WPILibC++ 2023.4.3
frc::MecanumDriveOdometry Class Reference

Class for mecanum drive odometry. More...

#include <frc/kinematics/MecanumDriveOdometry.h>

Public Member Functions

 MecanumDriveOdometry (MecanumDriveKinematics kinematics, const Rotation2d &gyroAngle, const MecanumDriveWheelPositions &wheelPositions, const Pose2d &initialPose=Pose2d{})
 Constructs a MecanumDriveOdometry object. More...
 
void ResetPosition (const Rotation2d &gyroAngle, const MecanumDriveWheelPositions &wheelPositions, const Pose2d &pose)
 Resets the robot's position on the field. More...
 
const Pose2dGetPose () const
 Returns the position of the robot on the field. More...
 
const Pose2dUpdate (const Rotation2d &gyroAngle, const MecanumDriveWheelPositions &wheelPositions)
 Updates the robot's position on the field using forward kinematics and integration of the pose over time. More...
 

Detailed Description

Class for mecanum drive odometry.

Odometry allows you to track the robot's position on the field over a course of a match using readings from your mecanum wheel encoders.

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.

Constructor & Destructor Documentation

◆ MecanumDriveOdometry()

frc::MecanumDriveOdometry::MecanumDriveOdometry ( MecanumDriveKinematics  kinematics,
const Rotation2d gyroAngle,
const MecanumDriveWheelPositions wheelPositions,
const Pose2d initialPose = Pose2d{} 
)
explicit

Constructs a MecanumDriveOdometry object.

Parameters
kinematicsThe mecanum drive kinematics for your drivetrain.
gyroAngleThe angle reported by the gyroscope.
wheelPositionsThe current distances measured by each wheel.
initialPoseThe starting position of the robot on the field.

Member Function Documentation

◆ GetPose()

const Pose2d & frc::MecanumDriveOdometry::GetPose ( ) const
inline

Returns the position of the robot on the field.

Returns
The pose of the robot.

◆ ResetPosition()

void frc::MecanumDriveOdometry::ResetPosition ( const Rotation2d gyroAngle,
const MecanumDriveWheelPositions wheelPositions,
const Pose2d pose 
)
inline

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
gyroAngleThe angle reported by the gyroscope.
wheelPositionsThe current distances measured by each wheel.
poseThe position on the field that your robot is at.

◆ Update()

const Pose2d & frc::MecanumDriveOdometry::Update ( const Rotation2d gyroAngle,
const MecanumDriveWheelPositions wheelPositions 
)

Updates the robot's position on the field using forward kinematics and integration of the pose over time.

This method takes in an angle parameter which is used instead of the angular rate that is calculated from forward kinematics, in addition to the current distance measurement at each wheel.

Parameters
gyroAngleThe angle reported by the gyroscope.
wheelPositionsThe current distances measured by each wheel.
Returns
The new pose of the robot.

The documentation for this class was generated from the following file: