State Charts
Our robot's software consists of three high-level event-handling services / state machines that run in parallel. First is the FSR Service for handling communication with the Field Status Reporter (i.e. FSR), the Strategy Service for deciding strategic choices during the game, and the Gameplay Service for organizing the hardware controls on the robot. The Ball Collecting, Scoring, and Wall Pushing state machines are sub state machines within the Gameplay Service.
FSR State Machine
The FSR State Machine is a flat state machine which cycles between different states corresponding to what data it is querying from the field. Within each state, a set of routines are called to properly communicate via Serial Peripheral Interface (SPI) protocols between the microcontroller and the wireless receiver (FSR).
Gameplay State Machine
The Gameplay State Machine is a hierarchical state machine that possesses three lower-level state machines. The lower level state machines correspond to the three general modes of movement that we decided the robot would need to handle : collecting balls, scoring balls, and pushing the wall. The low level Ball Collecting State Machine simply moves around the arena, driving forward and turning away from walls until further instructions are provided. The low level Scoring State Machine follows a specific set of commands in order, designed to help the robot find and deposit balls into bins from any starting position on the field. Finally, the low level Wall Pushing State Machine chooses a target bin to drive towards for the sake of protecting by clearing the wall away from it.
Strategy Service
The Strategy Service is not a state machine but instead an event handling service. It responds to different events that happen throughout the game and makes decisions based on these events, passing big events like Go To Scoring, Go To Ball Collecting, and Go To Wall Pushing into the Gameplay State Machine.