SwerveOdometry

class SwerveOdometry(swerveDriveTrain: SwerveDriveTrain, gyro: GenericGyro, swoToMeters: Double, startingPosition: Vector3 = Vector3(0.0, 0.0, 0.0), limelightList: Array<Limelight> = arrayOf(), debugLogging: Boolean = false, field2d: Optional<Field2d> = Optional.empty())

Class for odometry using a swerve drive train. This tracks the position of the robot in 2d/3d space by un-doing SwerveDriveTrain (see SwerveDriveTrain.kt) and using the gyro to track the robot's orientation. READ THE DOCUMENTATION FOR "swoToMeters" IT IS CRUCIAL.

Parameters

swerveDriveTrain

The swerve drive train to use for odometry

gyro

The gyro to use for odometry

swoToMeters

The conversion factor from swerve drive units to meters. This unit (named the SWO) was accidentally discovered by team 2875 (Milan Lustig) and represents a semi-fluid unit of measurement nearly equal to a meter. SwerveOdometry will position the robot in 2d space in this unit, a conversion factor is required to turn it to meters. To discern this conversion factor, I recommend settings this value to one, measuring out 10-50m (mark the floor), drive the robot in a straight line at a medium speed (to ensure the wheels don't slip) along this distance. Then, you can take the distance traveled reported by SwerveOdometry (with a conversion factor of one) and divide it by the actual measured distance traveled. It is recommended to re-measure this on any major changes in floor material (carpet vs tile) or with any changes to wheel treads, robot weight, or motors. ALL HAIL THE SWO!

startingPosition

The starting position of the robot

limelightList

The list of limelights to use for odometry

debugLogging

Whether or not to log debug information

field2d

The field2d object to use for odometry

See also

Constructors

Link copied to clipboard
constructor(swerveDriveTrain: SwerveDriveTrain, gyro: GenericGyro, swoToMeters: Double, startingPosition: Vector3 = Vector3(0.0, 0.0, 0.0), limelightList: Array<Limelight> = arrayOf(), debugLogging: Boolean = false, field2d: Optional<Field2d> = Optional.empty())

Functions

Link copied to clipboard
Link copied to clipboard
fun resetOdometryLL(fieldOrientedAngle: Double = 0.0)
Link copied to clipboard

Updates the field2d object in Shuffleboard (teleometry) with the current position of the robot. Call this function to use the telemetry in Shuffleboard.

Link copied to clipboard

Updates the position of the robot (optionally using the limelight and fiducials)

Properties

Link copied to clipboard