description |
---|
YAGSL has a helper for that! |
Lock Pose is a special circumstance when you want to stay in a position and become incredibly difficult to move. All of the wheels point inwards to an X formation. This should only be used when no other input is given or else there could be some breaking undefined behavior that happens.
You call the function SwerveDrive.lockPose()
repeatedly instead of passing any controller input.
public class RobotContainer
{
// Replace with CommandPS4Controller or CommandJoystick if needed
final CommandXboxController driverXbox = new CommandXboxController(0);
// The robot's subsystems and commands are defined here...
private final SwerveSubsystem drivebase = new SwerveSubsystem(new File(Filesystem.getDeployDirectory(),
"swerve/neo"));
/**
* The container for the robot. Contains subsystems, OI devices, and commands.
*/
public RobotContainer()
{
// Configure the trigger bindings
configureBindings();
Command driveFieldOrientedDirectAngleSim = drivebase.simDriveCommand(
() -> MathUtil.applyDeadband(driverXbox.getLeftY(), OperatorConstants.LEFT_Y_DEADBAND),
() -> MathUtil.applyDeadband(driverXbox.getLeftX(), OperatorConstants.LEFT_X_DEADBAND),
() -> driverXbox.getRawAxis(2));
drivebase.setDefaultCommand(driveFieldOrientedDirectAngleSim);
}
/**
* Use this method to define your trigger->command mappings. Triggers can be created via the
* {@link Trigger#Trigger(java.util.function.BooleanSupplier)} constructor with an arbitrary predicate, or via the
* named factories in {@link edu.wpi.first.wpilibj2.command.button.CommandGenericHID}'s subclasses for
* {@link CommandXboxController Xbox}/{@link edu.wpi.first.wpilibj2.command.button.CommandPS4Controller PS4}
* controllers or {@link edu.wpi.first.wpilibj2.command.button.CommandJoystick Flight joysticks}.
*/
private void configureBindings()
{
driverXbox.x().whileTrue(Commands.runOnce(drivebase::lock, drivebase).repeatedly());
}
/**
* Use this to pass the autonomous command to the main {@link Robot} class.
*
* @return the command to run in autonomous
*/
public Command getAutonomousCommand()
{
// An example command will be run in autonomous
return drivebase.getAutonomousCommand("New Auto");
}
public void setDriveMode()
{
//drivebase.setDefaultCommand();
}
public void setMotorBrake(boolean brake)
{
drivebase.setMotorBrake(brake);
}
}