Awesome
High Integrity Sumobot
This mini-sumobot is an advanced-level project programmed in Ada/SPARK and Arduino (C++).
Story
I created the High Integrity Sumobot using Ada/SPARK and high integrity software engineering techniques. I wanted to make it easy for people interested in Ada/SPARK to see how all the pieces fit together in a small embedded project.
I did my best to write simple, clean, and maintainable code throughout. It's extensively commented and it's open source so you can use it almost any way you want.
System overview
I started with a Zumo 32U4 sumobot. But instead of programming it directly as a microcontroller like most people do, I turned it into an I2C slave device, which I control with a microbit I programmed in Ada/SPARK.
The zumo continuously collects sensor data and stores it in a buffer. The microbit periodically requests sensor data from the zumo over I2C and the zumo sends the data it most recently collected. The microbit validates the sensor data, decides how the zumo should move, and sends motor commands back to the zumo (also over I2C). The zumo validates the motor commands and then executes them. And then the process repeats (at least 50 times per second).
The main job of a sumobot is to fight in sumo competitions. So the bulk of the code on the microbit is related to the fighting algorithm. Here's a simplified state table for it:
The 5 x 5 display on the microbit shows a character representing the current top-level state of the system (see the "Display" column of the state table above):
You can see the most important zumo parameters on the zumo's LCD, which is helpful for development and debugging. It shows the following information:
More information and build instructions
You can find the full documentation and build instructions for this project on my website. I've included everything you need to create your own High Integrity Sumobot:
- written requirements
- full parts list
- wiring diagram
- detailed build instructions (with photos)
- detailed software installation instructions (with screenshots)
- instructions for how to run the automated unit tests
- compile/build and upload/flashing instructions (with screenshots)
- end-to-end testing plan linked to each requirement