Package frc.robot.commands
Class DriveCommands
java.lang.Object
frc.robot.commands.DriveCommands
A file that should contain all the commands that relate to the drivetrain.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Alternate implementation of the above method using a class instead of a command.static class
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic edu.wpi.first.wpilibj2.command.Command
arcadeDriveCommand
(Supplier<Double> forwardSpeed, Supplier<Double> turnSpeed) A command that sets the speed of the robot based on an arcade control scheme, using an Instant Command.static edu.wpi.first.wpilibj2.command.Command
driveDistance
(double distance) Method that causes the XRP to drive a certain distancestatic edu.wpi.first.wpilibj2.command.Command
Commands can also a part of command groups, which are sets of commands that run in certain ways.static edu.wpi.first.wpilibj2.command.Command
turnDegreesCommand
(double speed, double degrees)
-
Constructor Details
-
DriveCommands
public DriveCommands()
-
-
Method Details
-
driveDistance
public static edu.wpi.first.wpilibj2.command.Command driveDistance(double distance) Method that causes the XRP to drive a certain distance- Parameters:
distance
- Distance that the XRP drives in inches- Returns:
- Command that causes the XRP to execute the functions below
-
arcadeDriveCommand
public static edu.wpi.first.wpilibj2.command.Command arcadeDriveCommand(Supplier<Double> forwardSpeed, Supplier<Double> turnSpeed) A command that sets the speed of the robot based on an arcade control scheme, using an Instant Command. Because this value is something that changes based on controller input, we want the values to be rechecked periodically. For this, we use what is called a supplier, which is any function which returns a double. By using a supplier, instead of the drive speed being a constant 0, the command instead runs the supplier each time it runs to determine the correct speed.- Parameters:
forwardSpeed
- Speed the robot goes forward. Is a supplier, and therefore must be a method or a lambda.turnSpeed
- Speed the robot turns. Is a supplier, and therefore must be a method or a lambda.- Returns:
- Command to arcade drive the XRP
-
turnDegreesCommand
public static edu.wpi.first.wpilibj2.command.Command turnDegreesCommand(double speed, double degrees) -
sequentialExampleCommand
public static edu.wpi.first.wpilibj2.command.Command sequentialExampleCommand()Commands can also a part of command groups, which are sets of commands that run in certain ways. Sequential Command Groups are commands that execute one after another. This is useful for auto behavior.- Returns:
- A command that drives forward 5 inches, turns 90 degrees, and drives forward 4 inches.
-