mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Update ProfiledPIDController API (#1967)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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>()));
|
||||
|
||||
Reference in New Issue
Block a user