State Charts
Our TRACTOR software was set up with two upper level state machines and a single lower-level state machine, with interrupt-driven services handling motor control.
Upper Level State Machines: RobotHSM and SPUDSM
RobotHSM serves as the top level hierarchical state machine for mining operations, whereas SPUDSM is a standalone flat state machine that polls the SPUD every 250ms to acquire the most up-to-date information on the field. This polling sequences acquire data from all SPUD registers, including data on mining permits, MINER locations, real-time score, mining locations, etc.
Robot Hierarchical State Machine Pseudocode
|
|
SPUD State Machine Pseudocode
|
|
Lower-Level State Machine - GameplaySM
After mining permits are issued, GameplaySM is started and begins controlling the primary function of our TRACTOR. Within this state machine, the DecidingStrategy state does most of the heavy lifting.
Our overall strategy is based on a large decision tree that is evaluated upon entry to the DecidingStrategy state. This tree takes into account whether or not our TRACTOR possesses a MINER, current MINER locations, current mining locations, and the success/failure of the previous step to create a Master Plan that consists of individual steps for the TRACTOR to follow. This Master Plan is evaluated in the Rotating2Target and Driving states to determine our next target location.
The Rotating2Target state uses accelerometer interrupts to orient ourselves along one of the four cardinal directions towards a the target square.
The Driving state drives straight with an encoder tick count corresponding to the color of our current square, assuming we have been correctly oriented in the Rotating2Target state. If a collision interrupt is triggered by the accelerometer, we move to the Reversing state.
In the Reversing state, we drive backwards while constantly monitoring the MINER locations from the SPUD. If any of the MINERs moves into the same square as our TRACTOR, we can assume that we have captured that MINER with our permanent magnets and proceed with a new Master Plan generated by entering the DecidingStrategy state.
Our overall strategy is based on a large decision tree that is evaluated upon entry to the DecidingStrategy state. This tree takes into account whether or not our TRACTOR possesses a MINER, current MINER locations, current mining locations, and the success/failure of the previous step to create a Master Plan that consists of individual steps for the TRACTOR to follow. This Master Plan is evaluated in the Rotating2Target and Driving states to determine our next target location.
The Rotating2Target state uses accelerometer interrupts to orient ourselves along one of the four cardinal directions towards a the target square.
The Driving state drives straight with an encoder tick count corresponding to the color of our current square, assuming we have been correctly oriented in the Rotating2Target state. If a collision interrupt is triggered by the accelerometer, we move to the Reversing state.
In the Reversing state, we drive backwards while constantly monitoring the MINER locations from the SPUD. If any of the MINERs moves into the same square as our TRACTOR, we can assume that we have captured that MINER with our permanent magnets and proceed with a new Master Plan generated by entering the DecidingStrategy state.
|
|
Other Source Code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
es_configure.h | |
File Size: | 15 kb |
File Type: | h |