Introduction
Even with the most beautifully designed mechanical and electrical systems, it is all for naught without robust and reliable software. With this in mind, we have designed a software architecture that is simple, organized, and powerful; all of this supports an elegant state machine with inter-robot communication.
State Machine
Faced with a competition that has many unique challenges occurring sequentially, we determined that designing a state machine for each robot would be the most elegant method of control.
This allows us to give each part of the competition a descriptive name and specific instructions, from RampClimbing to BasketLifting. The robots perform different actions based on where they are in the competition, which allows us to test different parts of the course modularly. The descriptive naming also helps our team more clearly communicate when discussing ideas for different parts of the competition.
Communication
The best communication is needing no communication: a single microcontroller. But with six motors, four servos, and over a dozen sensors, there are simply not enough pins on a single STM32 microcontroller to control both robots.
We decided on using the Master-Slave protocol for inter-robot communication, as this would be simple, reliable one-way communication that requires only two communication wires.
Vader Bot (the upper robot) is the Master, as it contains the majority of the sensors and actuators guiding the system throughout the competition. Trooper Bot (the lower robot) only performs its tasks if Vader Bot commands it.
Abstraction
In order to handle the complexity of our robots’ many functionalities, we have divided each component of the robot into separate libraries.
By abstracting away the implementation of each module, we are able to both build our codebase more quickly through improved team collaboration and keep our high-level robotic control software clean, bug-free, and easily tuned.
Click here to read more about the individual components.
Reliable Performance
Reliable performance is essential for our robots, so we made the following improvements to ensure that they demonstrate this quality.
- Regulated loop time – ensure consistent behavior between iterations
- Debounced pin readings – greater tolerance to electrical noise
- Non-blocking code – improve robots’ responsiveness by continuously performing all tasks without getting stuck on any particular task