Skip to content

Commit

Permalink
add deadzone for arm defaultcommand
Browse files Browse the repository at this point in the history
to fix issue #24
  • Loading branch information
FriedLongJohns committed Mar 6, 2024
1 parent 571b732 commit 91e7922
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main/java/org/carlmontrobotics/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ private void setDefaultCommands() {
// () -> driverController.getRawButton(OI.Driver.slowDriveButton)
// ));

arm.setDefaultCommand(new ArmTeleop(arm, () -> inputProcessing(getStickValue(manipulatorController, Axis.kLeftY))));
arm.setDefaultCommand(new ArmTeleop(arm,
() -> DeadzonedAxis(inputProcessing(getStickValue(manipulatorController, Axis.kLeftY)))));
}

private void setBindingsDriver() {
Expand Down Expand Up @@ -158,4 +159,17 @@ private double inputProcessing(double value) {
private double ProcessedAxisValue(GenericHID hid, Axis axis) {
return inputProcessing(getStickValue(hid, axis));
}

/**
* Returns zero if a axis input is inside the deadzone
*
* @param hid The controller/plane joystick the axis is on
* @param axis The processed axis
* @return The processed value.
*/
private double DeadzonedAxis(double axOut) {
return (-OI.JOY_THRESH < axOut && axOut < OI.JOY_THRESH) ? 0.0 : axOut;
}


}

0 comments on commit 91e7922

Please sign in to comment.