Command Framework

Strongback’s command framework makes it easier to write robot code that does multiple things at once. Using the command framework is entirely optional: your robot might not need it, or if it does you might prefer to use another framework, such as the command-based framework built into WPILib.

What are commands and why are they useful? Many robots need to do multiple things at once, and Strongback’s commands provide a very simple, composeable, and testable way to organize the code to control these different activities. Plus, commands can be used in both autonomous and teleoperated modes.

When you use Strongback commands, you write each separate bit of logic to control these different parts as a command class. You can even create larger and more complex commands, called command groups, by composing them from a number of smaller, more atomic commands. Then at the appropriate time, your code creates an instance of a command and submits it to the scheduler. The scheduler’s job is to maintain a list of all submitted commands and, using a single thread, periodically go through this list and give each command an opportunity to execute. The scheduler removes a command when that command tells the scheduler it has finished completes, or if/when the scheduler receives a new command that preempts it.

The rest of this chapter starts with an example that shows why commands are useful, and then walks you through the details of how to use commands in your robot code and the flexibility and power that Strongback’s command framework provides. We then cover how to test commands, and finally end by comparing Strongback’s command framework to WPILib’s command-based programming.

results matching ""

    No results matching ""