Class SwerveArcOdometry
Inspired by Team 1690, this odometry model treats each swerve module's motion between updates as an arc defined by the change in wheel angle and distance traveled. This more accurately represents real swerve motion, especially during simultaneous translation and rotation, where straight-line assumptions can introduce measurable integration error.
Compared to SwerveDriveOdometry, which assumes each module travels in a straight line
over a timestep, this class:
- Computes per-module displacement along a circular arc
- Transforms those displacements into the field frame
- Averages the resulting module displacements to update the robot pose
The robot heading is still sourced directly from the gyro, while translation is derived purely from module motion.
This class is intended as a drop-in replacement for SwerveDriveOdometry when improved
accuracy is desired at the cost of slightly increased computation.
-
Constructor Summary
ConstructorsConstructorDescriptionSwerveArcOdometry(SwerveDriveKinematics kinematics, Rotation2d gyroAngle, SwerveModulePosition[] modulePositions) Constructs a new arc-based swerve odometry instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidresetPosition(Rotation2d gyroAngle, SwerveModulePosition[] wheelPositions, Pose2d poseMeters) voidresetRotation(Rotation2d rotation) voidresetTranslation(Translation2d translation) update(Rotation2d currentGyroAngle, SwerveModulePosition[] currentWheelPositions)
-
Constructor Details
-
SwerveArcOdometry
public SwerveArcOdometry(SwerveDriveKinematics kinematics, Rotation2d gyroAngle, SwerveModulePosition[] modulePositions) Constructs a new arc-based swerve odometry instance.- Parameters:
kinematics- the swerve drive kinematics describing module locationsgyroAngle- the initial robot heading from the gyromodulePositions- the initial positions of each swerve module
-
-
Method Details
-
update
- Overrides:
updatein classSwerveDriveOdometry
-
resetPosition
public void resetPosition(Rotation2d gyroAngle, SwerveModulePosition[] wheelPositions, Pose2d poseMeters) - Overrides:
resetPositionin classSwerveDriveOdometry
-
resetPose
- Overrides:
resetPosein classOdometry<SwerveModulePosition[]>
-
resetTranslation
- Overrides:
resetTranslationin classOdometry<SwerveModulePosition[]>
-
resetRotation
- Overrides:
resetRotationin classOdometry<SwerveModulePosition[]>
-
getPoseMeters
- Overrides:
getPoseMetersin classOdometry<SwerveModulePosition[]>
-