Maze Following Robot Logic

So, the basic premise of the robot is that it drives forward down the center of the maze until it comes within 4 centimeters of a wall and stops. Once it hits that point it needs to determine whether or not it needs to turn to the right or the left. To do this we have the program compare the distance on the left and the right side of the robot using the ultrasonic sensors.

What does the maze look like? Where is the target destination? Will you take note of side corridors as you pass them?

Way back when, my colleague & I wrote a solver for a robot designed to solve the micro mouse maze - sadly the robot mechanics lagged way behind the solver code. That maze is of known dimensions and the start and target locations are known.

The idealized robot had forward, left and right distance sensors. It explored the maze, preferring straight ahead over turns, but took note of any side passages it encountered, gradually building up a picture of where the walls were. Once it found the destination (the centre), it stopped - in micro mouse, having learned the maze you then get to try for speed. I think the map was just a 2D array of bytes with each byte representing a cell in the maze. Each cell had four bits representing the walls.

Running the maze once a route was found was just a matter of flood filling the number of steps each cell is away from the centre. Then the robot simply navigates by choosing a cell to move to that needs fewer steps than the one it currently occupies.

For an optimal solution in micro mouse at least, the robot should explore the entire maze because there is usually more than one route to the goal.