Class SwerveInputs
java.lang.Object
frc.robot.subsystems.swerve.SwerveInputs
- All Implemented Interfaces:
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 Summary
FieldsModifier and TypeFieldDescriptiondoublePigeon acceleration along its own axes, g (gravity included).doubledoubleCTRE's own pose estimate, for comparison only.intbooleandoubledoublebooleanPhoenix's raw Pigeon reset flag; logic readsSwerve.gyroRebootedThisLoop.doubledoubledoubleboolean[]Per module: drive and steer motors both answering this loop.boolean[]Per module: Phoenix's raw reset flag for the drive motor, which is also true on the first contact after boot.double[]Module steer angle per sample, radians, flattened.double[]Module drive distance per sample, metres, flattened.doubledouble[]Sample times,Timer.getTimestamp()base.double[]Gyro yaw per sample, radians.doubleRaw, m/s^2: WPILib does not apply the mount orientation to the accelerometer.doubledoublebooleanSystemCore's onboard IMU, the backup gyro.doubledoubleint -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
odometryTimestamps
public double[] odometryTimestampsSample times,Timer.getTimestamp()base. -
odometryYawRadians
public double[] odometryYawRadiansGyro yaw per sample, radians. -
odometryModuleDistances
public double[] odometryModuleDistancesModule drive distance per sample, metres, flattened. -
odometryModuleAngles
public double[] odometryModuleAnglesModule steer angle per sample, radians, flattened. -
ctrePose
CTRE's own pose estimate, for comparison only. -
robotVelocity
-
moduleVelocities
-
moduleTargets
-
moduleConnected
public boolean[] moduleConnectedPer module: drive and steer motors both answering this loop. -
moduleResetOccurred
public boolean[] moduleResetOccurredPer module: Phoenix's raw reset flag for the drive motor, which is also true on the first contact after boot. Logic readsSwerve.moduleRebootedThisLoopinstead. -
gyroConnected
public boolean gyroConnected -
gyroResetOccurred
public boolean gyroResetOccurredPhoenix's raw Pigeon reset flag; logic readsSwerve.gyroRebootedThisLoop. -
gyroYawRateRadPerSec
public double gyroYawRateRadPerSec -
gyroPitchDegrees
public double gyroPitchDegrees -
gyroRollDegrees
public double gyroRollDegrees -
gyroPitchRateDegPerSec
public double gyroPitchRateDegPerSec -
gyroRollRateDegPerSec
public double gyroRollRateDegPerSec -
accelXG
public double accelXGPigeon acceleration along its own axes, g (gravity included). All 0 when not read. -
accelYG
public double accelYG -
accelZG
public double accelZG -
onboardImuPresent
public boolean onboardImuPresentSystemCore'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 onboardImuAccelXRaw, 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
-
toLog
- Specified by:
toLogin interfaceLoggableInputs
-
fromLog
- Specified by:
fromLogin interfaceLoggableInputs
-