Update ProfiledPIDController API (#1967)

This commit is contained in:
Oblarg
2019-10-24 23:37:55 -04:00
committed by Peter Johnson
parent d04eb35465
commit cbe05e7e8a
5 changed files with 72 additions and 23 deletions

View File

@@ -5,6 +5,8 @@
/* the project. */
/*----------------------------------------------------------------------------*/
#include <units/units.h>
#include <frc/Encoder.h>
#include <frc/Joystick.h>
#include <frc/PWMVictorSPX.h>
@@ -26,7 +28,8 @@ class Robot : public frc::TimedRobot {
}
// Run controller and update motor output
m_motor.Set(m_controller.Calculate(m_encoder.GetDistance()));
m_motor.Set(
m_controller.Calculate(units::meter_t(m_encoder.GetDistance())));
}
private:

View File

@@ -41,7 +41,7 @@ void SwerveModule::SetDesiredState(const frc::SwerveModuleState& state) {
// Calculate the turning motor output from the turning PID controller.
const auto turnOutput = m_turningPIDController.Calculate(
m_turningEncoder.Get(),
units::meter_t(m_turningEncoder.Get()),
// We have to convert to the meters type here because that's what
// ProfiledPIDController wants.
units::meter_t(state.angle.Radians().to<double>()));