diff --git a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/TrapezoidProfileCommand.java b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/TrapezoidProfileCommand.java index 57185a9df6..50416b6c30 100644 --- a/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/TrapezoidProfileCommand.java +++ b/wpilibNewCommands/src/main/java/edu/wpi/first/wpilibj2/command/TrapezoidProfileCommand.java @@ -79,7 +79,7 @@ public class TrapezoidProfileCommand extends Command { @SuppressWarnings("removal") public void execute() { if (m_newAPI) { - m_output.accept(m_profile.calculate(m_timer.get(), m_goal.get(), m_currentState.get())); + m_output.accept(m_profile.calculate(m_timer.get(), m_currentState.get(), m_goal.get())); } else { m_output.accept(m_profile.calculate(m_timer.get())); } diff --git a/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileCommand.h b/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileCommand.h index 69cc8d8b23..289b1cb455 100644 --- a/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileCommand.h +++ b/wpilibNewCommands/src/main/native/include/frc2/command/TrapezoidProfileCommand.h @@ -79,7 +79,7 @@ class TrapezoidProfileCommand void Initialize() override { m_timer.Restart(); } void Execute() override { - m_output(m_profile.Calculate(m_timer.Get(), m_goal(), m_currentState())); + m_output(m_profile.Calculate(m_timer.Get(), m_currentState(), m_goal())); } void End(bool interrupted) override { m_timer.Stop(); } diff --git a/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp index fb3a70dc8c..63cd55d974 100644 --- a/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/ElevatorTrapezoidProfile/cpp/Robot.cpp @@ -34,7 +34,7 @@ class Robot : public frc::TimedRobot { // Retrieve the profiled setpoint for the next timestep. This setpoint moves // toward the goal while obeying the constraints. - m_setpoint = m_profile.Calculate(kDt, m_goal, m_setpoint); + m_setpoint = m_profile.Calculate(kDt, m_setpoint, m_goal); // Send setpoint to offboard controller PID m_motor.SetSetpoint(ExampleSmartMotorController::PIDMode::kPosition, diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp index f6a9eeaf94..38e9262613 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceArm/cpp/Robot.cpp @@ -117,7 +117,7 @@ class Robot : public frc::TimedRobot { goal = {kLoweredPosition, 0_rad_per_s}; } m_lastProfiledReference = - m_profile.Calculate(20_ms, goal, m_lastProfiledReference); + m_profile.Calculate(20_ms, m_lastProfiledReference, goal); m_loop.SetNextR(frc::Vectord<2>{m_lastProfiledReference.position.value(), m_lastProfiledReference.velocity.value()}); diff --git a/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp b/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp index 3b83793330..ceadd8392b 100644 --- a/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp +++ b/wpilibcExamples/src/main/cpp/examples/StateSpaceElevator/cpp/Robot.cpp @@ -117,7 +117,7 @@ class Robot : public frc::TimedRobot { goal = {kLoweredPosition, 0_fps}; } m_lastProfiledReference = - m_profile.Calculate(20_ms, goal, m_lastProfiledReference); + m_profile.Calculate(20_ms, m_lastProfiledReference, goal); m_loop.SetNextR(frc::Vectord<2>{m_lastProfiledReference.position.value(), m_lastProfiledReference.velocity.value()}); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java index 2acb5bcd39..938132ba00 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/elevatortrapezoidprofile/Robot.java @@ -40,7 +40,7 @@ public class Robot extends TimedRobot { // Retrieve the profiled setpoint for the next timestep. This setpoint moves // toward the goal while obeying the constraints. - m_setpoint = m_profile.calculate(kDt, m_goal, m_setpoint); + m_setpoint = m_profile.calculate(kDt, m_setpoint, m_goal); // Send setpoint to offboard controller PID m_motor.setSetpoint( diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespacearm/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespacearm/Robot.java index 69997d17f1..1b24a61250 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespacearm/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespacearm/Robot.java @@ -126,7 +126,7 @@ public class Robot extends TimedRobot { goal = new TrapezoidProfile.State(kLoweredPosition, 0.0); } // Step our TrapezoidalProfile forward 20ms and set it as our next reference - m_lastProfiledReference = m_profile.calculate(0.020, goal, m_lastProfiledReference); + m_lastProfiledReference = m_profile.calculate(0.020, m_lastProfiledReference, goal); m_loop.setNextR(m_lastProfiledReference.position, m_lastProfiledReference.velocity); // Correct our Kalman filter's state vector estimate with encoder data. m_loop.correct(VecBuilder.fill(m_encoder.getDistance())); diff --git a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceelevator/Robot.java b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceelevator/Robot.java index 20695212cb..cb196c814c 100644 --- a/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceelevator/Robot.java +++ b/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples/statespaceelevator/Robot.java @@ -130,7 +130,7 @@ public class Robot extends TimedRobot { goal = new TrapezoidProfile.State(kLowGoalPosition, 0.0); } // Step our TrapezoidalProfile forward 20ms and set it as our next reference - m_lastProfiledReference = m_profile.calculate(0.020, goal, m_lastProfiledReference); + m_lastProfiledReference = m_profile.calculate(0.020, m_lastProfiledReference, goal); m_loop.setNextR(m_lastProfiledReference.position, m_lastProfiledReference.velocity); // Correct our Kalman filter's state vector estimate with encoder data. diff --git a/wpimath/src/main/java/edu/wpi/first/math/controller/ProfiledPIDController.java b/wpimath/src/main/java/edu/wpi/first/math/controller/ProfiledPIDController.java index 80311f5bfb..ba29fa12c4 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/controller/ProfiledPIDController.java +++ b/wpimath/src/main/java/edu/wpi/first/math/controller/ProfiledPIDController.java @@ -347,7 +347,7 @@ public class ProfiledPIDController implements Sendable { m_setpoint.position = setpointMinDistance + measurement; } - m_setpoint = m_profile.calculate(getPeriod(), m_goal, m_setpoint); + m_setpoint = m_profile.calculate(getPeriod(), m_setpoint, m_goal); return m_controller.calculate(measurement, m_setpoint.position); } diff --git a/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrapezoidProfile.java b/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrapezoidProfile.java index fd7494ca25..d29ed107c9 100644 --- a/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrapezoidProfile.java +++ b/wpimath/src/main/java/edu/wpi/first/math/trajectory/TrapezoidProfile.java @@ -29,7 +29,7 @@ import java.util.Objects; * *
* previousProfiledReference =
- * profile.calculate(timeSincePreviousUpdate, unprofiledReference, previousProfiledReference);
+ * profile.calculate(timeSincePreviousUpdate, previousProfiledReference, unprofiledReference);
*
*
* where `unprofiledReference` is free to change between calls. Note that when the unprofiled
@@ -212,11 +212,11 @@ public class TrapezoidProfile {
* the profile was at time t = 0.
*
* @param t The time since the beginning of the profile.
- * @param goal The desired state when the profile is complete.
* @param current The current state.
+ * @param goal The desired state when the profile is complete.
* @return The position and velocity of the profile at time t.
*/
- public State calculate(double t, State goal, State current) {
+ public State calculate(double t, State current, State goal) {
m_direction = shouldFlipAcceleration(current, goal) ? -1 : 1;
m_current = direct(current);
goal = direct(goal);
diff --git a/wpimath/src/main/native/include/frc/controller/ProfiledPIDController.h b/wpimath/src/main/native/include/frc/controller/ProfiledPIDController.h
index 8f211c62c4..39dc3add2c 100644
--- a/wpimath/src/main/native/include/frc/controller/ProfiledPIDController.h
+++ b/wpimath/src/main/native/include/frc/controller/ProfiledPIDController.h
@@ -322,7 +322,7 @@ class ProfiledPIDController
m_setpoint.position = setpointMinDistance + measurement;
}
- m_setpoint = m_profile.Calculate(GetPeriod(), m_goal, m_setpoint);
+ m_setpoint = m_profile.Calculate(GetPeriod(), m_setpoint, m_goal);
return m_controller.Calculate(measurement.value(),
m_setpoint.position.value());
}
diff --git a/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.h b/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.h
index 73aab38506..18002462a0 100644
--- a/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.h
+++ b/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.h
@@ -29,8 +29,8 @@ namespace frc {
* Run on update:
* @code{.cpp}
* previousProfiledReference = profile.Calculate(timeSincePreviousUpdate,
- * unprofiledReference,
- * previousProfiledReference);
+ * previousProfiledReference,
+ * unprofiledReference);
* @endcode
*
* where `unprofiledReference` is free to change between calls. Note that when
@@ -121,10 +121,10 @@ class TrapezoidProfile {
* where the beginning of the profile was at time t = 0.
*
* @param t The time since the beginning of the profile.
- * @param goal The desired state when the profile is complete.
* @param current The initial state (usually the current state).
+ * @param goal The desired state when the profile is complete.
*/
- State Calculate(units::second_t t, State goal, State current);
+ State Calculate(units::second_t t, State current, State goal);
/**
* Returns the time left until a target distance in the profile is reached.
diff --git a/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.inc b/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.inc
index 24e0a46b80..c970a791d5 100644
--- a/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.inc
+++ b/wpimath/src/main/native/include/frc/trajectory/TrapezoidProfile.inc
@@ -97,8 +97,8 @@ TrapezoidProfile