Skip to content

Commit 9670046

Browse files
committed
fix: clamped to current limits as well
1 parent 8d43862 commit 9670046

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/main/java/frc/robot/commands/ElevatorCommand.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,16 @@ else if (lowerLimit != null && m_desiredHeight < currentLimit.getKey()) { // goi
6363
pivotLimits = currentLimit.getValue();
6464
}
6565

66-
final double pivotPosition = MathUtil.clamp(m_endEffectorSubsystem.getSetpoint(), pivotLimits.getFirst(),
66+
67+
// first clamp using setpoint limit
68+
final double pivotPositionSetpointClamped = MathUtil.clamp(m_endEffectorSubsystem.getSetpoint(), pivotLimits.getFirst(),
6769
pivotLimits.getSecond());
68-
m_endEffectorSubsystem.pivotTo(pivotPosition);
70+
71+
// then clamp with current limit
72+
final double pivotPositionClamped = MathUtil.clamp(pivotPositionSetpointClamped, currentLimit.getValue().getFirst(),
73+
currentLimit.getValue().getSecond());
74+
75+
m_endEffectorSubsystem.pivotTo(pivotPositionClamped);
6976
}
7077

7178
// Called once the command ends or is interrupted.

0 commit comments

Comments
 (0)