Skip to content

Commit e2bd3eb

Browse files
committed
fix: add soft limit switch for max extension height in ElevatorIOReal
Signed-off-by: Dasun Abeykoon <[email protected]>
1 parent 8a69d0e commit e2bd3eb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main/java/org/frc6423/robot/subsystems/superstructure/elevator/ElevatorIOReal.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66

77
package org.frc6423.robot.subsystems.superstructure.elevator;
88

9+
import static edu.wpi.first.units.Units.Meters;
910
import static edu.wpi.first.units.Units.MetersPerSecond;
1011
import static edu.wpi.first.units.Units.MetersPerSecondPerSecond;
1112
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.CANBUS;
1213
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.CHILD_MOTOR_ID;
1314
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.MAX_ACCELERATION;
15+
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.MAX_EXTENSION_HEIGHT;
1416
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.MAX_VELOCITY;
1517
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.PARENT_MOTOR_ID;
1618
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.SENSOR_TO_MECH_RATIO;
@@ -49,10 +51,13 @@ public ElevatorIOReal() {
4951
conf.MotorOutput.NeutralMode = NeutralModeValue.Brake;
5052
conf.MotorOutput.Inverted = InvertedValue.CounterClockwise_Positive;
5153

52-
conf.CurrentLimits.StatorCurrentLimit = 80.0;
54+
conf.HardwareLimitSwitch.ForwardLimitAutosetPositionEnable = true;
55+
conf.HardwareLimitSwitch.ForwardLimitAutosetPositionValue = MAX_EXTENSION_HEIGHT.in(Meters);
56+
5357
conf.CurrentLimits.StatorCurrentLimitEnable = true;
54-
conf.CurrentLimits.SupplyCurrentLimit = 40.0;
58+
conf.CurrentLimits.StatorCurrentLimit = 80.0;
5559
conf.CurrentLimits.SupplyCurrentLimitEnable = true;
60+
conf.CurrentLimits.SupplyCurrentLimit = 40.0;
5661

5762
conf.Feedback.SensorToMechanismRatio = SENSOR_TO_MECH_RATIO;
5863
conf.ClosedLoopRamps.TorqueClosedLoopRampPeriod = 0.1;

0 commit comments

Comments
 (0)