diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/MecanumControllerCommand.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/MecanumControllerCommand.java index 70978c63f1..440018817c 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/MecanumControllerCommand.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/MecanumControllerCommand.java @@ -368,19 +368,16 @@ public class MecanumControllerCommand extends Command { if (m_usePID) { final double frontLeftFeedforward = - m_feedforward.calculateWithVelocities( - m_prevFrontLeftSpeedSetpoint, frontLeftSpeedSetpoint); + m_feedforward.calculate(m_prevFrontLeftSpeedSetpoint, frontLeftSpeedSetpoint); final double rearLeftFeedforward = - m_feedforward.calculateWithVelocities(m_prevRearLeftSpeedSetpoint, rearLeftSpeedSetpoint); + m_feedforward.calculate(m_prevRearLeftSpeedSetpoint, rearLeftSpeedSetpoint); final double frontRightFeedforward = - m_feedforward.calculateWithVelocities( - m_prevFrontRightSpeedSetpoint, frontRightSpeedSetpoint); + m_feedforward.calculate(m_prevFrontRightSpeedSetpoint, frontRightSpeedSetpoint); final double rearRightFeedforward = - m_feedforward.calculateWithVelocities( - m_prevRearRightSpeedSetpoint, rearRightSpeedSetpoint); + m_feedforward.calculate(m_prevRearRightSpeedSetpoint, rearRightSpeedSetpoint); frontLeftOutput = frontLeftFeedforward diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/RamseteCommand.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/RamseteCommand.java index 88aae9cca1..23ec61c622 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/RamseteCommand.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/RamseteCommand.java @@ -181,11 +181,10 @@ public class RamseteCommand extends Command { double rightOutput; if (m_usePID) { - double leftFeedforward = - m_feedforward.calculateWithVelocities(m_prevLeftSpeedSetpoint, leftSpeedSetpoint); + double leftFeedforward = m_feedforward.calculate(m_prevLeftSpeedSetpoint, leftSpeedSetpoint); double rightFeedforward = - m_feedforward.calculateWithVelocities(m_prevRightSpeedSetpoint, rightSpeedSetpoint); + m_feedforward.calculate(m_prevRightSpeedSetpoint, rightSpeedSetpoint); leftOutput = leftFeedforward diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/drivedistanceoffboard/subsystems/DriveSubsystem.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/drivedistanceoffboard/subsystems/DriveSubsystem.java index b8947ce6da..3c3179dcc0 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/drivedistanceoffboard/subsystems/DriveSubsystem.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/drivedistanceoffboard/subsystems/DriveSubsystem.java @@ -96,12 +96,12 @@ public class DriveSubsystem extends SubsystemBase { m_leftLeader.setSetpoint( ExampleSmartMotorController.PIDMode.kPosition, currentLeft.position, - m_feedforward.calculateWithVelocities(currentLeft.velocity, nextLeft.velocity) + m_feedforward.calculate(currentLeft.velocity, nextLeft.velocity) / RobotController.getBatteryVoltage()); m_rightLeader.setSetpoint( ExampleSmartMotorController.PIDMode.kPosition, currentRight.position, - m_feedforward.calculateWithVelocities(currentLeft.velocity, nextLeft.velocity) + m_feedforward.calculate(currentLeft.velocity, nextLeft.velocity) / RobotController.getBatteryVoltage()); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/controller/SimpleMotorFeedforward.java b/wpimath/src/main/java/edu/wpi/first/math/controller/SimpleMotorFeedforward.java index b7603a6bfb..e9e6a3f22d 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/controller/SimpleMotorFeedforward.java +++ b/wpimath/src/main/java/edu/wpi/first/math/controller/SimpleMotorFeedforward.java @@ -123,20 +123,6 @@ public class SimpleMotorFeedforward implements ProtobufSerializable, StructSeria return m_dt; } - /** - * Calculates the feedforward from the gains and setpoints assuming continuous control. - * - * @param velocity The velocity setpoint. - * @param acceleration The acceleration setpoint. - * @return The computed feedforward. - * @deprecated Use {@link #calculateWithVelocities(double, double)} instead. - */ - @SuppressWarnings("removal") - @Deprecated(forRemoval = true, since = "2025") - public double calculate(double velocity, double acceleration) { - return ks * Math.signum(velocity) + kv * velocity + ka * acceleration; - } - /** * Calculates the feedforward from the gains and velocity setpoint assuming continuous control * (acceleration is assumed to be zero). @@ -157,7 +143,7 @@ public class SimpleMotorFeedforward implements ProtobufSerializable, StructSeria * @param nextVelocity The next velocity setpoint. * @return The computed feedforward. */ - public double calculateWithVelocities(double currentVelocity, double nextVelocity) { + public double calculate(double currentVelocity, double nextVelocity) { // See wpimath/algorithms.md#Simple_motor_feedforward for derivation if (ka == 0.0) { return ks * Math.signum(nextVelocity) + kv * nextVelocity; diff --git a/wpimath/src/main/native/include/frc/controller/SimpleMotorFeedforward.h b/wpimath/src/main/native/include/frc/controller/SimpleMotorFeedforward.h index 87099047f5..4aeea81d2c 100644 --- a/wpimath/src/main/native/include/frc/controller/SimpleMotorFeedforward.h +++ b/wpimath/src/main/native/include/frc/controller/SimpleMotorFeedforward.h @@ -67,22 +67,6 @@ class SimpleMotorFeedforward { } } - /** - * Calculates the feedforward from the gains and setpoints assuming continuous - * control. - * - * @param velocity The velocity setpoint. - * @param acceleration The acceleration setpoint. - * @return The computed feedforward, in volts. - * @deprecated Use the current/next velocity overload instead. - */ - [[deprecated("Use the current/next velocity overload instead.")]] - constexpr units::volt_t Calculate( - units::unit_t velocity, - units::unit_t acceleration) const { - return kS * wpi::sgn(velocity) + kV * velocity + kA * acceleration; - } - /** * Calculates the feedforward from the gains and velocity setpoint assuming * discrete control. Use this method when the velocity setpoint does not diff --git a/wpimath/src/test/java/edu/wpi/first/math/controller/SimpleMotorFeedforwardTest.java b/wpimath/src/test/java/edu/wpi/first/math/controller/SimpleMotorFeedforwardTest.java index 3c0a74835a..799cfe8bac 100644 --- a/wpimath/src/test/java/edu/wpi/first/math/controller/SimpleMotorFeedforwardTest.java +++ b/wpimath/src/test/java/edu/wpi/first/math/controller/SimpleMotorFeedforwardTest.java @@ -34,19 +34,17 @@ class SimpleMotorFeedforwardTest { double nextVelocity = 3.0; // rad/s assertEquals( - 37.52499583432516 + 0.5, - simpleMotor.calculateWithVelocities(currentVelocity, nextVelocity), - 0.002); + 37.52499583432516 + 0.5, simpleMotor.calculate(currentVelocity, nextVelocity), 0.002); assertEquals( plantInversion.calculate(r, nextR).get(0, 0) + Ks, - simpleMotor.calculateWithVelocities(currentVelocity, nextVelocity), + simpleMotor.calculate(currentVelocity, nextVelocity), 0.002); // These won't match exactly. It's just an approximation to make sure they're // in the same ballpark. assertEquals( plantInversion.calculate(r, nextR).get(0, 0) + Ks, - simpleMotor.calculateWithVelocities(currentVelocity, nextVelocity), + simpleMotor.calculate(currentVelocity, nextVelocity), 2.0); } diff --git a/wpimath/src/test/java/edu/wpi/first/math/trajectory/DifferentialDriveVoltageConstraintTest.java b/wpimath/src/test/java/edu/wpi/first/math/trajectory/DifferentialDriveVoltageConstraintTest.java index 52af40e89b..11a47bd71c 100644 --- a/wpimath/src/test/java/edu/wpi/first/math/trajectory/DifferentialDriveVoltageConstraintTest.java +++ b/wpimath/src/test/java/edu/wpi/first/math/trajectory/DifferentialDriveVoltageConstraintTest.java @@ -51,25 +51,25 @@ class DifferentialDriveVoltageConstraintTest { assertAll( () -> assertTrue( - feedforward.calculateWithVelocities( + feedforward.calculate( wheelSpeeds.leftMetersPerSecond, wheelSpeeds.leftMetersPerSecond + dt * acceleration) <= maxVoltage + 0.05), () -> assertTrue( - feedforward.calculateWithVelocities( + feedforward.calculate( wheelSpeeds.leftMetersPerSecond, wheelSpeeds.leftMetersPerSecond + dt * acceleration) >= -maxVoltage - 0.05), () -> assertTrue( - feedforward.calculateWithVelocities( + feedforward.calculate( wheelSpeeds.rightMetersPerSecond, wheelSpeeds.rightMetersPerSecond + dt * acceleration) <= maxVoltage + 0.05), () -> assertTrue( - feedforward.calculateWithVelocities( + feedforward.calculate( wheelSpeeds.rightMetersPerSecond, wheelSpeeds.rightMetersPerSecond + dt * acceleration) >= -maxVoltage - 0.05)); diff --git a/wpimath/src/test/java/edu/wpi/first/math/trajectory/ExponentialProfileTest.java b/wpimath/src/test/java/edu/wpi/first/math/trajectory/ExponentialProfileTest.java index 2f4ffac2f2..a71bfefe43 100644 --- a/wpimath/src/test/java/edu/wpi/first/math/trajectory/ExponentialProfileTest.java +++ b/wpimath/src/test/java/edu/wpi/first/math/trajectory/ExponentialProfileTest.java @@ -43,7 +43,7 @@ class ExponentialProfileTest { private static ExponentialProfile.State checkDynamics( ExponentialProfile profile, ExponentialProfile.State current, ExponentialProfile.State goal) { var next = profile.calculate(kDt, current, goal); - var signal = feedforward.calculateWithVelocities(current.velocity, next.velocity); + var signal = feedforward.calculate(current.velocity, next.velocity); assertTrue(Math.abs(signal) < constraints.maxInput + 1e-9);