Git Product home page Git Product logo

maxswerve-cpp-template's People

Contributors

jfabellera avatar noahandrews avatar r4stered avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

maxswerve-cpp-template's Issues

Wrong Swerve Module Order in m_odometry.Update on line 35

The order in which the swerve modules are passed to the odometry update function are in a different order then they are create in the SwerveDriveKinematics object.

They are created with the order of front left, front right, rear left, rear right.

frc::SwerveDriveKinematics<4> kDriveKinematics{
frc::Translation2d{DriveConstants::kWheelBase / 2, DriveConstants::kTrackWidth / 2},
frc::Translation2d{DriveConstants::kWheelBase / 2, -DriveConstants::kTrackWidth / 2},
frc::Translation2d{-DriveConstants::kWheelBase / 2, DriveConstants::kTrackWidth / 2},
frc::Translation2d{-DriveConstants::kWheelBase / 2, -DriveConstants::kTrackWidth / 2}};

When the odometry is updated, they are passed in the order front left, rear left, front right, rear right:

m_odometry.Update(frc::Rotation2d(units::radian_t{ m_gyro.GetAngle(frc::ADIS16470_IMU::IMUAxis::kZ)}),
{m_frontLeft.GetPosition(), m_rearLeft.GetPosition(),
m_frontRight.GetPosition(), m_rearRight.GetPosition()});

wpilib documentation states the below about the modulePositions parameter:

"modulePositions: The current position of all swerve modules. Please provide the positions in the same order in which you instantiated your [SwerveDriveKinematics]"

◆ Update()

template<size_t NumModules>
const Pose2d & frc::SwerveDriveOdometry< NumModules >::Update(const Rotation2d & gyroAngle,const wpi::array< SwerveModulePosition, NumModules > & modulePositions ) | const Pose2d & frc::SwerveDriveOdometry< NumModules >::Update | ( | const Rotation2d & | gyroAngle, |   |   | const wpi::array< SwerveModulePosition, NumModules > & | modulePositions |   | ) |   |   | inline -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- const Pose2d & frc::SwerveDriveOdometry< NumModules >::Update | ( | const Rotation2d & | gyroAngle,   |   | const wpi::array< SwerveModulePosition, NumModules > & | modulePositions   | ) |   |  
Returns
The new pose of the robot.

Update()
template<size_t NumModules>
const Pose2d & frc::SwerveDriveOdometry< NumModules >::Update ( const Rotation2d & gyroAngle,
const wpi::array< SwerveModulePosition, NumModules > & modulePositions
)
inline
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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.