Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions simgui-ds.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"Keyboard 0 Settings": {
"window": {
"visible": true
}
},
"keyboardJoysticks": [
{
"axisConfig": [
Expand Down Expand Up @@ -42,7 +47,7 @@
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
"key90": 54
}
],
"povCount": 1
Expand Down Expand Up @@ -83,7 +88,7 @@
51,
52,
53,
54
-1
],
"povCount": 0
},
Expand All @@ -94,11 +99,6 @@
}
],
"robotJoysticks": [
{
"guid": "78696e70757401000000000000000000",
"useGamepad": true
},
{},
{
"guid": "Keyboard0"
}
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
55 changes: 17 additions & 38 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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) {
Expand All @@ -583,6 +558,10 @@ public void logSwerveStickyFaults() {
swerve.logStickyFaults();
}

public boolean getBraking() {
return braking;
}

public void autonomousInit() {
Logger.recordOutput("Auto/CurrentAuto", autoChooser.getSelected().getName());
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/frc/robot/commands/ManualDriveCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading