Package choreo.trajectory
Class SwerveSample
java.lang.Object
choreo.trajectory.SwerveSample
- All Implemented Interfaces:
TrajectorySample<SwerveSample>,Interpolatable<SwerveSample>,StructSerializable,WPISerializable
A single swerve robot sample in a Trajectory.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal doubleThe angular acceleration of the sample in rad/s².final doubleThe acceleration of the sample in the X direction in m/s².final doubleThe acceleration of the sample in the Y direction in m/s².final doubleThe heading of the sample in radians, with 0 being in the +X direction.final doubleThe angular velocity of the sample in rad/s.static final Struct<SwerveSample>The struct for the SwerveSample class.final doubleThe timestamp of this sample, relative to the beginning of the trajectory.final doubleThe velocity of the sample in the X direction in m/s.final doubleThe velocity of the sample in the Y direction in m/s.final doubleThe X position of the sample relative to the blue alliance wall origin in meters.final doubleThe Y position of the sample relative to the blue alliance wall origin in meters. -
Constructor Summary
ConstructorsConstructorDescriptionSwerveSample(double t, double x, double y, double heading, double vx, double vy, double omega, double ax, double ay, double alpha, double[] moduleForcesX, double[] moduleForcesY) Constructs a SwerveSample with the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionbooleanflipped()Returns this sample, flipped to the other alliance according to the symmetry of the field.Returns the field-relative chassis speeds of this sample.getPose()Returns the pose at this sample.doubleReturns the timestamp of this sample.interpolate(SwerveSample endValue, double timestamp) mirrorX()Returns this sample, mirrored to the other alliance.mirrorY()Returns this sample, mirrored left-to-right from the driver's perspective.double[]A null safe getter for the module forces in the X direction.double[]A null safe getter for the module forces in the Y direction.offsetBy(double timestampOffset) Returns this sample, offset by the given timestamp.Returns this sample, rotated 180 degrees around the field center.
-
Field Details
-
t
The timestamp of this sample, relative to the beginning of the trajectory. -
x
The X position of the sample relative to the blue alliance wall origin in meters. -
y
The Y position of the sample relative to the blue alliance wall origin in meters. -
heading
The heading of the sample in radians, with 0 being in the +X direction. -
vx
The velocity of the sample in the X direction in m/s. -
vy
The velocity of the sample in the Y direction in m/s. -
omega
The angular velocity of the sample in rad/s. -
ax
The acceleration of the sample in the X direction in m/s². -
ay
The acceleration of the sample in the Y direction in m/s². -
alpha
The angular acceleration of the sample in rad/s². -
struct
The struct for the SwerveSample class.
-
-
Constructor Details
-
SwerveSample
public SwerveSample(double t, double x, double y, double heading, double vx, double vy, double omega, double ax, double ay, double alpha, double[] moduleForcesX, double[] moduleForcesY) Constructs a SwerveSample with the specified parameters.- Parameters:
t- The timestamp of this sample, relative to the beginning of the trajectory.x- The X position of the sample in meters.y- The Y position of the sample in meters.heading- The heading of the sample in radians, with 0 being in the +X direction.vx- The velocity of the sample in the X direction in m/s.vy- The velocity of the sample in the Y direction in m/s.omega- The angular velocity of the sample in rad/s.ax- The acceleration of the sample in the X direction in m/s².ay- The acceleration of the sample in the Y direction in m/s².alpha- The angular acceleration of the sample in rad/s².moduleForcesX- The force on each swerve module in the X direction in Newtons. Module forces appear in the following order: [FL, FR, BL, BR].moduleForcesY- The force on each swerve module in the Y direction in Newtons. Module forces appear in the following order: [FL, FR, BL, BR].
-
-
Method Details
-
moduleForcesX
A null safe getter for the module forces in the X direction.- Returns:
- The module forces in the X direction.
-
moduleForcesY
A null safe getter for the module forces in the Y direction.- Returns:
- The module forces in the Y direction.
-
getTimestamp
Description copied from interface:TrajectorySampleReturns the timestamp of this sample.- Specified by:
getTimestampin interfaceTrajectorySample<SwerveSample>- Returns:
- the timestamp of this sample.
-
getPose
Description copied from interface:TrajectorySampleReturns the pose at this sample.- Specified by:
getPosein interfaceTrajectorySample<SwerveSample>- Returns:
- the pose at this sample.
-
getChassisSpeeds
Description copied from interface:TrajectorySampleReturns the field-relative chassis speeds of this sample.- Specified by:
getChassisSpeedsin interfaceTrajectorySample<SwerveSample>- Returns:
- the field-relative chassis speeds of this sample.
-
interpolate
- Specified by:
interpolatein interfaceInterpolatable<SwerveSample>
-
offsetBy
Description copied from interface:TrajectorySampleReturns this sample, offset by the given timestamp.- Specified by:
offsetByin interfaceTrajectorySample<SwerveSample>- Parameters:
timestampOffset- the offset to apply to the timestamp.- Returns:
- this sample, offset by the given timestamp.
-
flipped
Description copied from interface:TrajectorySampleReturns this sample, flipped to the other alliance according to the symmetry of the field.- Specified by:
flippedin interfaceTrajectorySample<SwerveSample>- Returns:
- this sample, flipped to the other alliance according to the symmetry of the field.
-
mirrorX
Description copied from interface:TrajectorySampleReturns this sample, mirrored to the other alliance.- Specified by:
mirrorXin interfaceTrajectorySample<SwerveSample>- Returns:
- this sample, mirrored to the other alliance.
-
mirrorY
Description copied from interface:TrajectorySampleReturns this sample, mirrored left-to-right from the driver's perspective.- Specified by:
mirrorYin interfaceTrajectorySample<SwerveSample>- Returns:
- this sample, mirrored left-to-right from the driver's perspective.
-
rotateAround
Description copied from interface:TrajectorySampleReturns this sample, rotated 180 degrees around the field center.- Specified by:
rotateAroundin interfaceTrajectorySample<SwerveSample>- Returns:
- this sample, rotated 180 degrees around the field center.
-
equals
-