TrapezoidProfileRadians

class wpimath.trajectory.TrapezoidProfileRadians(constraints: wpimath._controls._controls.trajectory.TrapezoidProfileRadians.Constraints, goal: wpimath._controls._controls.trajectory.TrapezoidProfileRadians.State, initial: wpimath._controls._controls.trajectory.TrapezoidProfileRadians.State = <wpimath._controls._controls.trajectory.TrapezoidProfileRadians.State object at 0x7fecbf5c8f30>)

Bases: pybind11_object

A 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)
previousProfiledReference = initialReference

Run on update:

profile = TrapezoidProfile(constraints, unprofiledReference, previousProfiledReference)
previousProfiledReference = profile.calculate(timeSincePreviousUpdate)

where unprofiledReference is 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 via isFinished().

Construct a TrapezoidProfile.

Parameters:
  • constraints – The constraints on the profile, like maximum velocity.

  • goal – The desired state when the profile is complete.

  • initial – The initial state (usually the current state).

class Constraints(maxVelocity: radians_per_second = 0, maxAcceleration: radians_per_second_squared = 0)

Bases: pybind11_object

class State(position: radians = 0, velocity: radians_per_second = 0)

Bases: pybind11_object

property position
property velocity
calculate(t: seconds) wpimath._controls._controls.trajectory.TrapezoidProfileRadians.State

Calculate the correct position and velocity for the profile at a time t where the beginning of the profile was at time t = 0.

Parameters:

t – The time since the beginning of the profile.

isFinished(t: 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.

timeLeftUntil(target: radians) seconds

Returns the time left until a target distance in the profile is reached.

Parameters:

target – The target distance.

totalTime() seconds

Returns the total time the profile takes to reach the goal.