mode switching (might need more testing)

This commit is contained in:
aarav18
2023-02-13 19:47:24 -07:00
parent 44b5ed5c53
commit 3efe228e00
2 changed files with 16 additions and 2 deletions
+1 -1
View File
@@ -65,7 +65,7 @@ public final class Constants {
public static final int CANCODER_TICKS_PER_ROTATION = 4096; public static final int CANCODER_TICKS_PER_ROTATION = 4096;
public static final double JOYSTICK_TO_METERS_PER_SECOND_FAST = 11.0; // TODO: find the actual value public static final double JOYSTICK_TO_METERS_PER_SECOND_FAST = 11.0; // TODO: find the actual value
public static final double JOYSTICK_TO_METERS_PER_SECOND_SLOW = 1.0; // TODO: find the actual value public static final double JOYSTICK_TO_METERS_PER_SECOND_SLOW = 0.5; // TODO: find the actual value
public static final double MOTOR_REV_PER_WHEEL_REV = 5.12; public static final double MOTOR_REV_PER_WHEEL_REV = 5.12;
public static final double MOTOR_REV_PER_STEER_REV = 12.8; public static final double MOTOR_REV_PER_STEER_REV = 12.8;
@@ -7,6 +7,8 @@
package frc4388.robot; package frc4388.robot;
import java.util.function.BooleanSupplier;
import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.InstantCommand; import edu.wpi.first.wpilibj2.command.InstantCommand;
@@ -41,6 +43,9 @@ public class RobotContainer {
private final DeadbandedXboxController m_driverXbox = new DeadbandedXboxController(OIConstants.XBOX_DRIVER_ID); private final DeadbandedXboxController m_driverXbox = new DeadbandedXboxController(OIConstants.XBOX_DRIVER_ID);
private final DeadbandedXboxController m_operatorXbox = new DeadbandedXboxController(OIConstants.XBOX_OPERATOR_ID); private final DeadbandedXboxController m_operatorXbox = new DeadbandedXboxController(OIConstants.XBOX_OPERATOR_ID);
private boolean mode = true;
/** /**
* The container for the robot. Contains subsystems, OI devices, and commands. * The container for the robot. Contains subsystems, OI devices, and commands.
*/ */
@@ -77,7 +82,8 @@ public class RobotContainer {
.onTrue(new AutoBalance(m_robotMap.gyro, m_robotSwerveDrive)); .onTrue(new AutoBalance(m_robotMap.gyro, m_robotSwerveDrive));
new JoystickButton(getDeadbandedDriverController(), XboxController.B_BUTTON) new JoystickButton(getDeadbandedDriverController(), XboxController.B_BUTTON)
.onTrue(new InstantCommand(() -> m_robotSwerveDrive.highSpeed(false), m_robotSwerveDrive)); .onTrue(new InstantCommand(() -> m_robotSwerveDrive.highSpeed(mode), m_robotSwerveDrive))
.onFalse(new InstantCommand(() -> this.toggleMode()));
// /* Operator Buttons */ // /* Operator Buttons */
// // interrupt button // // interrupt button
@@ -110,6 +116,14 @@ public class RobotContainer {
return this.m_operatorXbox; return this.m_operatorXbox;
} }
public boolean getMode() {
return this.mode;
}
public void toggleMode() {
mode = !mode;
}
/** /**
* Add your docs here. * Add your docs here.
*/ */