Class DifferentialDriveOdometry3d
This class is meant to be an easy replacement for DifferentialDriveOdometry
, only
requiring the addition of appropriate conversions between 2D and 3D versions of geometry classes.
(See Pose3d(Pose2d)
, Rotation3d(Rotation2d)
, Translation3d(Translation2d)
, and Pose3d.toPose2d()
.)
Teams can use odometry during the autonomous period for complex tasks like path following. Furthermore, odometry can be used for latency compensation when using computer-vision systems.
It is important that you reset your encoders to zero before using this class. Any subsequent pose resets also require the encoders to be reset to zero.
-
Constructor Summary
ConstructorDescriptionDifferentialDriveOdometry3d
(Rotation3d gyroAngle, double leftDistanceMeters, double rightDistanceMeters) Constructs a DifferentialDriveOdometry3d object.DifferentialDriveOdometry3d
(Rotation3d gyroAngle, double leftDistanceMeters, double rightDistanceMeters, Pose3d initialPoseMeters) Constructs a DifferentialDriveOdometry3d object.DifferentialDriveOdometry3d
(Rotation3d gyroAngle, Distance leftDistance, Distance rightDistance) Constructs a DifferentialDriveOdometry3d object.DifferentialDriveOdometry3d
(Rotation3d gyroAngle, Distance leftDistance, Distance rightDistance, Pose3d initialPoseMeters) Constructs a DifferentialDriveOdometry3d object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
resetPosition
(Rotation3d gyroAngle, double leftDistanceMeters, double rightDistanceMeters, Pose3d poseMeters) Resets the robot's position on the field.void
resetPosition
(Rotation3d gyroAngle, Distance leftDistance, Distance rightDistance, Pose3d poseMeters) Resets the robot's position on the field.update
(Rotation3d gyroAngle, double leftDistanceMeters, double rightDistanceMeters) Updates the robot position on the field using distance measurements from encoders.Methods inherited from class edu.wpi.first.math.kinematics.Odometry3d
getPoseMeters, resetPose, resetPosition, resetRotation, resetTranslation, update
-
Constructor Details
-
DifferentialDriveOdometry3d
public DifferentialDriveOdometry3d(Rotation3d gyroAngle, double leftDistanceMeters, double rightDistanceMeters, Pose3d initialPoseMeters) Constructs a DifferentialDriveOdometry3d object.- Parameters:
gyroAngle
- The angle reported by the gyroscope.leftDistanceMeters
- The distance traveled by the left encoder.rightDistanceMeters
- The distance traveled by the right encoder.initialPoseMeters
- The starting position of the robot on the field.
-
DifferentialDriveOdometry3d
public DifferentialDriveOdometry3d(Rotation3d gyroAngle, Distance leftDistance, Distance rightDistance, Pose3d initialPoseMeters) Constructs a DifferentialDriveOdometry3d object.- Parameters:
gyroAngle
- The angle reported by the gyroscope.leftDistance
- The distance traveled by the left encoder.rightDistance
- The distance traveled by the right encoder.initialPoseMeters
- The starting position of the robot on the field.
-
DifferentialDriveOdometry3d
public DifferentialDriveOdometry3d(Rotation3d gyroAngle, double leftDistanceMeters, double rightDistanceMeters) Constructs a DifferentialDriveOdometry3d object.- Parameters:
gyroAngle
- The angle reported by the gyroscope.leftDistanceMeters
- The distance traveled by the left encoder.rightDistanceMeters
- The distance traveled by the right encoder.
-
DifferentialDriveOdometry3d
public DifferentialDriveOdometry3d(Rotation3d gyroAngle, Distance leftDistance, Distance rightDistance) Constructs a DifferentialDriveOdometry3d object.- Parameters:
gyroAngle
- The angle reported by the gyroscope.leftDistance
- The distance traveled by the left encoder.rightDistance
- The distance traveled by the right encoder.
-
-
Method Details
-
resetPosition
public void resetPosition(Rotation3d gyroAngle, double leftDistanceMeters, double rightDistanceMeters, Pose3d poseMeters) Resets the robot's position on the field.The gyroscope angle does not need to be reset here on the user's robot code. The library automatically takes care of offsetting the gyro angle.
- Parameters:
gyroAngle
- The angle reported by the gyroscope.leftDistanceMeters
- The distance traveled by the left encoder.rightDistanceMeters
- The distance traveled by the right encoder.poseMeters
- The position on the field that your robot is at.
-
resetPosition
public void resetPosition(Rotation3d gyroAngle, Distance leftDistance, Distance rightDistance, Pose3d poseMeters) Resets the robot's position on the field.The gyroscope angle does not need to be reset here on the user's robot code. The library automatically takes care of offsetting the gyro angle.
- Parameters:
gyroAngle
- The angle reported by the gyroscope.leftDistance
- The distance traveled by the left encoder.rightDistance
- The distance traveled by the right encoder.poseMeters
- The position on the field that your robot is at.
-
update
Updates the robot position on the field using distance measurements from encoders. This method is more numerically accurate than using velocities to integrate the pose and is also advantageous for teams that are using lower CPR encoders.- Parameters:
gyroAngle
- The angle reported by the gyroscope.leftDistanceMeters
- The distance traveled by the left encoder.rightDistanceMeters
- The distance traveled by the right encoder.- Returns:
- The new pose of the robot.
-