Programming of micromouse to complete a maze
Background
With one semester of design in the bag, it was time to move into my second semester of third year and therefore move onto my second design course. We were now tasked with implementing everything that we learnt from our first design course in terms of the design process into a new project. We also had to assess what went wrong and what went well in our first semester and take those lessons into this new project. It is to be said though that this project was a continuation on the micromouse task.
The task
We were now tasked, once again in groups of two, with taking a fully finished micromouse with all the modules (including sensing and power) integrated into the system and programming the micromouse to learn the ideal path of a maze and then complete the ideal path of the maze in the fastest time possible.
The micromouse has a microcontroller implemented as one of the modules that both controls the sensor and power modules of the micromouse and can store the information of the maze and the decisions that the micromouse has made to move through the maze.
We had to configure the sensors and movement of the micromouse, allow it to make decisions in terms of where to move and storing all of this info in the micromouse microcontroller.
The was all done in matlab simulink and stateflow.
| Maze that had to be completed |
| Our micromouse that had to be programmed |
The Design
There was sort of two aspects that we had to be able to program. One was configuring the sensors so that the micromouse would be able to "see" things such as walls and the tape on the bottom of the wall so that it would able to follow that tape in order to move through the maze. The other aspect was programming the micromouse to be able to move through the maze and then while it is moving through, be able to determine what the best path is no matter where the mouse starts in the maze.
My partner did the programming and configuring of the sensors. Since the sensors were Infrared sensors, they were very susceptible to light. This involved testing the sensors to determine the voltage levels under varying conditions. The device would then be configured before a maze "run" and the sensors would be configured based on these conditions. The innovation that my partner came up with was to calibrate the system as you move through the maze just in case the environmental conditions changed. This would all then ensure that the micromouse could follow the lines in the maze and avoid walls.
I was tasked with programming the movement of the micromouse determining whether it should go straight or turn and programming how the micromouse would determine the best path. The movement was fairly simple to program, but finding the optimum path was the more challenging task. We decided to go with the "floodfill algorithm", a common algorithm used in micromouse competitions. This involved formulating the maze to be an artificial grid system and then assigning each block a number based on how far away you are from the end goal. These numbers would be changed throughout movement through the maze if the micromouse sees that a potential ideal path is blocked off by a wall. You can find more information about the floodfill algorithm in the following video.
Both of these had to be implemented in matlab in stateflow, which is programming flowchart software that can be used to program hardware.
| An example of coding in Matlab stateflow |
| Image demonstrating the floodfill algorithm |
| First testing of micromouse movement |
| First testing of line following |
Testing
We then had to test everything we had programmed in an actual maze. We made sure to load the code on the processor of the micromouse and then started our algorithms once we placed it in the maze. Here is a video demonstration of what we were able to accomplish:
In the end, our micromouse was able to find the end of the maze and save that ideal path in its memory, but we ran into issues with trying to be able to move through that ideal path in the fastest way possible. We realized that in a future iteration, we could simulate the maze solving beforehand to make sure that our algorithms would work properly. We were both extremely proud though with what we were able to accomplish.
What I learnt
This project really tested my design skills. We were essentially left on our own on this one and could approach the task in any way possible as long as we met the requirements that were set out. This meants that I had to learn how to define the project, plan how to approach the challenges faced and then problem solve and think on my feet to be able to solve any issues that came up. It also forced me to become more familar with my programming skills and how this can be implemented in hardware. It forced me to come up with new ideas and to be able to research the best way to solve a problem
More information
If you would like to know more about the specific details of this project, you can find our final report here: