Class SwerveInputs

java.lang.Object
frc.robot.subsystems.swerve.SwerveInputs
All Implemented Interfaces:
LoggableInputs

public class SwerveInputs extends Object implements LoggableInputs
Everything the drivetrain reads from CTRE in one loop, as an AdvantageKit input.

The CTRE SwerveDrivetrain still runs a 250 Hz odometry thread and the swerve requests. None of the robot's logic reads its pose directly. Instead, every odometry sample it produced since the last loop is queued off its thread and recorded here, and PoseFusion integrates them on the main loop. That is what makes the robot pose replayable: in replay these arrays come back from the log, the fusion re-runs over them, and every vision gate sees the same pose it saw on the field.

Odometry samples are stored flattened: module m of sample s is at index s * 4 + m.

  • Field Details

    • odometryTimestamps

      public double[] odometryTimestamps
      Sample times, Timer.getTimestamp() base.
    • odometryYawRadians

      public double[] odometryYawRadians
      Gyro yaw per sample, radians.
    • odometryModuleDistances

      public double[] odometryModuleDistances
      Module drive distance per sample, metres, flattened.
    • odometryModuleAngles

      public double[] odometryModuleAngles
      Module steer angle per sample, radians, flattened.
    • ctrePose

      public Pose2d ctrePose
      CTRE's own pose estimate, for comparison only.
    • robotVelocity

      public ChassisVelocities robotVelocity
    • moduleVelocities

      public SwerveModuleVelocity[] moduleVelocities
    • moduleTargets

      public SwerveModuleVelocity[] moduleTargets
    • moduleConnected

      public boolean[] moduleConnected
      Per module: drive and steer motors both answering this loop.
    • moduleResetOccurred

      public boolean[] moduleResetOccurred
      Per module: Phoenix's raw reset flag for the drive motor, which is also true on the first contact after boot. Logic reads Swerve.moduleRebootedThisLoop instead.
    • gyroConnected

      public boolean gyroConnected
    • gyroResetOccurred

      public boolean gyroResetOccurred
      Phoenix's raw Pigeon reset flag; logic reads Swerve.gyroRebootedThisLoop.
    • gyroYawRateRadPerSec

      public double gyroYawRateRadPerSec
    • gyroPitchDegrees

      public double gyroPitchDegrees
    • gyroRollDegrees

      public double gyroRollDegrees
    • gyroPitchRateDegPerSec

      public double gyroPitchRateDegPerSec
    • gyroRollRateDegPerSec

      public double gyroRollRateDegPerSec
    • accelXG

      public double accelXG
      Pigeon acceleration along its own axes, g (gravity included). All 0 when not read.
    • accelYG

      public double accelYG
    • accelZG

      public double accelZG
    • onboardImuPresent

      public boolean onboardImuPresent
      SystemCore's onboard IMU, the backup gyro. Not on CAN, so a CANivore drop spares it.
    • onboardImuYawRadians

      public double onboardImuYawRadians
    • onboardImuYawRateRadPerSec

      public double onboardImuYawRateRadPerSec
    • onboardImuAccelX

      public double onboardImuAccelX
      Raw, m/s^2: WPILib does not apply the mount orientation to the accelerometer.
    • onboardImuAccelY

      public double onboardImuAccelY
    • onboardImuAccelZ

      public double onboardImuAccelZ
    • odometryPeriodSeconds

      public double odometryPeriodSeconds
    • successfulDaqs

      public int successfulDaqs
    • failedDaqs

      public int failedDaqs
  • Constructor Details

    • SwerveInputs

      public SwerveInputs()
  • Method Details