Code Architecture
We used a hybrid of HSM (Heirarchical State Machine) and FSM (Finite State Machine) to build out the code archictecture that ultimately enabled our autonomous robot to function. At the highest level we had four services - JSRBrain Service, Motor Service, Sensor Service, and the Servo Service. The JSRBrain service was responsible for interfacing with the Joust Status Reporter - which let the robot know what stage of the game it was in. The Motor Service was directly responsible for handling the two drive motors we had. In the sensor service lay all the code pertaining to our sensors (knight sensors, goal sensors). The Servo Service had a custom made library we developed for handling different servo motor actuations. These services were all on the same plane as our MasterHSM module, the heirarchical state machine we used for handling the different stages of the game.
MasterHSM
The Master HSM had different states each pertaining to the different stages of the game. There was a "Round 1" state, an "Intermission 1" state, a "Round 2" state, etc. all the way up to the Sudden Death state. Each of the Round states were state machines in themselves containing the states of "Driving" and "Soccerring" (the state in which the robot would be shooting at the goal). The Intermission states had multiple states as well, one in which it would be requesting balls from the depot (this was only relevant in Intermission 2) and one in which the bot would nudge up to the start line to better position itself for the beginning of the Round.
The Driving State was also a state machine and had the orthogonal states of Jousting (a state that controlled whether or not the lance would be deployed) and Shooting (a state in which the bot would be shooting its balls). The Shooting state is different from the Soccerring state because, it is at a lower level than the Soccering state (thus the Soccerring state machine could have Shooting as a state that it was in) and also because the robot could be shooting at the opposing knight-bot, where as Soccerring was a state specifically for shooting at the goal.
We used a hybrid of HSM (Heirarchical State Machine) and FSM (Finite State Machine) to build out the code archictecture that ultimately enabled our autonomous robot to function. At the highest level we had four services - JSRBrain Service, Motor Service, Sensor Service, and the Servo Service. The JSRBrain service was responsible for interfacing with the Joust Status Reporter - which let the robot know what stage of the game it was in. The Motor Service was directly responsible for handling the two drive motors we had. In the sensor service lay all the code pertaining to our sensors (knight sensors, goal sensors). The Servo Service had a custom made library we developed for handling different servo motor actuations. These services were all on the same plane as our MasterHSM module, the heirarchical state machine we used for handling the different stages of the game.
MasterHSM
The Master HSM had different states each pertaining to the different stages of the game. There was a "Round 1" state, an "Intermission 1" state, a "Round 2" state, etc. all the way up to the Sudden Death state. Each of the Round states were state machines in themselves containing the states of "Driving" and "Soccerring" (the state in which the robot would be shooting at the goal). The Intermission states had multiple states as well, one in which it would be requesting balls from the depot (this was only relevant in Intermission 2) and one in which the bot would nudge up to the start line to better position itself for the beginning of the Round.
The Driving State was also a state machine and had the orthogonal states of Jousting (a state that controlled whether or not the lance would be deployed) and Shooting (a state in which the bot would be shooting its balls). The Shooting state is different from the Soccerring state because, it is at a lower level than the Soccering state (thus the Soccerring state machine could have Shooting as a state that it was in) and also because the robot could be shooting at the opposing knight-bot, where as Soccerring was a state specifically for shooting at the goal.
State Charts
Whiteboard Iteration of HSM
States in MasterHSM
note: although not indicated above, Intermission 3 and Sudden Death were included in code, they follow the above sequence after Round 3.
Substates of above HSM
Lowest Level States
Key Generated Events
Developing a list of events generated by mere strokes on the keyboard came in handy when debugging the functionality of the robot. Futhermore, it allowed us to test functionality quicker as well .
Developing a list of events generated by mere strokes on the keyboard came in handy when debugging the functionality of the robot. Futhermore, it allowed us to test functionality quicker as well .
|
|
Psuedo Code
Highest Level Services and Master HSM (Heirarchical State Machine)
|
|
|
|
Second Level HSMs
|
|
|
|
Third Level HSM and SM (State Machine)
|
|
|
Lowest Level SMs
|
|
Header Files
Highest Level Services and Master HSM (Heirarchical State Machine)
|
|
|
|
Second Level HSMs
|
|
|
|
Third Level HSM and SM (State Machine)
|
|
|
Lowest Level SMs
|
|
Source Files
Highest Level Services and Master HSM (Heirarchical State Machine)
|
|
|
|
Second Level HSMs
|
|
|
|
Third Level HSM and SM (State Machine)
|
|
|
Lowest Level SMs
|
|