mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[wpimath] Reorder TrapezoidProfile.calculate() arguments (#5874)
ProfiledPIDController and ExponentialProfile use current, then goal. This isn't a breaking change because this overload of calculate() is new for 2024.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import java.util.Objects;
|
||||
*
|
||||
* <pre><code>
|
||||
* previousProfiledReference =
|
||||
* profile.calculate(timeSincePreviousUpdate, unprofiledReference, previousProfiledReference);
|
||||
* profile.calculate(timeSincePreviousUpdate, previousProfiledReference, unprofiledReference);
|
||||
* </code></pre>
|
||||
*
|
||||
* <p>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);
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -97,8 +97,8 @@ TrapezoidProfile<Distance>::Calculate(units::second_t t) const {
|
||||
}
|
||||
template <class Distance>
|
||||
typename TrapezoidProfile<Distance>::State
|
||||
TrapezoidProfile<Distance>::Calculate(units::second_t t, State goal,
|
||||
State current) {
|
||||
TrapezoidProfile<Distance>::Calculate(units::second_t t, State current,
|
||||
State goal) {
|
||||
m_direction = ShouldFlipAcceleration(current, goal) ? -1 : 1;
|
||||
m_current = Direct(current);
|
||||
goal = Direct(goal);
|
||||
|
||||
Reference in New Issue
Block a user