SwerveDrive4Odometry

class wpimath.kinematics.SwerveDrive4Odometry(kinematics: wpimath.kinematics._kinematics.SwerveDrive4Kinematics, gyroAngle: wpimath.geometry._geometry.Rotation2d, modulePositions: Tuple[wpimath.kinematics._kinematics.SwerveModulePosition, wpimath.kinematics._kinematics.SwerveModulePosition, wpimath.kinematics._kinematics.SwerveModulePosition, wpimath.kinematics._kinematics.SwerveModulePosition], initialPose: wpimath.geometry._geometry.Pose2d = Pose2d(Translation2d(x=0.000000, y=0.000000), Rotation2d(0.000000)))

Bases: pybind11_object

Class for swerve drive odometry. Odometry allows you to track the robot’s position on the field over a course of a match using readings from your swerve drive encoders and swerve azimuth 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.

Constructs a SwerveDriveOdometry object.

Parameters:
  • kinematics – The swerve drive kinematics for your drivetrain.

  • gyroAngle – The angle reported by the gyroscope.

  • modulePositions – The wheel positions reported by each module.

  • initialPose – The starting position of the robot on the field.

getPose() wpimath.geometry._geometry.Pose2d

Returns the position of the robot on the field.

Returns:

The pose of the robot.

resetPosition(arg0: wpimath.geometry._geometry.Rotation2d, arg1: wpimath.geometry._geometry.Pose2d, arg2: wpimath.kinematics._kinematics.SwerveModulePosition, arg3: wpimath.kinematics._kinematics.SwerveModulePosition, arg4: wpimath.kinematics._kinematics.SwerveModulePosition, arg5: wpimath.kinematics._kinematics.SwerveModulePosition) None

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.

  • modulePositions – The wheel positions reported by each module.

  • pose – The position on the field that your robot is at.

update(arg0: wpimath.geometry._geometry.Rotation2d, arg1: wpimath.kinematics._kinematics.SwerveModulePosition, arg2: wpimath.kinematics._kinematics.SwerveModulePosition, arg3: wpimath.kinematics._kinematics.SwerveModulePosition, arg4: wpimath.kinematics._kinematics.SwerveModulePosition) wpimath.geometry._geometry.Pose2d

Updates the robot’s position on the field using forward kinematics and integration of the pose over time. This also takes in an angle parameter which is used instead of the angular rate that is calculated from forward kinematics.

Parameters:
  • gyroAngle – The angle reported by the gyroscope.

  • modulePositions – The current position of all swerve modules. Please provide the positions in the same order in which you instantiated your SwerveDriveKinematics.

Returns:

The new pose of the robot.