From 593369efb5ba2c4b442aa38b564ea41e4f80e30e Mon Sep 17 00:00:00 2001 From: nathanrsxtn Date: Sat, 15 Jan 2022 09:54:25 -0700 Subject: [PATCH] Get HAL controller data every command run --- .../java/frc4388/robot/RobotContainer.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index db00580..ee6d25b 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -5,9 +5,6 @@ package frc4388.robot; import edu.wpi.first.hal.HAL; -import edu.wpi.first.math.geometry.Rotation2d; -import edu.wpi.first.math.geometry.Translation2d; -import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.XboxController; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.Command; @@ -49,7 +46,7 @@ public class RobotContainer { private final XboxController m_driverXbox = new XboxController(OIConstants.XBOX_DRIVER_ID); private final XboxController m_operatorXbox = new XboxController(OIConstants.XBOX_OPERATOR_ID); - private final boolean bypassDSController = true; + private static final boolean BYPASS_DS_CONTROLLER = true; /** * The container for the robot. Contains subsystems, OI devices, and commands. @@ -58,14 +55,14 @@ public class RobotContainer { configureButtonBindings(); /* Default Commands */ // drives the swerve drive with a two-axis input from the driver controller - float[] joystickAxes = new float[HAL.kMaxJoystickAxes]; - HAL.getJoystickAxes((byte) getDriverController().getPort(), joystickAxes); - double leftXAxis = bypassDSController ? joystickAxes[XboxController.Axis.kLeftX.value] : getDriverController().getLeftX(); - double leftYAxis = bypassDSController ? joystickAxes[XboxController.Axis.kLeftY.value] : getDriverController().getLeftY(); - double rightXAxis = bypassDSController ? joystickAxes[XboxController.Axis.kRightX.value] : getDriverController().getRightX(); - m_robotSwerveDrive.setDefaultCommand(new RunCommand(() -> - m_robotSwerveDrive.driveWithInput(clampJoystickAxis(leftXAxis, leftYAxis), -rightXAxis, true), - m_robotSwerveDrive + m_robotSwerveDrive.setDefaultCommand(new RunCommand(() -> { + float[] joystickAxes = new float[HAL.kMaxJoystickAxes]; + if (BYPASS_DS_CONTROLLER) HAL.getJoystickAxes((byte) getDriverController().getPort(), joystickAxes); + double leftXAxis = BYPASS_DS_CONTROLLER ? joystickAxes[XboxController.Axis.kLeftX.value] : getDriverController().getLeftX(); + double leftYAxis = BYPASS_DS_CONTROLLER ? joystickAxes[XboxController.Axis.kLeftY.value] : getDriverController().getLeftY(); + double rightXAxis = BYPASS_DS_CONTROLLER ? joystickAxes[XboxController.Axis.kRightX.value] : getDriverController().getRightX(); + m_robotSwerveDrive.driveWithInput(clampJoystickAxis(leftXAxis, leftYAxis), -rightXAxis, true); + }, m_robotSwerveDrive )); // continually sends updates to the Blinkin LED controller to keep the lights on