Skip to content

Stage 1B Overview

Stage 1A used a simple sequential approach to controlling the kitbot. But real robots need to respond to many inputs at once, like button presses, sensor data, and vision. Command-based programming solves this by modeling robot behavior as commands (actions) triggered by triggers (events).

Commands define individual robot actions (deploy the intake, index a game piece, drive based on joystick inputs). Triggers define when commands should run (controller input, sensor data reaches a certain threshold, the start of autonomous or teleop). Mechanisms represent the physical robot mechanisms that commands require and control (intake, indexer, drivetrain).

By the end of Stage 1B, you’ll rewrite your Stage 1A kitbot code into a command-based architecture, adding controller bindings, default commands, and simple autonomous routines.

This stage will cover the following topics:

Note

Why commands v3?

If you’re an experienced programmer, you likely know about or have used commands v2 in the past. Commands v3 is a major change from commands v2, changing the internals of the scheduler to run on Java’s continuations API. This much of the boilerplate code commands v2 necessitated to be removed and makes writing commands more akin to writing regular Java code.



Commands v3 also brings many improvements related to commands requiring mechanisms, allowing triggers to be scoped to an opmode or command, and a new state machine API. For all of these reasons, commands v3 was chosen for this course, as its authors believe that commands v3 offers a significantly better and simpler user experience compared to commands v2, enabling users to write the same functionality in a much simpler and easier way.