phoenix6.swerve.utility.linear_path

Module Contents

class phoenix6.swerve.utility.linear_path.LinearPath(linear: wpimath.TrapezoidProfile.Constraints, angular: wpimath.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 TrapezoidProfile).

Initialization:

path = LinearPath(
    TrapezoidProfile.Constraints(MAX_V, MAX_A),
    TrapezoidProfile.Constraints(MAX_OMEGA, MAX_ALPHA)
)
current = LinearPath.State(initial_pose, initial_field_velocity)

Run on update:

current = path.calculate(time_since_previous_update, current, target_pose)

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(), velocity: phoenix6.swerve.utility.kinematics.ChassisVelocities = ChassisVelocities())

Path state.

pose

The pose at this state.

velocity

The field-centric velocity at this state.

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

Calculates the pose and velocity 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 velocity of the profile at time t

Return type:

State

duration() → wpimath.units.seconds

Returns the duration oft he path.

Returns:

The duration of the path

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