Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes the resetOdometry method #142

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -336,13 +336,15 @@ public void setMotorBrake(boolean brake)
}

/**
* Gets the current yaw angle of the robot, as reported by the imu. CCW positive, not wrapped.
* Gets the current yaw angle of the robot, as reported by the swerve pose estimator in the underlying
* drivebase. Note, this is not the raw gyro reading, this may be corrected from calls to
* resetOdometry().
*
* @return The yaw angle
*/
public Rotation2d getHeading()
{
return swerveDrive.getYaw();
return getPose().getRotation();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/swervelib/SwerveDrive.java
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public ChassisSpeeds getRobotVelocity()
public void resetOdometry(Pose2d pose)
{
odometryLock.lock();
swerveDrivePoseEstimator.resetPosition(pose.getRotation(), getModulePositions(), pose);
swerveDrivePoseEstimator.resetPosition(getYaw(), getModulePositions(), pose);
odometryLock.unlock();
kinematics.toSwerveModuleStates(ChassisSpeeds.fromFieldRelativeSpeeds(0, 0, 0, pose.getRotation()));
}
Expand Down