[wpimath] Fix SimpleFeedforward overload set (#7516)

This commit is contained in:
Tyler Veness
2024-12-07 20:32:16 -08:00
committed by GitHub
parent 6dbff902fa
commit c497e4ec22
8 changed files with 17 additions and 53 deletions

View File

@@ -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);
}

View File

@@ -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));

View File

@@ -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);