Open maxchen132 opened 1 year ago
Instructions from Jaci (These are all separate autonomous commands that we might want to use):
1 and 2 combined (combine the logic, don't just copy paste one after the other)
1 has been completed (mostly, excluding any necessary initial calibrations) as an example of how an auton command is implemented (probably, may be subject to future change)
Since our first competition is coming up so soon, I'm going to start working on this issue as well. If there's a part of this issue you want to work on, comment on this issue and I'll let you do it. Otherwise, I'm going to assume no one is taking this and just finish it because we need it for competition.
Currently, 1 is finished (tentatively, still need to test) and most of 2 has been completed by Ivan.
3 tentatively completed.
4 tentatively completed, all autons are still open to adjustments and suggestions
Requires testing
If you have any ideas for auton, feel free to make them as well, these 4 don't have to be the only options we have
The autonomous mode is the 15 second period at the beginning of the match in which the robot operates without any input from the drivers. We want to have different autonomous commands to run. Your task is to code different autonomous mode commands, according to instructions provided by Jaci probably which I will post here later probably once I receive specific instructions.
There are multiple things you'll want to understand before you start this. First, you'll want to know how to use PathWeaver, since we will be using PathWeaver to move the robot efficiently along trajectories during autonomous. Whenever we want to move the robot from point A to point B, most of the time we will want to use PathWeaver to draw a trajectory between two points. Documentation of PathWeaver can be found in issue #35 .
Second of all, you'll want to understand our autonomous command structure and the way in which commands work. Documentation on commands can also be found in the Read documentation issue.
Explanation for autonomous command structure: Our autonomous command structure is made up of several parts:
Code in
RobotContainer.java
: the code here initializes and passes the selected autonomous command to the robot to be run in autonomous mode. We select the different autonomous commands through SmartDashboard (a dashboard which we use to help control the robot), which is implemented inRobotContainer
throughSendableChooser<Command>
. Furthermore, all trajectory commands generated by PathWeaver are retrieved from their JSON files and stored inRobotContainer
.Code in
Autons.java
:Autons.java
can be found in thecommands.autocommands
folder, and contains multiple factory methods which return create and return Commands to be run inRobotContainer
(factory methods are methods that generate objects). Each factory method returns a Command that is passed in throughSendableChooser
to be an option on SmartDashboard, so that we can choose different autonomous commands to run depending on the situation during competition. In other words, each method inAutons.java
represents one autonomous command.How to actually code autonomous commands: To create our autonomous commands, we will be using command compositions, which is the combination of smaller commands/actions to create larger commands (you can read about command compositions in the documentation). In order to generate instant actions/commands, we use this:
If the -> operator is new to you, look up java lambdas.
subsystem1
andsubsystem2
can be any number of subsystems that the command needs to access. You will most likely use this structure to code all of the arm instructions, as the drive instructions will be handled by the trajectory commands stored inRobotContainer
. These instant commands can be concatenated with other commands using the.andThen()
and.alongWith()
decorators, which is how we will be calling both the instant commands and trajectory commands together as one command. Additionally, you will need to add the subsystems that you want to use as parameters to the factory method you are working on (see comments inAuton.java
for more details). TLDR: use command compositions to create autonomous commands to be passed in to the robot to be run during autonomous modes.As always, if there are any questions feel free to ask. Sorry for the wall of text, some of it might be hard to understand cuase Im tired