Mobile Robot Navigation, step 3
Seeing with lidar
Turn lidar ranges into points on the walls, then drive a winding corridor with a rule that reacts to what the rover sees.
Builds on Angles, atan2 & 2-D rotation and Frames & homogeneous transforms, from the free Foundations.
Write and run this step in the simulator with ProA spinning laser
The rover's lidar sweeps a laser beam all the way round and times each echo. rover.lidar() returns a Scan of 180 beams, one every 2°:
scan.ranges[i]is how far beam went before it hit something (m);scan.angles[i]is its direction in the rover's frame: straight ahead, to the left, angles anticlockwise from ahead;- a beam that hits nothing reads exactly
scan.max_range(1.2 m). That's a miss, not a wall, andscan.validis False for it.
From ranges to the world
In the rover's frame, beam hit the point . To put it on the map, rotate it by the rover's heading and shift it by the rover's position . This rotate-then-shift is the SE(2) transform between the two frames:
Multiplied out, it says that beam points at in the world: and .
Reacting to what you see
Avoiding walls doesn't need a map. A reactive rule turns each scan straight into a command:
- ahead, left and right are the nearest hits within 30° of straight ahead, from 30° to 150°, and from −150° to −30°;
- : full speed when the way is clear, slowing over the last SLOW metres to a stop STOP metres short of a wall;
- , clipped to : turn rad/s towards the side with more room for every 10 cm it has over the other. In a corridor that holds the rover in the middle, and at a bend it turns into the opening.
Your task
- Write
scan_to_world(scan, pose): an array of the world points of the beams that hit, in beam order. Write it yourself rather than callingscan.points(). - Write
react(scan), returning by the rule above, with thenearesthelper.
The program draws your first scan on the walls, then drives the corridor, redrawing the scan every second. The checks want those points within 1.5 cm of the walls, and the rover at the end in under 60 s without a bump.