public class TrajectoryBuilder extends BaseTrajectoryBuilder<T>
Builder for trajectories with dynamic constraints.
@JvmOverloads public TrajectoryBuilder(@NotNull Pose2d startPose, double startTangent, @NotNull TrajectoryVelocityConstraint baseVelConstraint, @NotNull TrajectoryAccelerationConstraint baseAccelConstraint, double resolution)
Create a builder from a start pose and motion state. This is the recommended constructor for creating trajectories from rest.
@JvmOverloads public TrajectoryBuilder(@NotNull Pose2d startPose, double startTangent, @NotNull TrajectoryVelocityConstraint baseVelConstraint, @NotNull TrajectoryAccelerationConstraint baseAccelConstraint)
Create a builder from a start pose and motion state. This is the recommended constructor for creating trajectories from rest.
@JvmOverloads public TrajectoryBuilder(@NotNull Pose2d startPose, @NotNull TrajectoryVelocityConstraint baseVelConstraint, @NotNull TrajectoryAccelerationConstraint baseAccelConstraint)
Create a builder from a start pose and motion state. This is the recommended constructor for creating trajectories from rest.
@JvmOverloads public TrajectoryBuilder(@NotNull Pose2d startPose, boolean reversed, @NotNull TrajectoryVelocityConstraint baseVelConstraint, @NotNull TrajectoryAccelerationConstraint baseAccelConstraint, double resolution)
@JvmOverloads public TrajectoryBuilder(@NotNull Pose2d startPose, boolean reversed, @NotNull TrajectoryVelocityConstraint baseVelConstraint, @NotNull TrajectoryAccelerationConstraint baseAccelConstraint)
@JvmOverloads public TrajectoryBuilder(@NotNull Trajectory trajectory, double t, @NotNull TrajectoryVelocityConstraint baseVelConstraint, @NotNull TrajectoryAccelerationConstraint baseAccelConstraint, double resolution)
Create a builder from an active trajectory. This is useful for interrupting a live trajectory and smoothly transitioning to a new one.
@JvmOverloads public TrajectoryBuilder(@NotNull Trajectory trajectory, double t, @NotNull TrajectoryVelocityConstraint baseVelConstraint, @NotNull TrajectoryAccelerationConstraint baseAccelConstraint)
Create a builder from an active trajectory. This is useful for interrupting a live trajectory and smoothly transitioning to a new one.
@NotNull public TrajectoryBuilder lineTo(@NotNull Vector2d endPosition, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a line segment with tangent heading interpolation.
endPosition
- end position@NotNull public TrajectoryBuilder lineToConstantHeading(@NotNull Vector2d endPosition, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a line segment with constant heading interpolation.
endPosition
- end position@NotNull public TrajectoryBuilder lineToLinearHeading(@NotNull Pose2d endPose, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a line segment with linear heading interpolation.
endPose
- end pose@NotNull public TrajectoryBuilder lineToSplineHeading(@NotNull Pose2d endPose, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a line segment with spline heading interpolation.
endPose
- end pose@NotNull public TrajectoryBuilder strafeTo(@NotNull Vector2d endPosition, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a strafe path segment.
endPosition
- end position@NotNull public TrajectoryBuilder forward(double distance, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a line straight forward.
distance
- distance to travel forward@NotNull public TrajectoryBuilder back(double distance, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a line straight backward.
distance
- distance to travel backward@NotNull public TrajectoryBuilder strafeLeft(double distance, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a segment that strafes left in the robot reference frame.
distance
- distance to strafe left@NotNull public TrajectoryBuilder strafeRight(double distance, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a segment that strafes right in the robot reference frame.
distance
- distance to strafe right@NotNull public TrajectoryBuilder splineTo(@NotNull Vector2d endPosition, double endTangent, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a spline segment with tangent heading interpolation.
endPosition
- end positionendTangent
- end tangent@NotNull public TrajectoryBuilder splineToConstantHeading(@NotNull Vector2d endPosition, double endTangent, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a spline segment with constant heading interpolation.
endPosition
- end positionendTangent
- end tangent@NotNull public TrajectoryBuilder splineToLinearHeading(@NotNull Pose2d endPose, double endTangent, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a spline segment with linear heading interpolation.
endPose
- end poseendTangent
- end tangent@NotNull public TrajectoryBuilder splineToSplineHeading(@NotNull Pose2d endPose, double endTangent, @Nullable TrajectoryVelocityConstraint velConstraintOverride, @Nullable TrajectoryAccelerationConstraint accelConstraintOverride)
Adds a spline segment with spline heading interpolation.
endPose
- end pose@NotNull protected Trajectory buildTrajectory(@NotNull Path path, @NotNull java.util.List<com.acmerobotics.roadrunner.trajectory.TemporalMarker> temporalMarkers, @NotNull java.util.List<com.acmerobotics.roadrunner.trajectory.DisplacementMarker> displacementMarkers, @NotNull java.util.List<com.acmerobotics.roadrunner.trajectory.SpatialMarker> spatialMarkers)
Build a trajectory from path
.
path