Package com.ctre.phoenix6.swerve.utility
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, initialFieldSpeeds
);
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 speeds of the path at a time t where the current state is at t = 0.final booleanisFinished(double t) Returns true if the profile has reached the goal.final doubleReturns the total time the profile takes to reach 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 speeds 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 speeds of the profile at time t
-
totalTime
Returns the total time the profile takes to reach the goal.- Returns:
- The total time the profile takes to reach the goal
-
isFinished
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
-