mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Fix order of setting gyro offset in pose estimators (#3176)
The gyro offset should be determined from the desired initial pose, not the current pose. This fix reflects the behavior of the odometry classes and the C++ holonomic pose estimators.
This commit is contained in:
@@ -217,8 +217,8 @@ public class DifferentialDrivePoseEstimator {
|
||||
*/
|
||||
public void resetPosition(Pose2d poseMeters, Rotation2d gyroAngle) {
|
||||
m_previousAngle = poseMeters.getRotation();
|
||||
m_gyroOffset = getEstimatedPosition().getRotation().minus(gyroAngle);
|
||||
m_observer.setXhat(fillStateVector(poseMeters, 0.0, 0.0));
|
||||
m_gyroOffset = getEstimatedPosition().getRotation().minus(gyroAngle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -182,8 +182,8 @@ public class MecanumDrivePoseEstimator {
|
||||
*/
|
||||
public void resetPosition(Pose2d poseMeters, Rotation2d gyroAngle) {
|
||||
m_previousAngle = poseMeters.getRotation();
|
||||
m_gyroOffset = getEstimatedPosition().getRotation().minus(gyroAngle);
|
||||
m_observer.setXhat(StateSpaceUtil.poseTo3dVector(poseMeters));
|
||||
m_gyroOffset = getEstimatedPosition().getRotation().minus(gyroAngle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -182,8 +182,8 @@ public class SwerveDrivePoseEstimator {
|
||||
*/
|
||||
public void resetPosition(Pose2d poseMeters, Rotation2d gyroAngle) {
|
||||
m_previousAngle = poseMeters.getRotation();
|
||||
m_gyroOffset = getEstimatedPosition().getRotation().minus(gyroAngle);
|
||||
m_observer.setXhat(StateSpaceUtil.poseTo3dVector(poseMeters));
|
||||
m_gyroOffset = getEstimatedPosition().getRotation().minus(gyroAngle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user