Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Swerve_Drive_Odometry

spamtactics edited this page Oct 13, 2023 · 8 revisions
Shortcuts: 🧑‍💻 Code 🏠 Wiki Home 🧾 WPILib Docs Chief Delphi Forums ☑️ Project
Useful links:
https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/math/kinematics/package-summary.html
https://github.wpilib.org/allwpilib/docs/release/java/edu/wpi/first/math/kinematics/SwerveDriveOdometry.html
https://docs.wpilib.org/en/stable/docs/software/hardware-apis/sensors/gyros-software.html

What is odometry? Odometry is the process of using data from sensors to allow the robot to know where its current position is. For example, if the robot knows that it is moving at bearing 0 at 1m/s. After 1s, it must therefore know that it is currently at coordinate (0,1). (this is assuming that bearing 0 is corresponding to the x-axis) How to set up odometry in the code? First, intialise a SwerveDriveKinemtics class, a list of all SwerveModulePosition classes of the motors. Do note that the gyro angle will have to be provided by your IMU's gyroscope. Input the necessary variables to create a new SwerveDriveOdometry class. What are the functions of SwerveDriveOdometry: