TrapezoidProfileRadians
- class wpimath.TrapezoidProfileRadians(constraints: wpimath._wpimath.TrapezoidProfileRadians.Constraints)
Bases:
pybind11_objectA trapezoid-shaped velocity profile.
While this class can be used for a profiled movement from start to finish, the intended usage is to filter a reference’s dynamics based on trapezoidal velocity constraints. To compute the reference obeying this constraint, do the following.
Initialization:
constraints = TrapezoidProfile.Constraints(kMaxV, kMaxA) previous_profiled_reference = initial_reference
Run on update:
profile = TrapezoidProfile(constraints, unprofiled_reference, previous_profiled_reference) previous_profiled_reference = profile.calculate(time_since_previous_update)
where
unprofiled_referenceis free to change between calls. Note that when the unprofiled reference is within the constraints,calculate()returns the unprofiled reference unchanged.Otherwise, a timer can be started to provide monotonic values for
calculate()and to determine when the profile has completed viais_finished().Constructs a TrapezoidProfile.
- Parameters:
constraints – The constraints on the profile, like maximum velocity.
- class Constraints(max_velocity: wpimath.units.radians_per_second = 0, max_acceleration: wpimath.units.radians_per_second_squared = 0)
Bases:
pybind11_objectProfile constraints.
Constructs constraints for a Trapezoid Profile.
- Parameters:
max_velocity – Maximum velocity, must be non-negative.
max_acceleration – Maximum acceleration, must be non-negative.
- class State(position: wpimath.units.radians = 0, velocity: wpimath.units.radians_per_second = 0)
Bases:
pybind11_objectProfile state.
- calculate(t: wpimath.units.seconds, current: wpimath._wpimath.TrapezoidProfileRadians.State, goal: wpimath._wpimath.TrapezoidProfileRadians.State) wpimath._wpimath.TrapezoidProfileRadians.State
Calculates the position and velocity for the profile at a time t where the current state is at time t = 0.
- Parameters:
t – How long to advance from the current state toward the desired state.
current – The current state.
goal – The desired state when the profile is complete.
- Returns:
The position and velocity of the profile at time t.
- duration() wpimath.units.seconds
Returns the duration of the profile.
- Returns:
The duration of the profile, or zero if no goal was set.
- is_finished(t: wpimath.units.seconds) bool
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.
- Parameters:
t – The time since the beginning of the profile.
- Returns:
True if the profile has reached the goal.
- time_left_until(target: wpimath.units.radians) wpimath.units.seconds
Returns the time left until a target distance in the profile is reached.
- Parameters:
target – The target distance.
- Returns:
The time left until a target distance in the profile is reached, or zero if no goal was set.