The robot
Side view, front is on the rightHold a button (or its key) to ask for that state. Let go to ask for DRIVE.
Alliance zone: scoring_mode_ = SCORE, shoot at the hub (250 rad/s). Neutral zone: PASS, pass to our side (300 rad/s).
Robot states
Solid outline:system_state_. Red outline: wanted.Inside RobotContainer, this loop
Loop 01Wanted state
robot.getWantedState()=DRIVESet by the last button call. It stays wanted until something asks for another state ("sticky").
2handleStateTransition(wanted): the transition table
The real Java
3system_state_
4updateLogic()
no if in here
Trimmed: the real arms also set the localization state, the shooter target and a drive speed scale. Every arm asks every subsystem, every loop, so there are no enter or exit actions.
5Then each subsystem runs its own state machine
Things to try
- Shoot from a standstill. Turn off Driver is driving, then hold Shoot. The robot waits in
SHOOT_WAIT, then jumps toSHOOT_FEED_BRAKEDand crosses its wheels. - Watch a shot knock the flywheel out of tolerance. Each game piece slows the flywheel by about 15 rad/s, out of its ±10.5 rad/s tolerance. The shooter drops back to
SHOOT_WAITand so does the robot, until it recovers. - Find the sticky request. In
SHOOT_WAITthe robot asks the intake for nothing. Look at the intake card: its wanted state stays whatever was asked last. - Hold Intake, then also hold Shoot, then let go of Intake. The robot keeps shooting: the release only asks for
DRIVEifINTAKEis still wanted. - Pass on the move. Pick Neutral zone, keep driving and hold Shoot.
SHOOT_PASS_INTAKEkeeps intaking. Stop driving and it feeds. - Step through a transition. Pause, hold Shoot (paused, the buttons toggle), and press Step one loop until the robot changes state. Note which table row fired.
Read more: State Machines (the super state machine and writing the transitions) and Subsystems (a subsystem's transition table).