Class LinearPath
java.lang.Object
com.ctre.phoenix6.swerve.utility.LinearPath
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:
final LinearPath path = new LinearPath(
new TrapezoidProfile.Constraints(kMaxV, kMaxA),
new TrapezoidProfile.Constraints(kMaxOmega, kMaxAlpha)
);
LinearPath.State current = new LinearPath.State(
initialPose, initialFieldVelocity
);
Run on update:
current = path.calculate(timeSincePreviousUpdate, current, targetPose);
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionLinearPath(TrapezoidProfile.Constraints linear, TrapezoidProfile.Constraints angular) Constructs a linear path. -
Method Summary
Modifier and TypeMethodDescriptionfinal LinearPath.Statecalculate(double t, LinearPath.State current, Pose2d goal) Calculates the pose and velocity of the path at a time t where the current state is at t = 0.final doubleduration()Returns the duration of the path.final booleanisFinished(double t) Returns true if the profile has reached the goal.
-
Constructor Details
-
LinearPath
Constructs a linear path.- Parameters:
linear- The constraints on the profile linear motionangular- The constraints on the profile angular motion
-
-
Method Details
-
calculate
Calculates the pose and velocity of the path at a time t where the current state is at t = 0.- Parameters:
t- How long to advance from the current state to the desired statecurrent- The current stategoal- The desired pose when the path is complete- Returns:
- The pose and velocity of the profile at time t
-
duration
public final double duration()Returns the duration of the path.- Returns:
- The duration of the path
-
isFinished
public final boolean isFinished(double t) 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
-