Skip to content

Commit 095628a

Browse files
committed
feat: use tryUntilOk util in elevatorIOReal
Signed-off-by: Dasun Abeykoon <[email protected]>
1 parent 7499881 commit 095628a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import static edu.wpi.first.units.Units.Meters;
1010
import static edu.wpi.first.units.Units.MetersPerSecond;
1111
import static edu.wpi.first.units.Units.MetersPerSecondPerSecond;
12+
import static org.frc6423.lib.utilities.CtreUtils.*;
1213
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.CANBUS;
1314
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.CHILD_MOTOR_ID;
1415
import static org.frc6423.robot.subsystems.superstructure.elevator.Elevator.MAX_ACCELERATION;
@@ -70,8 +71,8 @@ public ElevatorIOReal() {
7071
conf.MotionMagic.MotionMagicCruiseVelocity = MAX_VELOCITY.in(MetersPerSecond);
7172
conf.MotionMagic.MotionMagicAcceleration = MAX_ACCELERATION.in(MetersPerSecondPerSecond);
7273

73-
parent.getConfigurator().apply(conf);
74-
child.getConfigurator().apply(conf);
74+
tryUntilOk(() -> parent.getConfigurator().apply(conf), 10, PARENT_MOTOR_ID);
75+
tryUntilOk(() -> child.getConfigurator().apply(conf), 10, CHILD_MOTOR_ID);
7576
child.setControl(new Follower(parent.getDeviceID(), true));
7677

7778
parentPoseSig = parent.getPosition();
@@ -143,8 +144,9 @@ public void setGains(double kG, double kS, double kV, double kA, double kP, doub
143144
conf.Slot0.kP = kP;
144145
conf.Slot0.kD = kD;
145146

146-
parent.getConfigurator().apply(conf);
147-
child.getConfigurator().apply(conf);
147+
// I think the configurator will only apply if the config is different so this should be fine
148+
tryUntilOk(() -> parent.getConfigurator().apply(conf), 10, PARENT_MOTOR_ID);
149+
tryUntilOk(() -> child.getConfigurator().apply(conf), 10, CHILD_MOTOR_ID);
148150
}
149151

150152
@Override

0 commit comments

Comments
 (0)