Class DrivetrainSplineSample

All Implemented Interfaces:
ProtobufSerializable, StructSerializable, WPISerializable

public class DrivetrainSplineSample extends HolonomicSample
Represents a single sample in a spline-based trajectory.
  • Field Details

    • curvature

      public final double curvature
      The curvature of the path at this sample, in rad/m.
  • Constructor Details

    • DrivetrainSplineSample

      public DrivetrainSplineSample(double time, Pose2d pose, double velocity, double acceleration, double curvature)
      Constructs a DrivetrainSplineSample from path-relative scalars.

      The robot follows the path along its heading, so the scalar forward velocity and acceleration are rotated into the field frame using the sample's pose. The resulting HolonomicSample.velocity and HolonomicSample.acceleration are field-relative.

      Parameters:
      time - The time of the sample relative to the trajectory start, in seconds.
      pose - The robot pose at this sample (in the field reference frame).
      velocity - The signed forward (path-tangential) velocity in meters per second.
      acceleration - The signed forward (path-tangential) acceleration in meters per second squared.
      curvature - The curvature of the path at this sample, in rad/m.
    • DrivetrainSplineSample

      public DrivetrainSplineSample(double time, Pose2d pose, ChassisVelocities velocity, ChassisAccelerations acceleration, double curvature)
      Constructs a DrivetrainSplineSample.
      Parameters:
      time - The time of the sample relative to the trajectory start, in seconds.
      pose - The robot pose at this sample (in the field reference frame).
      velocity - The robot velocity at this sample (in the field reference frame).
      acceleration - The robot acceleration at this sample (in the field reference frame).
      curvature - The curvature of the path at this sample, in rad/m.
    • DrivetrainSplineSample

      public DrivetrainSplineSample(HolonomicSample sample)
      Constructs a DrivetrainSplineSample from another HolonomicSample, assuming the other sample's linear velocity is not zero. Curvature is computed as omega / forward velocity.
      Parameters:
      sample - The HolonomicSample to convert.
    • DrivetrainSplineSample

      public DrivetrainSplineSample()
      Constructs a DrivetrainSplineSample with all values set to zero.
  • Method Details

    • forwardVelocity

      public double forwardVelocity()
      Returns the signed forward (robot-relative tangential) velocity at this sample, in meters per second. This is the field-relative HolonomicSample.velocity projected onto the sample's heading.
      Returns:
      The forward velocity in meters per second.
    • forwardAcceleration

      public double forwardAcceleration()
      Returns the signed forward (robot-relative tangential) acceleration at this sample, in meters per second squared. This is the field-relative HolonomicSample.acceleration projected onto the sample's heading.
      Returns:
      The forward acceleration in meters per second squared.
    • transform

      public DrivetrainSplineSample transform(Transform2d transform)
      Transforms the pose of this sample by the given transform.
      Overrides:
      transform in class HolonomicSample
      Parameters:
      transform - The transform to apply to the pose.
      Returns:
      A new sample with the transformed pose.
    • relativeTo

      public DrivetrainSplineSample relativeTo(Pose2d other)
      Transforms this sample to be relative to the given pose.
      Overrides:
      relativeTo in class HolonomicSample
      Parameters:
      other - The pose to make this sample relative to.
      Returns:
      A new sample with the relative pose.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class HolonomicSample
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class HolonomicSample