From 8a2a906205e18753d2a7ee4a608c03d61df84fd4 Mon Sep 17 00:00:00 2001 From: Debajit Ghosh Date: Fri, 23 Feb 2024 05:14:59 -0800 Subject: [PATCH 1/8] create PID helper class for running PID loops in a Mechanism's run() method. update RevA's Shoulder to use this, as an example. --- .../com/team766/controllers/PIDRunner.java | 96 +++++++++++++++++++ .../robot/reva/mechanisms/Shoulder.java | 36 ++++--- 2 files changed, 117 insertions(+), 15 deletions(-) create mode 100644 src/main/java/com/team766/controllers/PIDRunner.java diff --git a/src/main/java/com/team766/controllers/PIDRunner.java b/src/main/java/com/team766/controllers/PIDRunner.java new file mode 100644 index 000000000..3e6285209 --- /dev/null +++ b/src/main/java/com/team766/controllers/PIDRunner.java @@ -0,0 +1,96 @@ +package com.team766.controllers; + +import com.team766.framework.Mechanism; +import com.team766.hal.MotorController; +import com.team766.library.ValueProvider; +import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; +import java.util.function.Supplier; + +/** + * Helper class that can set a setpoint in a PID loop, eg within {@link Mechanism.run}. + * + * Uses functional interfaces for getting the setpoint, output, PID slot, and feedforward. + * Can use with lambdas and/or method references, eg: + * + * PIDRunner pidRunner = new PIDRunner("SHOULDER", leftMotor, ControlMode.Position, + * this::getSetPoint, this::getAngle); + */ +public class PIDRunner { + + public static Supplier DEFAULT_SLOT_PICKER = () -> 1; + public static Supplier NO_FEED_FORWARD = () -> 0.0; + + /** + * Returns a fixed FeedForward supplier, simply returning the latest input ffGain from a config file. + * @param ffGain Input FeedForward Gain, read from a config file. + * @return Fixed FeedForward Gain from the current value of ffGain. + */ + public static Supplier fixedFeedForward(ValueProvider ffGain) { + return () -> ffGain.get(); + } + + /** + * Returns a FeedForward supplier that gets the latest input ffGain from a config file and returns a proportional + * FeedForward based on the cosine of the supplied angle. Useful for arm type mechanisms, where we want to + * counteract gravity proportionally to the arm's current angle, where 0 is parallel to the ground and 90 + * is perpendicular & up. + * + * @param ffGain Input FeedForward Gain, read from a config file. + * @param angle Current angle of the mechanism. 0 is parallel to the ground, 90 is perpendicular & up. + * @return Proportional FeedForward Gain based on the angle. + */ + public static Supplier cosineFeedForward( + ValueProvider ffGain, Supplier angle) { + return () -> ffGain.valueOr(0.0) * Math.cos(Math.toRadians(angle.get())); + } + + private final String label; + private final MotorController motor; + private final MotorController.ControlMode mode; + private final Supplier setPoint; + private final Supplier output; + private final Supplier slot; + private final Supplier feedForward; + private double prevSetPoint = 0.0; + private double prevOutput = 0.0; + + public PIDRunner( + String label, + MotorController motor, + MotorController.ControlMode mode, + Supplier setPoint, + Supplier output) { + this(label, motor, mode, setPoint, output, DEFAULT_SLOT_PICKER, NO_FEED_FORWARD); + } + + public PIDRunner( + String label, + MotorController motor, + MotorController.ControlMode mode, + Supplier setPoint, + Supplier output, + Supplier slot, + Supplier feedForward) { + this.label = label; + this.motor = motor; + this.mode = mode; + this.setPoint = setPoint; + this.output = output; + this.slot = slot; + this.feedForward = feedForward; + } + + public void run() { + double currentSetPoint = setPoint.get(); + double currentOutput = output.get(); + if (prevSetPoint != currentOutput || prevOutput != currentOutput) { + prevSetPoint = currentSetPoint; + prevOutput = currentOutput; + SmartDashboard.putNumber(label + " setpoint", currentSetPoint); + SmartDashboard.putNumber(label + " output", currentOutput); + // FIXME: switch to supporting slot, feedForward once integrated + // motor.set(mode, currentSetPoint, slot.get(), feedForward.get()); + motor.set(mode, currentSetPoint); + } + } +} diff --git a/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java b/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java index f5941e036..14a0ecb82 100644 --- a/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java +++ b/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java @@ -4,9 +4,8 @@ import static com.team766.robot.reva.constants.ConfigConstants.SHOULDER_RIGHT; import com.ctre.phoenix.motorcontrol.NeutralMode; -import com.ctre.phoenix6.controls.PositionDutyCycle; -import com.ctre.phoenix6.hardware.TalonFX; import com.team766.config.ConfigFileReader; +import com.team766.controllers.PIDRunner; import com.team766.framework.Mechanism; import com.team766.hal.MotorController; import com.team766.hal.RobotProvider; @@ -36,8 +35,9 @@ public double getAngle() { private static final double NUDGE_AMOUNT = 30; // degrees - private MotorController leftMotor; - private MotorController rightMotor; + private final MotorController leftMotor; + private final MotorController rightMotor; + private final PIDRunner pidRunner; private ValueProvider ffGain; private double targetRotations = 0.0; @@ -50,6 +50,16 @@ public Shoulder() { leftMotor.setNeutralMode(NeutralMode.Brake); ffGain = ConfigFileReader.getInstance().getDouble("shoulder.leftMotor.ffGain"); leftMotor.setSensorPosition(0); + + pidRunner = + new PIDRunner( + "SHOULDER", + leftMotor, + MotorController.ControlMode.Position, + this::getTargetRotations, + this::getAngle, + PIDRunner.DEFAULT_SLOT_PICKER, + PIDRunner.cosineFeedForward(ffGain, this::getAngle)); } public void stop() { @@ -73,6 +83,10 @@ public double getRotations() { return leftMotor.getSensorPosition(); } + public double getTargetRotations() { + return targetRotations; + } + public double getAngle() { return rotationsToDegrees(leftMotor.getSensorPosition()); } @@ -103,17 +117,9 @@ public void rotate(double angle) { @Override public void run() { - SmartDashboard.putNumber("[SHOULDER] Angle", getAngle()); - SmartDashboard.putNumber("[SHOULDER] Rotations", getRotations()); - SmartDashboard.putNumber("[SHOULDER] Target Rotations", targetRotations); - - TalonFX leftTalon = (TalonFX) leftMotor; - SmartDashboard.putNumber("[SHOULDER] ffGain", ffGain.get()); - double ff = ffGain.valueOr(0.0) * Math.cos(Math.toRadians(getAngle())); - SmartDashboard.putNumber("[SHOULDER] FF", ff); + pidRunner.run(); + // also log velocity, for PID tuning + // TODO: consider moving this into PIDRunner SmartDashboard.putNumber("[SHOULDER VELOCITY]", Math.abs(leftMotor.getSensorVelocity())); - PositionDutyCycle positionRequest = new PositionDutyCycle(targetRotations); - positionRequest.FeedForward = ff; - leftTalon.setControl(positionRequest); } } From 628f69e0efe0b12f79ec892233e51750001ba058 Mon Sep 17 00:00:00 2001 From: Debajit Ghosh Date: Fri, 23 Feb 2024 05:27:49 -0800 Subject: [PATCH 2/8] change logic for when we set the setpoint --- .../com/team766/controllers/PIDRunner.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/team766/controllers/PIDRunner.java b/src/main/java/com/team766/controllers/PIDRunner.java index 3e6285209..4080c2f39 100644 --- a/src/main/java/com/team766/controllers/PIDRunner.java +++ b/src/main/java/com/team766/controllers/PIDRunner.java @@ -51,8 +51,10 @@ public static Supplier cosineFeedForward( private final Supplier output; private final Supplier slot; private final Supplier feedForward; + private boolean first = true; private double prevSetPoint = 0.0; - private double prevOutput = 0.0; + private double prevFeedForward = 0.0; + private int prevSlot = 0; public PIDRunner( String label, @@ -83,12 +85,26 @@ public PIDRunner( public void run() { double currentSetPoint = setPoint.get(); double currentOutput = output.get(); - if (prevSetPoint != currentOutput || prevOutput != currentOutput) { + double currentFeedForward = feedForward.get(); + int currentSlot = slot.get(); + + // if we haven't set the setpoint yet, or if the setpoint, feedforward, or slot have + // changed, set the setpoint. + if (first + || prevSetPoint != currentSetPoint + || prevFeedForward != currentFeedForward + || currentSlot != prevSlot) { + first = false; prevSetPoint = currentSetPoint; - prevOutput = currentOutput; + prevFeedForward = currentFeedForward; + prevSlot = currentSlot; + + // log to SmartDashboard - useful for PID tuning. SmartDashboard.putNumber(label + " setpoint", currentSetPoint); SmartDashboard.putNumber(label + " output", currentOutput); - // FIXME: switch to supporting slot, feedForward once integrated + SmartDashboard.putNumber(label + " PID slot", currentSlot); + + // FIXME: switch to supporting slot, feedForward once that PR is integrated // motor.set(mode, currentSetPoint, slot.get(), feedForward.get()); motor.set(mode, currentSetPoint); } From 10c24a44593798f48d60367a6479fb1a52b39d64 Mon Sep 17 00:00:00 2001 From: Debajit Ghosh Date: Fri, 23 Feb 2024 05:35:13 -0800 Subject: [PATCH 3/8] move shoulder's ffGain config string to ConfigConstants --- .../java/com/team766/robot/reva/constants/ConfigConstants.java | 2 ++ src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/team766/robot/reva/constants/ConfigConstants.java b/src/main/java/com/team766/robot/reva/constants/ConfigConstants.java index c16c1a949..b2f247ba1 100644 --- a/src/main/java/com/team766/robot/reva/constants/ConfigConstants.java +++ b/src/main/java/com/team766/robot/reva/constants/ConfigConstants.java @@ -10,6 +10,8 @@ private ConfigConstants() {} public static final String SHOULDER_RIGHT = "shoulder.rightMotor"; public static final String SHOULDER_LEFT = "shoulder.leftMotor"; + // TODO: change this to shoulder.ffGain + public static final String SHOULDER_FFGAIN = "shoulder.leftMotor.ffGain"; // intake config values public static final String INTAKE_MOTOR = "intake.motor"; diff --git a/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java b/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java index 14a0ecb82..b94917b91 100644 --- a/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java +++ b/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java @@ -1,5 +1,6 @@ package com.team766.robot.reva.mechanisms; +import static com.team766.robot.reva.constants.ConfigConstants.SHOULDER_FFGAIN; import static com.team766.robot.reva.constants.ConfigConstants.SHOULDER_LEFT; import static com.team766.robot.reva.constants.ConfigConstants.SHOULDER_RIGHT; @@ -48,7 +49,7 @@ public Shoulder() { rightMotor = RobotProvider.instance.getMotor(SHOULDER_RIGHT); rightMotor.follow(leftMotor); leftMotor.setNeutralMode(NeutralMode.Brake); - ffGain = ConfigFileReader.getInstance().getDouble("shoulder.leftMotor.ffGain"); + ffGain = ConfigFileReader.getInstance().getDouble(SHOULDER_FFGAIN); leftMotor.setSensorPosition(0); pidRunner = From b645d961411e2f12ae77c4daf291841b7d5ec905 Mon Sep 17 00:00:00 2001 From: Debajit Ghosh Date: Fri, 23 Feb 2024 06:02:15 -0800 Subject: [PATCH 4/8] setpoint and output should be rotations --- src/main/java/com/team766/controllers/PIDRunner.java | 2 +- src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/team766/controllers/PIDRunner.java b/src/main/java/com/team766/controllers/PIDRunner.java index 4080c2f39..2514014d0 100644 --- a/src/main/java/com/team766/controllers/PIDRunner.java +++ b/src/main/java/com/team766/controllers/PIDRunner.java @@ -13,7 +13,7 @@ * Can use with lambdas and/or method references, eg: * * PIDRunner pidRunner = new PIDRunner("SHOULDER", leftMotor, ControlMode.Position, - * this::getSetPoint, this::getAngle); + * this::getTargetRotations, this::getRotations); */ public class PIDRunner { diff --git a/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java b/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java index b94917b91..3307403a1 100644 --- a/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java +++ b/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java @@ -60,7 +60,7 @@ public Shoulder() { this::getTargetRotations, this::getAngle, PIDRunner.DEFAULT_SLOT_PICKER, - PIDRunner.cosineFeedForward(ffGain, this::getAngle)); + PIDRunner.cosineFeedForward(ffGain, this::getRotations)); } public void stop() { From 987f1e9a44c7b75b5748ce9f365765b4bd2d2f30 Mon Sep 17 00:00:00 2001 From: Debajit Ghosh Date: Fri, 23 Feb 2024 11:16:54 -0800 Subject: [PATCH 5/8] fix a few typos --- src/main/java/com/team766/controllers/PIDRunner.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/team766/controllers/PIDRunner.java b/src/main/java/com/team766/controllers/PIDRunner.java index 2514014d0..a6b7e790c 100644 --- a/src/main/java/com/team766/controllers/PIDRunner.java +++ b/src/main/java/com/team766/controllers/PIDRunner.java @@ -17,15 +17,15 @@ */ public class PIDRunner { - public static Supplier DEFAULT_SLOT_PICKER = () -> 1; - public static Supplier NO_FEED_FORWARD = () -> 0.0; + public static final Supplier DEFAULT_SLOT_PICKER = () -> 0; + public static final Supplier NO_FEED_FORWARD = () -> 0.0; /** * Returns a fixed FeedForward supplier, simply returning the latest input ffGain from a config file. * @param ffGain Input FeedForward Gain, read from a config file. * @return Fixed FeedForward Gain from the current value of ffGain. */ - public static Supplier fixedFeedForward(ValueProvider ffGain) { + public static final Supplier fixedFeedForward(ValueProvider ffGain) { return () -> ffGain.get(); } @@ -39,7 +39,7 @@ public static Supplier fixedFeedForward(ValueProvider ffGain) { * @param angle Current angle of the mechanism. 0 is parallel to the ground, 90 is perpendicular & up. * @return Proportional FeedForward Gain based on the angle. */ - public static Supplier cosineFeedForward( + public static final Supplier cosineFeedForward( ValueProvider ffGain, Supplier angle) { return () -> ffGain.valueOr(0.0) * Math.cos(Math.toRadians(angle.get())); } From a7959574911c2774e229428fdab40387cd4c7e64 Mon Sep 17 00:00:00 2001 From: Debajit Ghosh Date: Fri, 23 Feb 2024 11:44:25 -0800 Subject: [PATCH 6/8] renamed feedForward to arbitraryFeedForward --- .../com/team766/controllers/PIDRunner.java | 36 +++++++++---------- .../robot/reva/constants/ConfigConstants.java | 4 +-- .../robot/reva/mechanisms/Shoulder.java | 11 +++--- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/main/java/com/team766/controllers/PIDRunner.java b/src/main/java/com/team766/controllers/PIDRunner.java index a6b7e790c..cd22b688f 100644 --- a/src/main/java/com/team766/controllers/PIDRunner.java +++ b/src/main/java/com/team766/controllers/PIDRunner.java @@ -18,15 +18,15 @@ public class PIDRunner { public static final Supplier DEFAULT_SLOT_PICKER = () -> 0; - public static final Supplier NO_FEED_FORWARD = () -> 0.0; + public static final Supplier NO_ARBITRARY_FEED_FORWARD = () -> 0.0; /** - * Returns a fixed FeedForward supplier, simply returning the latest input ffGain from a config file. - * @param ffGain Input FeedForward Gain, read from a config file. + * Returns a fixed arbitrary FeedForward supplier, simply returning the latest input ffGain from a config file. + * @param arbitraryFFGain Input FeedForward Gain, read from a config file. * @return Fixed FeedForward Gain from the current value of ffGain. */ - public static final Supplier fixedFeedForward(ValueProvider ffGain) { - return () -> ffGain.get(); + public static final Supplier fixedArbitraryFeedForward(ValueProvider arbitraryFFGain) { + return () -> arbitraryFFGain.get(); } /** @@ -35,13 +35,13 @@ public static final Supplier fixedFeedForward(ValueProvider ffGa * counteract gravity proportionally to the arm's current angle, where 0 is parallel to the ground and 90 * is perpendicular & up. * - * @param ffGain Input FeedForward Gain, read from a config file. + * @param arbitraryFFGain Input FeedForward Gain, read from a config file. * @param angle Current angle of the mechanism. 0 is parallel to the ground, 90 is perpendicular & up. * @return Proportional FeedForward Gain based on the angle. */ - public static final Supplier cosineFeedForward( - ValueProvider ffGain, Supplier angle) { - return () -> ffGain.valueOr(0.0) * Math.cos(Math.toRadians(angle.get())); + public static final Supplier cosineArbitraryFeedForward( + ValueProvider arbitraryFFGain, Supplier angle) { + return () -> arbitraryFFGain.valueOr(0.0) * Math.cos(Math.toRadians(angle.get())); } private final String label; @@ -50,10 +50,10 @@ public static final Supplier cosineFeedForward( private final Supplier setPoint; private final Supplier output; private final Supplier slot; - private final Supplier feedForward; + private final Supplier arbitraryFeedForward; private boolean first = true; private double prevSetPoint = 0.0; - private double prevFeedForward = 0.0; + private double prevArbitraryFeedForward = 0.0; private int prevSlot = 0; public PIDRunner( @@ -62,7 +62,7 @@ public PIDRunner( MotorController.ControlMode mode, Supplier setPoint, Supplier output) { - this(label, motor, mode, setPoint, output, DEFAULT_SLOT_PICKER, NO_FEED_FORWARD); + this(label, motor, mode, setPoint, output, DEFAULT_SLOT_PICKER, NO_ARBITRARY_FEED_FORWARD); } public PIDRunner( @@ -72,31 +72,31 @@ public PIDRunner( Supplier setPoint, Supplier output, Supplier slot, - Supplier feedForward) { + Supplier arbitraryFeedForward) { this.label = label; this.motor = motor; this.mode = mode; this.setPoint = setPoint; this.output = output; this.slot = slot; - this.feedForward = feedForward; + this.arbitraryFeedForward = arbitraryFeedForward; } public void run() { double currentSetPoint = setPoint.get(); double currentOutput = output.get(); - double currentFeedForward = feedForward.get(); + double currentArbitraryFeedForward = arbitraryFeedForward.get(); int currentSlot = slot.get(); // if we haven't set the setpoint yet, or if the setpoint, feedforward, or slot have // changed, set the setpoint. if (first || prevSetPoint != currentSetPoint - || prevFeedForward != currentFeedForward + || prevArbitraryFeedForward != currentArbitraryFeedForward || currentSlot != prevSlot) { first = false; prevSetPoint = currentSetPoint; - prevFeedForward = currentFeedForward; + prevArbitraryFeedForward = currentArbitraryFeedForward; prevSlot = currentSlot; // log to SmartDashboard - useful for PID tuning. @@ -105,7 +105,7 @@ public void run() { SmartDashboard.putNumber(label + " PID slot", currentSlot); // FIXME: switch to supporting slot, feedForward once that PR is integrated - // motor.set(mode, currentSetPoint, slot.get(), feedForward.get()); + // motor.set(mode, currentSetPoint, slot.get(), arbitraryFeedForward.get()); motor.set(mode, currentSetPoint); } } diff --git a/src/main/java/com/team766/robot/reva/constants/ConfigConstants.java b/src/main/java/com/team766/robot/reva/constants/ConfigConstants.java index b2f247ba1..b8c1bf419 100644 --- a/src/main/java/com/team766/robot/reva/constants/ConfigConstants.java +++ b/src/main/java/com/team766/robot/reva/constants/ConfigConstants.java @@ -10,8 +10,8 @@ private ConfigConstants() {} public static final String SHOULDER_RIGHT = "shoulder.rightMotor"; public static final String SHOULDER_LEFT = "shoulder.leftMotor"; - // TODO: change this to shoulder.ffGain - public static final String SHOULDER_FFGAIN = "shoulder.leftMotor.ffGain"; + // TODO: change this to shoulder.arbitraryFFGain + public static final String SHOULDER_ARBITRARY_FFGAIN = "shoulder.leftMotor.ffGain"; // intake config values public static final String INTAKE_MOTOR = "intake.motor"; diff --git a/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java b/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java index 3307403a1..8721e1496 100644 --- a/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java +++ b/src/main/java/com/team766/robot/reva/mechanisms/Shoulder.java @@ -1,6 +1,6 @@ package com.team766.robot.reva.mechanisms; -import static com.team766.robot.reva.constants.ConfigConstants.SHOULDER_FFGAIN; +import static com.team766.robot.reva.constants.ConfigConstants.SHOULDER_ARBITRARY_FFGAIN; import static com.team766.robot.reva.constants.ConfigConstants.SHOULDER_LEFT; import static com.team766.robot.reva.constants.ConfigConstants.SHOULDER_RIGHT; @@ -40,7 +40,7 @@ public double getAngle() { private final MotorController rightMotor; private final PIDRunner pidRunner; - private ValueProvider ffGain; + private ValueProvider arbitraryFFGain; private double targetRotations = 0.0; public Shoulder() { @@ -49,7 +49,7 @@ public Shoulder() { rightMotor = RobotProvider.instance.getMotor(SHOULDER_RIGHT); rightMotor.follow(leftMotor); leftMotor.setNeutralMode(NeutralMode.Brake); - ffGain = ConfigFileReader.getInstance().getDouble(SHOULDER_FFGAIN); + arbitraryFFGain = ConfigFileReader.getInstance().getDouble(SHOULDER_ARBITRARY_FFGAIN); leftMotor.setSensorPosition(0); pidRunner = @@ -58,9 +58,9 @@ public Shoulder() { leftMotor, MotorController.ControlMode.Position, this::getTargetRotations, - this::getAngle, + this::getRotations, PIDRunner.DEFAULT_SLOT_PICKER, - PIDRunner.cosineFeedForward(ffGain, this::getRotations)); + PIDRunner.cosineArbitraryFeedForward(arbitraryFFGain, this::getAngle)); } public void stop() { @@ -122,5 +122,6 @@ public void run() { // also log velocity, for PID tuning // TODO: consider moving this into PIDRunner SmartDashboard.putNumber("[SHOULDER VELOCITY]", Math.abs(leftMotor.getSensorVelocity())); + SmartDashboard.putNumber("[SHOULDER ANGLE]", getAngle()); } } From e46823d29b315b05d7f775fc0060bc3b8bc226cd Mon Sep 17 00:00:00 2001 From: Debajit Ghosh Date: Sat, 24 Feb 2024 11:08:53 -0800 Subject: [PATCH 7/8] linting --- src/main/java/com/team766/controllers/PIDRunner.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/team766/controllers/PIDRunner.java b/src/main/java/com/team766/controllers/PIDRunner.java index cd22b688f..106311545 100644 --- a/src/main/java/com/team766/controllers/PIDRunner.java +++ b/src/main/java/com/team766/controllers/PIDRunner.java @@ -25,7 +25,8 @@ public class PIDRunner { * @param arbitraryFFGain Input FeedForward Gain, read from a config file. * @return Fixed FeedForward Gain from the current value of ffGain. */ - public static final Supplier fixedArbitraryFeedForward(ValueProvider arbitraryFFGain) { + public static final Supplier fixedArbitraryFeedForward( + ValueProvider arbitraryFFGain) { return () -> arbitraryFFGain.get(); } From 07b509f4ca68e5f991624baf1667e07c8e9989af Mon Sep 17 00:00:00 2001 From: Debajit Ghosh Date: Mon, 4 Mar 2024 17:37:25 -0800 Subject: [PATCH 8/8] addressing PR comment --- src/main/java/com/team766/controllers/PIDRunner.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/team766/controllers/PIDRunner.java b/src/main/java/com/team766/controllers/PIDRunner.java index 106311545..74efff25c 100644 --- a/src/main/java/com/team766/controllers/PIDRunner.java +++ b/src/main/java/com/team766/controllers/PIDRunner.java @@ -27,7 +27,7 @@ public class PIDRunner { */ public static final Supplier fixedArbitraryFeedForward( ValueProvider arbitraryFFGain) { - return () -> arbitraryFFGain.get(); + return () -> arbitraryFFGain.valueOr(0.0); } /**