C++ PIDCommand: Add GetMeasurement() and UseOutput() (#1892)

These are in the Java version but were missed in C++.
This commit is contained in:
Oblarg
2019-09-16 13:53:03 -04:00
committed by Peter Johnson
parent 2dfbb855d7
commit 85d42c1993
2 changed files with 22 additions and 2 deletions

View File

@@ -31,10 +31,10 @@ PIDCommand::PIDCommand(PIDController controller,
void PIDCommand::Initialize() { m_controller.Reset(); }
void PIDCommand::Execute() {
m_useOutput(m_controller.Calculate(m_measurement(), m_setpoint()));
UseOutput(m_controller.Calculate(GetMeasurement(), m_setpoint()));
}
void PIDCommand::End(bool interrupted) { m_useOutput(0); }
void PIDCommand::End(bool interrupted) { UseOutput(0); }
void PIDCommand::SetOutput(std::function<void(double)> useOutput) {
m_useOutput = useOutput;
@@ -52,4 +52,8 @@ void PIDCommand::SetSetpointRelative(double relativeSetpoint) {
SetSetpoint(m_setpoint() + relativeSetpoint);
}
double PIDCommand::GetMeasurement() { return m_measurement(); }
void PIDCommand::UseOutput(double output) { m_useOutput(output); }
PIDController& PIDCommand::getController() { return m_controller; }