diff --git a/simgui-ds.json b/simgui-ds.json index 8e88840..d22008a 100644 --- a/simgui-ds.json +++ b/simgui-ds.json @@ -1,4 +1,9 @@ { + "Keyboard 0 Settings": { + "window": { + "visible": true + } + }, "keyboardJoysticks": [ { "axisConfig": [ @@ -42,7 +47,7 @@ "key270": 324, "key315": 327, "key45": 329, - "key90": 326 + "key90": 54 } ], "povCount": 1 @@ -83,7 +88,7 @@ 51, 52, 53, - 54 + -1 ], "povCount": 0 }, @@ -94,11 +99,6 @@ } ], "robotJoysticks": [ - { - "guid": "78696e70757401000000000000000000", - "useGamepad": true - }, - {}, { "guid": "Keyboard0" } diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 2752346..8c6eb8a 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -74,6 +74,8 @@ public void robotPeriodic() { // block in order for anything in the Command-based framework to work. CommandScheduler.getInstance().run(); logPowerDistribution(); + + Logger.recordOutput("Drive/WheelsLocked", m_robotContainer.getBraking()); } private void logPowerDistribution() { diff --git a/src/main/java/frc/robot/RobotContainer.java b/src/main/java/frc/robot/RobotContainer.java index c1c1098..5dc8752 100644 --- a/src/main/java/frc/robot/RobotContainer.java +++ b/src/main/java/frc/robot/RobotContainer.java @@ -102,6 +102,7 @@ public class RobotContainer { private final SlewRateLimiter robotYSlewFilter = new SlewRateLimiter(Constants.SlewLimits.slewTranslateLimit.in(MetersPerSecondPerSecond)); private final SlewRateLimiter robotRotateSlewFilter = new SlewRateLimiter(Constants.SlewLimits.slewRotateLimit.in(RadiansPerSecondPerSecond)); private boolean simRobotCentricMode = false; + private boolean braking = false; private final SubsystemCommands subsystemCommands = new SubsystemCommands( swerve, @@ -384,41 +385,8 @@ private void configureBindings() { } private void configureSimBindings() { - swerve.setDefaultCommand( - swerve.applyRequest(() -> { - if (!isSimControllerConnected() && !isDriverControllerConnected()) { - return fieldCentricDrive.withVelocityX(0.0).withVelocityY(0.0).withRotationalRate(0.0); - } - - double exponentVelocity = - Constants.SimConstants.controllerVelocityCurveExponent; - double exponentRotation = - Constants.SimConstants.controllerRotationCurveExponent; - - if (!simRobotCentricMode) { - double fieldX = fieldXSlewFilter.calculate( - Constants.Driving.kMaxSpeed.in(MetersPerSecond) - * ExponentialConvert(getSimLeftInput(), exponentVelocity)); - double fieldY = fieldYSlewFilter.calculate( - Constants.Driving.kMaxSpeed.in(MetersPerSecond) - * ExponentialConvert(getSimForwardInput(), exponentVelocity)); - double fieldRotate = fieldRotateSlewFilter.calculate( - Constants.Driving.kMaxRotationalRate.in(RadiansPerSecond) - * ExponentialConvert(getSimRotationInput(), exponentRotation)); - return fieldCentricDrive.withVelocityX(fieldX).withVelocityY(fieldY).withRotationalRate(fieldRotate); - } else { - double robotX = robotXSlewFilter.calculate( - Constants.Driving.kMaxSpeed.in(MetersPerSecond) - * ExponentialConvert(getSimLeftInput(), exponentVelocity)); - double robotY = robotYSlewFilter.calculate( - Constants.Driving.kMaxSpeed.in(MetersPerSecond) - * ExponentialConvert(getSimForwardInput(), exponentVelocity)); - double robotRotate = robotRotateSlewFilter.calculate( - Constants.Driving.kMaxRotationalRate.in(RadiansPerSecond) - * ExponentialConvert(getSimRotationInput(), exponentRotation)); - return robotCentricDrive.withVelocityX(robotX).withVelocityY(robotY).withRotationalRate(robotRotate); - } - })); + configureManualDriveBindings(); + // Mirror driver-facing bindings on the sim joystick so the same features exist in sim. simButton(Constants.SimControllerButtons.kAutoAim) .or(driverRightStickButton()) @@ -447,9 +415,9 @@ private void configureSimBindings() { simButton(Constants.SimControllerButtons.kHangerUp) .or(driverPovLeft()) .onTrue(hanger.positionCommand(Hanger.Position.HANGER_EXTEND)); - simButton(Constants.SimControllerButtons.kHangerDown) - .or(driverPovRight()) - .onTrue(hanger.positionCommand(Hanger.Position.HANGER_HOME)); + // simButton(Constants.SimControllerButtons.kHangerDown) + // .or(driverPovRight()) + // .onTrue(hanger.positionCommand(Hanger.Position.HANGER_HOME)); simButton(Constants.SimControllerButtons.kHoodForward) .or(driver.y()) .onTrue(hood.positionCommand(0.75)); @@ -561,6 +529,13 @@ private void configureManualDriveBindings() { ); swerve.setDefaultCommand(manualDriveCommand); driver.back().onTrue(Commands.runOnce(() -> manualDriveCommand.seedFieldCentric())); + + Command brakeCommand = swerve.applyRequest(() -> new SwerveRequest.SwerveDriveBrake()) + .beforeStarting(() -> braking = true) + .finallyDo((interrupted) -> braking = false); + + driver.povRight().toggleOnTrue(brakeCommand); + } public static double ExponentialConvert(double controllerValue, double exponent) { @@ -583,6 +558,10 @@ public void logSwerveStickyFaults() { swerve.logStickyFaults(); } + public boolean getBraking() { + return braking; + } + public void autonomousInit() { Logger.recordOutput("Auto/CurrentAuto", autoChooser.getSelected().getName()); } diff --git a/src/main/java/frc/robot/commands/ManualDriveCommand.java b/src/main/java/frc/robot/commands/ManualDriveCommand.java index 749ef34..1bdc40f 100644 --- a/src/main/java/frc/robot/commands/ManualDriveCommand.java +++ b/src/main/java/frc/robot/commands/ManualDriveCommand.java @@ -148,15 +148,17 @@ public void execute() { previousInput = input; return; } + + currentState = State.IDLING; if (input.hasRotation()) { - currentState = State.DRIVING_WITH_MANUAL_ROTATION; + currentState = State.DRIVING_WITH_MANUAL_ROTATION; } else if (input.hasTranslation()) { currentState = lockedHeading.isPresent() ? State.DRIVING_WITH_LOCKED_HEADING : State.DRIVING_WITH_MANUAL_ROTATION; } else if (previousInput.hasRotation() || previousInput.hasTranslation()) { currentState = State.IDLING; } + previousInput = input; - switch (currentState) { case IDLING: swerve.setControl(idleRequest);