Commands
Here you will learn about commands.
Shows options on how to set up new commands. More information on commands can be found here
There are two main ways we recommend setting up commands.
This is a standard command. Refer to WPILib for more examples.
With more complex systems, you need a way to better define states. For this, we implement a state system designed by CCShambots.
Complex Example Breakdown
Let's go ahead and break down the complex command.
This code allows us to extend the CCShambots StateMachine class and add different states. States are gotten from our enum Flywheel.State
In this block of code, we are setting our flywheel to an undetermined state, registering all states the flywheel can be in, and also the state-to-state transitions that are allowed
Now let's dive into registerStateCommands()
.
This code defines what we want to happen when we tell the Flywheel to go into AMP mode.
In this case, we want to set the flywheel speed and trigger a flag when our speed is within tolerance to alert another part of our code to shoot.
By defining all possible states of the robot, we give it a clear purpose and direction, enhancing its functionality. This will allow you to add safety and more automation to your code.
This allows our flywheel to transition between any state without restrictions. This will change on your applications.
After that, all the code is pretty standard in other commands.
Finally, you need to call from RobotContainer.java
to set the state. You may need states in your RobotContainer.java
for very complicated robots.