[examples] Fix odometry update in SwerveControllerCommand example (#3310)

The Drive Subsystem was supplying an incorrectly constructed
Rotation2d to the odometry update method. Rotation2d constructor
was being called with heading in degrees, not radians as required.
This commit is contained in:
Jeff Hutchison
2021-04-24 23:07:04 -04:00
committed by GitHub
parent aaf24e2552
commit 6e31230adc

View File

@@ -7,7 +7,6 @@ package edu.wpi.first.wpilibj.examples.swervecontrollercommand.subsystems;
import edu.wpi.first.wpilibj.ADXRS450_Gyro;
import edu.wpi.first.wpilibj.examples.swervecontrollercommand.Constants.DriveConstants;
import edu.wpi.first.wpilibj.geometry.Pose2d;
import edu.wpi.first.wpilibj.geometry.Rotation2d;
import edu.wpi.first.wpilibj.interfaces.Gyro;
import edu.wpi.first.wpilibj.kinematics.ChassisSpeeds;
import edu.wpi.first.wpilibj.kinematics.SwerveDriveKinematics;
@@ -68,7 +67,7 @@ public class DriveSubsystem extends SubsystemBase {
public void periodic() {
// Update the odometry in the periodic block
m_odometry.update(
new Rotation2d(getHeading()),
m_gyro.getRotation2d(),
m_frontLeft.getState(),
m_rearLeft.getState(),
m_frontRight.getState(),