Class TiltState
java.lang.Object
frc.robot.subsystems.swerve.TiltState
What the Pigeon says about the robot's attitude and knocks, derived from logged inputs so it
replays. Used by odometry (tilt scaling), vision gating (sources that assume a level robot), and
available to shot gating (
Swerve.isTilted(), Swerve.wasBumpedRecently()).
- Tilt: the angle between the robot's up axis and vertical, from pitch and roll.
- Impact: how far the total measured acceleration is from 1 g. Standing, driving smoothly or tilted it stays near 0 (gravity is 1 g in any orientation); a collision, a bump or landing off one shows as a spike, whatever the direction.
- Odometry scale (6328's
addOdometryObservation, issue #10 section 8g): 1 while level, falling linearly to 0 betweenTILT_DEADBAND_DEGandTILT_ZERO_DEG. On a bump the wheels slip, lift or roll up a slope, so their travel overstates the robot's motion across the floor.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleImpact (g) above which the robot counts as bumped.static final doubleHow long (seconds) a bump keeps counting as recent.static final doubleBelow this tilt (degrees) the floor and the IMU's own noise; odometry is not scaled.static final doubleAt this tilt (degrees) and beyond, wheel travel is not counted at all (6328: 25 deg).static final doubleTilt (degrees) above which the robot counts as tilted, for gating. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbumpedRecently(double nowSeconds) Whether an impact aboveBUMP_Ghappened in the lastBUMP_HOLD_SECONDS.doubleimpactG()doublestatic doubleodometryScale(double tiltDeg) The odometry scale for a tilt: 1 level, 0 atTILT_ZERO_DEGand beyond.doubletiltDeg()static doubletiltDegrees(double pitchDeg, double rollDeg) The angle between the robot's up axis and vertical, degrees.booleantilted()doublevoidupdate(double nowSeconds, double pitchDeg, double rollDeg, double pitchRateDegPerSec, double rollRateDegPerSec, double accelXG, double accelYG, double accelZG) Updates from this loop's inputs.
-
Field Details
-
TILT_DEADBAND_DEG
public static final double TILT_DEADBAND_DEGBelow this tilt (degrees) the floor and the IMU's own noise; odometry is not scaled.- See Also:
-
TILT_ZERO_DEG
public static final double TILT_ZERO_DEGAt this tilt (degrees) and beyond, wheel travel is not counted at all (6328: 25 deg).- See Also:
-
TILTED_DEG
public static final double TILTED_DEGTilt (degrees) above which the robot counts as tilted, for gating.- See Also:
-
BUMP_G
public static final double BUMP_GImpact (g) above which the robot counts as bumped.- See Also:
-
BUMP_HOLD_SECONDS
public static final double BUMP_HOLD_SECONDSHow long (seconds) a bump keeps counting as recent.- See Also:
-
-
Constructor Details
-
TiltState
public TiltState()
-
-
Method Details
-
update
public void update(double nowSeconds, double pitchDeg, double rollDeg, double pitchRateDegPerSec, double rollRateDegPerSec, double accelXG, double accelYG, double accelZG) Updates from this loop's inputs.- Parameters:
nowSeconds- robot timepitchDeg- Pigeon pitchrollDeg- Pigeon rollpitchRateDegPerSec- Pigeon pitch raterollRateDegPerSec- Pigeon roll rateaccelXG- acceleration along the Pigeon's x, gaccelYG- acceleration along y, gaccelZG- acceleration along z, g
-
tiltDegrees
public static double tiltDegrees(double pitchDeg, double rollDeg) The angle between the robot's up axis and vertical, degrees. -
odometryScale
public static double odometryScale(double tiltDeg) The odometry scale for a tilt: 1 level, 0 atTILT_ZERO_DEGand beyond. -
tiltDeg
public double tiltDeg() -
tiltRateDegPerSec
public double tiltRateDegPerSec() -
impactG
public double impactG() -
tilted
public boolean tilted() -
bumpedRecently
public boolean bumpedRecently(double nowSeconds) Whether an impact aboveBUMP_Ghappened in the lastBUMP_HOLD_SECONDS. -
odometryScale
public double odometryScale()
-