Class SwerveDrivetrain.SwerveDriveState

java.lang.Object
com.ctre.phoenix6.swerve.SwerveDrivetrain.SwerveDriveState
All Implemented Interfaces:
Cloneable
Enclosing class:
SwerveDrivetrain<DriveMotorT extends CommonTalon, SteerMotorT extends CommonTalon, EncoderT extends ParentDevice>

public static class SwerveDrivetrain.SwerveDriveState extends Object implements Cloneable
Plain-Old-Data class holding the state of the swerve drivetrain. This encapsulates most data that is relevant for telemetry or decision-making from the Swerve Drive.
  • Field Details

    • Pose

      public Pose2d Pose
      The current pose of the robot
    • Velocity

      public ChassisVelocities Velocity
      The current robot-centric velocity
    • ModulePositions

      public SwerveModulePosition[] ModulePositions
      The current module positions
    • ModuleVelocities

      public SwerveModuleVelocity[] ModuleVelocities
      The current module velocities
    • ModuleTargets

      public SwerveModuleVelocity[] ModuleTargets
      The target module velocities
    • RawHeading

      public Rotation2d RawHeading
      The raw heading of the robot, unaffected by vision updates and odometry resets
    • Timestamp

      public double Timestamp
      The timestamp of the state capture, in the timebase of Utils.getCurrentTimeSeconds()
    • OdometryPeriod

      public double OdometryPeriod
      The measured odometry update period, in seconds
    • SuccessfulDaqs

      public int SuccessfulDaqs
      Number of successful data acquisitions
    • FailedDaqs

      public int FailedDaqs
      Number of failed data acquisitions
  • Constructor Details

    • SwerveDriveState

      public SwerveDriveState(int numModules)
      Creates a new swerve drive state.
      Parameters:
      numModules - The number of modules in the swerve drive state
  • Method Details

    • clone

      Creates a deep copy of this state object. This API is not thread-safe.
      Overrides:
      clone in class Object
    • updateFromNative

      protected void updateFromNative(MemorySegment driveState)
      Parameters:
      driveState - SwerveNative.swerve_drive_state_t
    • getStruct

      public static final SwerveDriveStateStruct getStruct(int numModules)
      Creates an implementation of the Struct interface for a swerve drive state object.
      Parameters:
      numModules - The number of modules in the swerve drive state objects the serializer processes
      Returns:
      Struct implementation
    • getStruct

      public final SwerveDriveStateStruct getStruct()
      Creates an implementation of the Struct interface for this swerve drive state object.
      Returns:
      Struct implementation