diff --git a/wpilibc/src/main/native/cpp/frc2/command/PIDCommand.cpp b/wpilibc/src/main/native/cpp/frc2/command/PIDCommand.cpp index 03be847d6f..4391e606d8 100644 --- a/wpilibc/src/main/native/cpp/frc2/command/PIDCommand.cpp +++ b/wpilibc/src/main/native/cpp/frc2/command/PIDCommand.cpp @@ -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 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; } diff --git a/wpilibc/src/main/native/include/frc2/command/PIDCommand.h b/wpilibc/src/main/native/include/frc2/command/PIDCommand.h index a54a485d73..6e553ff39e 100644 --- a/wpilibc/src/main/native/include/frc2/command/PIDCommand.h +++ b/wpilibc/src/main/native/include/frc2/command/PIDCommand.h @@ -92,6 +92,22 @@ class PIDCommand : public CommandHelper { */ void SetSetpointRelative(double relativeSetpoint); + /** + * Gets the measurement of the process variable. Wraps the passed-in function + * for readability. + * + * @return The measurement of the process variable + */ + virtual double GetMeasurement(); + + /** + * Gets the measurement of the process variable. Wraps the passed-in function + * for readability. + * + * @return The measurement of the process variable + */ + virtual void UseOutput(double output); + /** * Returns the PIDController used by the command. *