Skip to content

Commit

Permalink
brake for climbing after disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanknj5 committed Aug 30, 2024
1 parent f58e60a commit 369a2b6
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/main/java/frc/robot/arm/ArmSubsystem.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package frc.robot.arm;

import com.ctre.phoenix6.controls.PositionVoltage;
import com.ctre.phoenix6.controls.StaticBrake;
import com.ctre.phoenix6.hardware.TalonFX;
import dev.doglog.DogLog;
import edu.wpi.first.math.MathUtil;
Expand All @@ -23,8 +24,12 @@ public class ArmSubsystem extends StateMachine<ArmState> {
private InterpolatingDoubleTreeMap speakerDistanceToAngle = new InterpolatingDoubleTreeMap();
private InterpolatingDoubleTreeMap feedSpotDistanceToAngle = new InterpolatingDoubleTreeMap();
private final PositionVoltage positionRequest =
new PositionVoltage(0).withEnableFOC(false).withLimitReverseMotion(false);

new PositionVoltage(0).withEnableFOC(false).withLimitReverseMotion(false).withOverrideBrakeDurNeutral(true);
// private final StaticBrake staticBrake =
// new StaticBrake();
//IF withOverrideBrakeDurNeutral DOEST WORK


public void setDistanceToSpeaker(double distance) {
distanceToSpeaker = distance;
}
Expand All @@ -49,8 +54,13 @@ public void setState(ArmState newState) {
setStateFromRequest(newState);
}
}

public boolean atGoal() {
// public void disabledPeriodic()
// {
// rightMotor.setControl(staticBrake);
// rightMotor.setControl(staticBrake);
// }
//IF withOverrideBrakeDurNeutral DOESNT WORK
public boolean atGoal() {
return switch (getState()) {
case IDLE, PRE_MATCH_HOMING -> true;
case SPEAKER_SHOT ->
Expand All @@ -75,6 +85,7 @@ public boolean atGoal() {
case CLIMBING_2_HANGING ->
MathUtil.isNear(ArmAngle.CLIMBING_2_HANGING.getDegrees(), leftMotorAngle, 1)
&& MathUtil.isNear(ArmAngle.CLIMBING_2_HANGING.getDegrees(), rightMotorAngle, 1);

case AMP ->
MathUtil.isNear(ArmAngle.AMP.getDegrees(), leftMotorAngle, 1)
&& MathUtil.isNear(ArmAngle.AMP.getDegrees(), rightMotorAngle, 1);
Expand Down Expand Up @@ -111,6 +122,7 @@ protected void afterTransition(ArmState newState) {
rightMotor.setControl(
positionRequest.withPosition(ArmAngle.CLIMBING_2_HANGING.getRotations()));
}

case DROP -> {
leftMotor.setControl(positionRequest.withPosition(ArmAngle.DROP.getRotations()));
rightMotor.setControl(positionRequest.withPosition(ArmAngle.DROP.getRotations()));
Expand Down Expand Up @@ -142,7 +154,7 @@ protected void afterTransition(ArmState newState) {
}
}
}

@Override
public void robotPeriodic() {
super.robotPeriodic();
Expand Down Expand Up @@ -187,4 +199,5 @@ private static double clampAngle(double angle) {
}
return angle;
}

}

0 comments on commit 369a2b6

Please sign in to comment.