mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
[wpimath] Clean up profile classes (#6311)
* Reorder functions so they match between languages * Copy more complete JavaDocs to C++ * Fix incorrect description for time parameter of TrapezoidProfile.calculate()
This commit is contained in:
@@ -99,14 +99,14 @@ class TrapezoidProfile {
|
||||
};
|
||||
|
||||
/**
|
||||
* Construct a TrapezoidProfile.
|
||||
* Constructs a TrapezoidProfile.
|
||||
*
|
||||
* @param constraints The constraints on the profile, like maximum velocity.
|
||||
*/
|
||||
TrapezoidProfile(Constraints constraints); // NOLINT
|
||||
|
||||
/**
|
||||
* Construct a TrapezoidProfile.
|
||||
* Constructs a TrapezoidProfile.
|
||||
*
|
||||
* @param constraints The constraints on the profile, like maximum velocity.
|
||||
* @param goal The desired state when the profile is complete.
|
||||
@@ -127,10 +127,12 @@ class TrapezoidProfile {
|
||||
TrapezoidProfile& operator=(TrapezoidProfile&&) = default;
|
||||
|
||||
/**
|
||||
* Calculate the correct position and velocity for the profile at a time t
|
||||
* where the beginning of the profile was at time t = 0.
|
||||
* Calculates the position and velocity for the profile at a time t where the
|
||||
* current state is at time t = 0.
|
||||
*
|
||||
* @param t The time since the beginning of the profile.
|
||||
* @param t How long to advance from the current state toward the desired
|
||||
* state.
|
||||
* @return The position and velocity of the profile at time t.
|
||||
* @deprecated Pass the desired and current state into calculate instead of
|
||||
* constructing a new TrapezoidProfile with the desired and current state
|
||||
*/
|
||||
@@ -141,12 +143,14 @@ class TrapezoidProfile {
|
||||
State Calculate(units::second_t t) const;
|
||||
|
||||
/**
|
||||
* Calculate the correct position and velocity for the profile at a time t
|
||||
* where the beginning of the profile was at time t = 0.
|
||||
* Calculates the position and velocity for the profile at a time t where the
|
||||
* current state is at time t = 0.
|
||||
*
|
||||
* @param t The time since the beginning of the profile.
|
||||
* @param current The initial state (usually the current state).
|
||||
* @param goal The desired state when the profile is complete.
|
||||
* @param t How long to advance from the current state toward the desired
|
||||
* state.
|
||||
* @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.
|
||||
*/
|
||||
State Calculate(units::second_t t, State current, State goal);
|
||||
|
||||
@@ -154,21 +158,25 @@ class TrapezoidProfile {
|
||||
* Returns the time left until a target distance in the profile is reached.
|
||||
*
|
||||
* @param target The target distance.
|
||||
* @return The time left until a target distance in the profile is reached.
|
||||
*/
|
||||
units::second_t TimeLeftUntil(Distance_t target) const;
|
||||
|
||||
/**
|
||||
* Returns the total time the profile takes to reach the goal.
|
||||
*
|
||||
* @return The total time the profile takes to reach the goal.
|
||||
*/
|
||||
units::second_t TotalTime() const { return m_endDeccel; }
|
||||
|
||||
/**
|
||||
* Returns true if the profile has reached the goal.
|
||||
*
|
||||
* The profile has reached the goal if the time since the profile started
|
||||
* has exceeded the profile's total time.
|
||||
* The profile has reached the goal if the time since the profile started has
|
||||
* exceeded the profile's total time.
|
||||
*
|
||||
* @param t The time since the beginning of the profile.
|
||||
* @return True if the profile has reached the goal.
|
||||
*/
|
||||
bool IsFinished(units::second_t t) const { return t >= TotalTime(); }
|
||||
|
||||
@@ -179,7 +187,7 @@ class TrapezoidProfile {
|
||||
* The profile is inverted if goal position is less than the initial position.
|
||||
*
|
||||
* @param initial The initial state (usually the current state).
|
||||
* @param goal The desired state when the profile is complete.
|
||||
* @param goal The desired state when the profile is complete.
|
||||
*/
|
||||
static bool ShouldFlipAcceleration(const State& initial, const State& goal) {
|
||||
return initial.position > goal.position;
|
||||
|
||||
Reference in New Issue
Block a user