phoenix6.swerve.utility.linear_path

Module Contents

class phoenix6.swerve.utility.linear_path.LinearPath(linear: wpimath.trajectory.TrapezoidProfile.Constraints, angular: wpimath.trajectory.TrapezoidProfile.Constraints)

A linear path for a holonomic drivetrain (i.e. swerve or mechanum). This generates profiled setpoints for the robot along a straight line based on trapezoidal velocity constraints (using {@link TrapezoidProfile}).

Initialization:

path = LinearPath(
    TrapezoidProfile.Constraints(kMaxV, kMaxA),
    TrapezoidProfile.Constraints(kMaxOmega, kMaxAlpha)
)
current = LinearPath.State(initialPose, initialFieldSpeeds)

Run on update:

current = path.calculate(timeSincePreviousUpdate, current, targetPose)

Constructs a linear path.

Parameters:
  • linear (TrapezoidProfile.Constraints) – The constraints on the profile linear motion

  • angular (TrapezoidProfile.Constraints) – The constraints on the profile angular motion

class State(pose: phoenix6.swerve.utility.geometry.Pose2d = Pose2d(), speeds: phoenix6.swerve.utility.kinematics.ChassisSpeeds = ChassisSpeeds())

Path state.

pose

The pose at this state.

speeds

The field-centric speeds at this state.

calculate(t: wpimath.units.seconds, current: State, goal: phoenix6.swerve.utility.geometry.Pose2d) State

Calculates the pose and speeds of the path at a time t where the current state is at t = 0.

Parameters:
  • t (units.seconds) – How long to advance from the current state to the desired state

  • current (State) – The current state

  • goal (Pose2d) – The desired pose when the path is complete

Returns:

The pose and speeds of the profile at time t

Return type:

State

total_time() wpimath.units.seconds

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

Returns:

The total time the profile takes to reach the goal

Return type:

units.seconds

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 (units.seconds) – The time since the beginning of the profile

Returns:

True if the profile has reached the goal

Return type:

bool