We often tell beginners that they can learn a lot by building a non-contact wall following micromouse. If it can keep track of where it is and knows when it is in the centre of the maze, most of the hard problems have been solved. To get to that stage, you need working sensors, reliable motor control and good information about the maze and the mouse’s position in the maze…
Beginners often get hung up about the whole maze thing. the issues of solving it in particular. These fears are often unfounded as the maze handling is relatively easy. Once you know how it is done, it is just a bit of software that you can run on your PC to test it out. Most maze builders seem to do that.
The challenges in building a micromouse lie in things like building reliable mechanicals, implementing good control algorithms for the motors and having good sensors. The motor control could be the hardest part of the software. There are any number of examples of how to make a digital servo or positioner. They all overlook a key feature of the mouse controller. First, you don’t know where a move will finish when you start it. That makes most of the servo algorithms nearly useless. Second, there are two wheels (on most mice) that need to be controlled together to give the mouse a reliable position and rotation.
Decimus, of course, has been designed from the start as a full maze-solving micromouse. However an essential part of the commissioning of a mice is, I believe, putting it through the wall-follower stage. The early phases of making a mouse require that you test each of the subsystems independently and then start to get them to work together. Once you are able to get the mouse moving, you need to link in the sensors to provide steering control in the maze.
Eventually, there will come a time when the mouse is able to run a maze. This is most easily accomplished if there is a command processor that can take a string of commands such as FWD4, L90, FWD4, R90 and so on. By planning for this end, you create the means by which the mouse will do everything else.
Following a wall is just a simplified case of the exploration of an unknown maze. With Decimus, I do that by giving the mouse a single command to move forward 1 square. Half way through the move, the sensors can see into the next cell and are able to detect any walls. The map can then be updated and a decision made as to what the mouse will do next. For the wall follower, we just look to see if the mouse can turn left. If so, the move is allowed to finish and a pair of moves, L90, FWD1, is sent to the command processor and we loop back. If there is a wall ahead and to the left but we can turn right, the commands will be R90, FWD1. Walls on all three sides need the command pair R180, FWD1. Walls to either side and none ahead are easily dealt with by directly manipulating the distance the mouse thinks it has left to travel in its single-square move. Simply add the length of one square to the final position and the mouse will carry on as if nothing had happened.
Here is a short video of Decimus following the left wall in this fashion until it reaches its target square. At the target square, it pauses for half a second and then follows the left wall to the start.
For a full solver, the only difference in this behaviour is that, having recorded the walls and updated the map, the mouse will need to solve the maze and use the information from that to decide which way to turn.