Hierarchical State Machines
MasterSM
MasterSM is the highest level state machine, responsible for responding to permit-based events received via the SPUD. Upon entrance of the Active Gameplay state, the middle level of this hierarchical state machine is initiated.
ActiveGamePlaySM
ActiveGamePlay is the middle level state machine which processes game play events (i.e. what the robot will do to play the game). It consists of six states which holistically allow the robot to locate, grab, and move a MINER. Upon entrance of the Look4Miner state, the lowest level of this hierarchical state machine is initiated.
Look4MinerSM
Look4Miner is the lowest level state machine which assigns and searches for the CurrentMinerTarget, one of the four MINERS on the field. This state machine interfaces with the Brains service which allows it to determine the CurrentMinerTarget. Look4MinerSM will then pass the CurrentMinerTarget up to ActiveGamePlaySM after the target has been found.
Flat State Machines
NavigationSM
NavigationSM determines the correct TargetAngle and TargetDistance to the desired target location, moves the robot to that location, and handles accidental collisions detected by the bumper.
SPUDSM
SPUDSM send the appropriate bits to the SSIDR and reads from all registers to determine the status of the game, location of miners, and the location of permits.
MotorSM
MotorSM implements PI control, keeps track of encoder counts on the wheels, and utilizes PWM to physically turns the robot, drives it forward, backward, and stops it. This state machine also actuates the movement when the bumpers sense a collision.
LEDSM
This one state state machine blinks the Mining LED when permits are issued and turns off the LED when permits expire. In the initialization, the correct comany LED is turned on.