Odometry
This interface defines a system capable of reporting the position of a robot. Several odometry systems are available for use within Pathfinder. If you'd like to create your own implementation of the Odometry interface, it's suggested you make use of the AbstractOdometry class instead, as it abstracts away many of the tedious methods.
It's strongly suggested that you don't perform any offsetting on the odometry's reported positioning outside of the methods provided in this class. This helps to ensure that positions are only modified from a single source, making debugging a lot easier.
Some of the most common forms of odometry include:
- Vision-based odometry
- Three-wheel odometry
- Two-wheel odometry
Optimally, you should use as many odometry systems as you can to maintain the best positional accuracy. An odometry system's only job is to provide information on the position of the robot it belongs to.
Another one of the neat features of the Odometry interface is the ability to offset the position. This allows you to manipulate the reported position at will. Say you'd like to relocalize/recalibrate your robot's position during operation - offsets to the rescue!
The unit you choose for odometry does not matter. Odometry should always report the center of the robot's position.
Methods
getRawPosition()
Returns the raw position reported by the odometry system. This position should not be modified by any user code directly. It should always return the very center of the robot's position.
getPosition()
Returns the robot's position, which is the getRawPosition() combined with any applied offset.
getOffset()
Returns the current offset applied to the odometry system. By default, this is PointXYZ.ZERO.
setOffset(PointXYZ offset)
Sets the odometry system's offset. This will overwrite any existing offset. This method is typically overridden by implementations that support offsets.
setOffsetX(double offset)
Sets the X component of the odometry's system offset. Returns this for method chaining.
setOffsetY(double offset)
Sets the Y component of the odometry's system offset. Returns this for method chaining.
setOffsetZ(Angle offset)
Sets the Z (heading) component of the odometry's system offset. Returns this for method chaining.
getOffsetX()
Returns the X value of the current offset.
getOffsetY()
Returns the Y value of the current offset.
getOffsetZ()
Returns the Z (heading) value of the current offset.
offsetBy(PointXYZ offset)
Modifies the existing offset by adding the provided offset to it.
removeOffset()
Removes the current offset by setting it to (0, 0, 0).
offsetSoPositionIs(PointXYZ targetPosition)
Creates an offset that makes the odometry's current reported position equal to the targetPosition.
zeroOdometry()
Finds and applies an offset that makes the odometry's current position (0, 0, 0).
getX()
Returns the robot's X position (including offset).
getY()
Returns the robot's Y position (including offset).
getZ()
Returns the robot's Z (heading) position (including offset).
getRad()
Returns the robot's current heading in radians (including offset).
getDeg()
Returns the robot's current heading in degrees (including offset).
getRawX()
Returns the raw X value from the odometry system (without offset).
getRawY()
Returns the raw Y value from the odometry system (without offset).
getRawZ()
Returns the raw Z (heading) value from the odometry system (without offset).
getRawRad()
Returns the robot's raw heading in radians (without offset).
getRawDeg()
Returns the robot's raw heading in degrees (without offset).
toAbstractOdometry()
Converts this Odometry instance into an AbstractOdometry instance.
getOdometryModifier()
Returns a Function that can modify the odometry's position. By default, this method throws an UnsupportedOperationException.
setOdometryModifier(Function<PointXYZ, PointXYZ> modifier)
Sets a Function to modify the odometry's position. By default, this method throws an UnsupportedOperationException.
tick()
This method should be called every update cycle to allow the odometry system to update itself. If the odometry system does not need to update itself, this method can be left blank.