[examples] Replace gyro rotation with poseEstimator rotation (#5900)

This commit is contained in:
Elliot Scher
2023-11-10 18:12:54 -05:00
committed by GitHub
parent fa6b171e1c
commit cc2cbeb04c
4 changed files with 6 additions and 4 deletions

View File

@@ -50,7 +50,8 @@ void Drivetrain::Drive(units::meters_per_second_t xSpeed,
units::second_t period) {
auto wheelSpeeds = m_kinematics.ToWheelSpeeds(frc::ChassisSpeeds::Discretize(
fieldRelative ? frc::ChassisSpeeds::FromFieldRelativeSpeeds(
xSpeed, ySpeed, rot, m_gyro.GetRotation2d())
xSpeed, ySpeed, rot,
m_poseEstimator.GetEstimatedPosition().Rotation())
: frc::ChassisSpeeds{xSpeed, ySpeed, rot},
period));
wheelSpeeds.Desaturate(kMaxSpeed);

View File

@@ -15,7 +15,8 @@ void Drivetrain::Drive(units::meters_per_second_t xSpeed,
auto states =
m_kinematics.ToSwerveModuleStates(frc::ChassisSpeeds::Discretize(
fieldRelative ? frc::ChassisSpeeds::FromFieldRelativeSpeeds(
xSpeed, ySpeed, rot, m_gyro.GetRotation2d())
xSpeed, ySpeed, rot,
m_poseEstimator.GetEstimatedPosition().Rotation())
: frc::ChassisSpeeds{xSpeed, ySpeed, rot},
period));