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.
How do I use Lock Pose?
You call the function SwerveDrive.lockPose() repeatedly instead of passing any controller input.
publicclassRobotContainer{// Replace with CommandPS4Controller or CommandJoystick if neededfinalCommandXboxController driverXbox =newCommandXboxController(0);// The robot's subsystems and commands are defined here...privatefinalSwerveSubsystem drivebase =newSwerveSubsystem(new File(Filesystem.getDeployDirectory(),"swerve/neo")); /** * The container for the robot. Contains subsystems, OI devices, and commands. */publicRobotContainer() {// Configure the trigger bindingsconfigureBindings();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 * {@linkTrigger#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}. */privatevoidconfigureBindings() {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 */publicCommandgetAutonomousCommand() {// An example command will be run in autonomousreturndrivebase.getAutonomousCommand("New Auto"); }publicvoidsetDriveMode() {//drivebase.setDefaultCommand(); }publicvoidsetMotorBrake(boolean brake) {drivebase.setMotorBrake(brake); }}