The highest level hierarchical state machine (HSM) is the master state machine (SM). The master SM is responsible for the transitions between the idle state and playing SM. These transitions facilitate turning on and off the game LED via initiating and resetting a timer.Â
The second level of the HSM, playing SM, determines the Scrat Pack's game strategy. It always begins by entering the Yard Determining state. In Yard Determining, the dynamixel beacon detection servo scans the field for the four beacon frequencies. Upon successfully finding all four beacons, it calculates and stores relative angles between them, using the angles to determine and indicate which side of the field the robot was placed. One done indicating, it sends the and event indicating the yard has been determined which initiates a transition into the Left Tree SM. Once the Left Tree SM is completed, it transitions the playing SM into the Right Tree SM to move to and clear the second tree. Once the Right Tree SM is complete, an event gets posted to send the playing SM into the Roaming SM, which looks for and shoots across stray ACORNs. Details of the Left Tree SM and Right Tree SM are further below.
The red arrows indicate the paths we were able to incorporate into our robot's physical performance within the timeline of the project, while the the rest of the event transitions were structured in code but not physically implemented.
The Left Tree SM starts in the Start Aligning state which involves the Dynamixel IR detector surverying the field for the four IR beacons. Once found, the SM moves into Going To T, which rotates the robot towards the center of hte field and drives forward until it has detected tape on it's side sensors. It then makes a 90 degree left turn in the Turing state to then drvie forward using velocity PID control in the Going to Tree state until it reaches the beacon. Once at the beacon, the robot goes through routine of collecting, reversing, aiming, opening (the collector), launching, and realigning to the tree. It performs this routine five times to exhaust the ACORNs at the tree, when it sends the ES_LEFT_TREE_CLEARED event to exit the state machine
The Right Tree SM is nearly identical to the Left Tree SM other than its initial aligning and travelling. At it's entrance, the robot will be align itself by making a CW turn until it's back sensor detects the tape, then drives forward using velocity PID control until it detects the wall of the right tree. One at the tree, the robot performs the same collecting and shotting routine described in the Left Tree SM until the five ACORNs under the right tree have been sent under the fence.