Class SwerveChassisTracker
- Direct Known Subclasses:
GyroSwerveTracker
public class SwerveChassisTracker extends java.lang.Object implements Tracker
As with any of the trackers in this library, this is compatible with
the Pathfinder system out of the box. In fact, you can even convert your
swerve drivetrain into a swerve chassis tracker pretty easily by using
the ChassisConverter
class.
Much of the tracking math behind the swerve chassis tracker happens elsewhere in the code. A lot of it happens in the SwerveModuleTracker class, which is included as an `@see` tag in this doc.
- Since:
- 0.1.0
- Author:
- Colin Robertson
- See Also:
SwerveModuleTracker
-
Field Summary
Fields Modifier and Type Field Description private SwerveModuleTracker
bl
Back-left swerve tracker.private Encoder
blDrive
The back-left dive motor's encoder.private Encoder
blTurn
The back-left turn motor's encoder.private SwerveModuleTracker
br
Back-right swerve tracker.private Encoder
brDrive
The back-right drive motor's encoder.private Encoder
brTurn
The back-right turn motor's encoder.private SwerveModuleTracker
fl
Front-left swerve tracker.private Encoder
flDrive
The front-left drive motor's encoder.private Encoder
flTurn
The front-left turn motor's encoder.private SwerveModuleTracker
fr
Front-right swerve tracker.private Encoder
frDrive
The front-right drive motor's encoder.private Encoder
frTurn
The front-right turn motor's encoder.double
gapX
The X distance, measured in inches, between the FR-FL pair of swerve modules.double
gapY
The Y distance, measured in inches, between the FR-FL pair of swerve modules.double
wheelDiameter
The diameter of each of the four drive wheels. -
Constructor Summary
Constructors Constructor Description SwerveChassisTracker(Encoder frTurn, Encoder frDrive, Encoder flTurn, Encoder flDrive, Encoder brTurn, Encoder brDrive, Encoder blTurn, Encoder blDrive, double wheelDiameter, double gapX, double gapY)
Create a new swerve chassis tracker! Yay!SwerveChassisTracker(SwerveModuleTracker fr, SwerveModuleTracker fl, SwerveModuleTracker br, SwerveModuleTracker bl)
Create a new swerve chassis tracker. -
Method Summary
Modifier and Type Method Description HeadingPoint
getBlPos()
Get the position of the back left swerve module.HeadingPoint
getBrPos()
Get the position of the back right swerve module.HeadingPoint
getFlPos()
Get the position of the front left swerve module.HeadingPoint
getFrPos()
Get the position of the front right swerve module.private HeadingPoint
getHeadlessPoint()
Get the chassis' position WITHOUT HEADING.HeadingPoint
getPos()
Get the robot's position and heading.void
update()
Update the odometry system.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
frTurn
The front-right turn motor's encoder. -
frDrive
The front-right drive motor's encoder. -
flTurn
The front-left turn motor's encoder. -
flDrive
The front-left drive motor's encoder. -
brTurn
The back-right turn motor's encoder. -
brDrive
The back-right drive motor's encoder. -
blTurn
The back-left turn motor's encoder. -
blDrive
The back-left dive motor's encoder. -
wheelDiameter
public final double wheelDiameterThe diameter of each of the four drive wheels. As usual, this value is measured in inches. -
gapX
public final double gapXThe X distance, measured in inches, between the FR-FL pair of swerve modules. This distance should be measured from the very center of the swerve module's rotational radius. -
gapY
public final double gapYThe Y distance, measured in inches, between the FR-FL pair of swerve modules. This distance should be measured from the very center of the swerve module's rotational radius. -
fr
Front-right swerve tracker. -
fl
Front-left swerve tracker. -
br
Back-right swerve tracker. -
bl
Back-left swerve tracker.
-
-
Constructor Details
-
SwerveChassisTracker
public SwerveChassisTracker(Encoder frTurn, Encoder frDrive, Encoder flTurn, Encoder flDrive, Encoder brTurn, Encoder brDrive, Encoder blTurn, Encoder blDrive, double wheelDiameter, double gapX, double gapY)Create a new swerve chassis tracker! Yay!Each of these constructor parameters is detailed in their own field JavaDocs in this Java file. If you're confused about what's going on, or what the meaning of a term is, you should go ahead and read those.
- Parameters:
frTurn
- FR turn encoderfrDrive
- FR drive encoderflTurn
- FL turn encoderflDrive
- FL drive encoderbrTurn
- BR turn encoderbrDrive
- BR drive encoderblTurn
- BL turn encoderblDrive
- BL drive encoderwheelDiameter
- see:wheelDiameter
gapX
- see:gapX
gapY
- see:gapY
-
SwerveChassisTracker
public SwerveChassisTracker(SwerveModuleTracker fr, SwerveModuleTracker fl, SwerveModuleTracker br, SwerveModuleTracker bl)Create a new swerve chassis tracker.- Parameters:
fr
- front-right tracker.fl
- front-left tracker.br
- back-right tracker.bl
- back-left tracker.
-
-
Method Details
-
getHeadlessPoint
Get the chassis' position WITHOUT HEADING.This point is calculated by averaging the position of all four of the swerve modules. In theory, this should give the chassis's center position, as the robot's position is defined as the very center of it.
- Returns:
- the chassis position, without heading.
-
getPos
Get the robot's position and heading.THIS CLASS DOES NOT SUPPORT TRACKING THE HEADING OF THE ROBOT. If you'd like to track the heading of the robot, you're going to have to do that some other way. Possibly the SwerveHeadingChassisTracker class that's in the very same package as this one. Just possibly.
- Specified by:
getPos
in interfaceOdometry
- Returns:
- the robot's position and heading.
- See Also:
getHeadlessPoint()
-
update
public void update()Update the odometry system.As I'm sure you've seen me say a million times already, this NEEDS to be called as frequently as possible. A whole thread can even be dedicated to doing just this.
- Specified by:
update
in interfaceOdometry
- See Also:
SwerveModuleTracker.update()
-
getFrPos
Get the position of the front right swerve module. -
getFlPos
Get the position of the front left swerve module. -
getBrPos
Get the position of the back right swerve module. -
getBlPos
Get the position of the back left swerve module.
-