State Charts
Master SM
The MasterSM was the top level state machine in our hierarchy. It managed three things: navigation to a recycling point, navigation from a recycling point to the catching point (to catch balls launched onto our collector) and to handle an edge case wherein we'd get stuck in a loop of collisions. The MasterSM kept track of the recycling centre that was currently being handled (either one of east or west) and the assigned emit frequency to open the door.
Go To Recycle
This state machine handled the navigation from any point on the assigned hemisphere of the robot to the assigned recycling centre. This was done by a sequence that first found the line, aligned with it and followed it till collision with the recycling centre wall. By the end of the project, we added states to manage edge cases like going off the line, unexpected collisions, not being able to find the line, etc.
Go To Catching Point
Since the arena was symmetrical, our team had decided to abstract the recycling and landfill centres as "opposite", "left", "right" and "home" beacons. This way our navigation was independent of whether we were the north our the south team. The conversion from the COMPASS information to our convention was done in the SPI (communication) module itself so that the rest of our system could follow the convention agnostic to which team we were.
Navigation from the left or the right recycling centres was done using closed loop control (two loops: one for RPM control and one for position using encoder ticks).
Navigation from the left or the right recycling centres was done using closed loop control (two loops: one for RPM control and one for position using encoder ticks).
Drive SM
The DriveSM was a state machine that made available drive functions such as stopping, driving forward/reverse, turning left/right with or without a specified distance/angle. We decided to add this as a state machine as it made navigation very simple and abstracted all low-level motor drive functions. DriveSM also managed unexpected collisions.
Collision SM
The CollisionSM state machine posts events for collisions with the wall as well as with other robots using information from the limit switches (front and back) as well as the tape sensor that senses IR reflected off of the retroreflective tape on other robots.
Ball Collector SM
The BallCollectorSM is a simple flat state machine that controls the actuation of the ball collector DC motor for either collection or dispensing balls and the trap door opening and closing based on events passed to it by MasterSM.
SPI SM
The SPISM is a flat state machine that manages the SPI communication between the TIVA and the COMPASS. It performs team registration and queries for information regarding the recycling centre, recyclable ball colour and the emit frequency.
Code Listings
|
|