8. Wheeled robots¶
wheeled_nav is a differential-drive robot driving to a goal between obstacles: the bundled
Pioneer-size model (pioneer: a 10 kg chassis, two driven wheels of 16.5 cm diameter and a rear
caster ball) rolling on flat ground. The wheels and the caster use the soft tyre force of the
floating-base package, computed in the compiled kernel, so this task steps as fast as the others.
This task needs the floating-base package (see Install).
import numpy as np
import redysim_rl
env = redysim_rl.make_vec("wheeled_nav", num_envs=8, task_kwargs={"n_obstacles": 6})
obs, info = env.reset(seed=0)
for _ in range(20): # drive straight on at half speed
obs, reward, terminated, truncated, info = env.step(np.tile([0.5, 0.0], (8, 1)))
print(obs.shape, info["distance"].mean().round(2), int(info["collision"].sum()))
The world¶
The arena is a square of 6 m (half width 3 m) with discs on the ground as obstacles (radius 0.2 to 0.45 m, six by default). At every reset the robot gets a random place and heading, the goal is at least 2 m away, and no obstacle covers the start or the goal. The obstacles are not bodies of the physics: the robot passes through them, and touching one (or a wall) ends the episode. The robot counts as a disc of radius 0.28 m. A robot that tips over also ends the episode.
What the policy sees and does¶
The action is a forward speed and a turn rate in [-1, 1], scaled by 1 m/s and 2 rad/s (positive
turns left): the diff_drive action mode. It converts them to the two wheel speeds and a speed law
kd (target - speed) on each wheel, clipped to 1 N m, the way the speed-controlled motors of a real robot
work; the law is evaluated at every 5 ms physics step. The control step is 50 ms and an episode lasts
500 steps (25 s).
The observation has 26 values for the default 16 rays:
| values | content |
|---|---|
| 3 | the goal in the heading frame: forward and left (divided by the arena half width) and the distance |
| 3 | forward speed, lateral speed (m/s) and yaw rate (rad/s) |
| 2 | the wheel speeds (divided by 10) |
| 2 | the previous action |
| 16 | the range finder: 1 - range / 3 m for 16 rays all round (0: nothing within 3 m, 1: touching) |
The range finder is computed from the discs and the walls by ray intersection, so it costs little; the
rays and the range are settings (n_rays, fov, lidar_range). The policy has no map and no position:
it has to steer round what the range finder shows.
Reward¶
Per step: 5 × the distance gained towards the goal, +20 on reaching it (within 0.3 m; the episode
ends), -0.02 for time, -0.02 |a - a_prev|², -0.5 (0.4 - d) while an obstacle or wall is closer than
0.4 m (edge to edge), and -20 on a collision (the episode ends). info has distance, is_success,
collision, clearance and forward_speed.
Settings¶
from redysim_rl import RedysimVectorEnv
from redysim_rl.wheeled import WheeledNavigation
task = WheeledNavigation(n_obstacles=8, arena=3.0, obstacle_radius=(0.2, 0.45), n_rays=16,
lidar_range=3.0, tol=0.3)
env = RedysimVectorEnv(task, num_envs=4)
obs, _ = env.reset(seed=1, options={"start": [[0.0, 0.0]] * 4, "heading": [0.0] * 4,
"goal": [[2.0, 0.0]] * 4})
print(obs.shape)
reset also takes obstacles (N, K, 2) and radii (N, K) to place the obstacles yourself. The
same wheel model runs in the package's own simulation, and its behaviour was compared with MuJoCo
(see the floating-base manual).
Why the wheels carry an inertia of 0.02 kg m²¶
The tyre slip is stiff: a bare wheel (0.0017 kg m² about its axle) makes the slip mode about 8000 per second, and a fixed 5 ms step cannot integrate that (the wheel speed chatters). The bundled model gives the wheel the inertia it has with its rotor and gearbox reflected onto it (0.02 kg m²), as a real robot does. If you change the wheel inertia or the tyre stiffness, check that a driven wheel's speed is smooth.