GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::PIDController< T > Class Template Reference

Proportional-integral-derivative feedback loop for adjusting a control variable towards a desired setpoint based on a measured process variable in the form of a discrete-time input signal. More...

#include <GREM/core/control.hpp>

Public Member Functions

constexpr PIDController ()=default
 Default-construct a PID controller.
constexpr PIDController (T error, T integral)
 Construct a PID controller with specific initial values.
constexpr void reset ()
 Reset the PID controller to the default state.
constexpr void reset (T newError, T newIntegral)
 Reset the PID controller to specific values.
constexpr void resetError (T newError={})
 Reset the PID controller's latest error to a specific value.
constexpr void resetIntegral (T newIntegral={})
 Reset the PID controller's accumulated integral to a specific value.
template<typename Coefficient>
constexpr auto update (T newSignalError, Coefficient proportionalGain, Coefficient integralGain, Coefficient derivativeGain)
 Update the controller state and get the next control variable value to use in order to steer the process variable towards a given setpoint based on the next discrete input signal sample value.

Detailed Description

template<typename T>
class grem::PIDController< T >

Proportional-integral-derivative feedback loop for adjusting a control variable towards a desired setpoint based on a measured process variable in the form of a discrete-time input signal.

Template Parameters
Tsignal value type. Must be a type that behaves like a number.

Constructor & Destructor Documentation

◆ PIDController() [1/2]

template<typename T>
grem::PIDController< T >::PIDController ( )
constexprdefault

Default-construct a PID controller.

◆ PIDController() [2/2]

template<typename T>
grem::PIDController< T >::PIDController ( T error,
T integral )
inlineconstexpr

Construct a PID controller with specific initial values.

Parameters
errorinitial value to set the latest error value to.
integralinitial value to set the accumulated integral value to.

Member Function Documentation

◆ reset() [1/2]

template<typename T>
void grem::PIDController< T >::reset ( )
inlineconstexpr

Reset the PID controller to the default state.

◆ reset() [2/2]

template<typename T>
void grem::PIDController< T >::reset ( T newError,
T newIntegral )
inlineconstexpr

Reset the PID controller to specific values.

Parameters
newErrornew value to set the latest error value to.
newIntegralnew value to set the accumulated integral value to.

◆ resetError()

template<typename T>
void grem::PIDController< T >::resetError ( T newError = {})
inlineconstexpr

Reset the PID controller's latest error to a specific value.

Parameters
newErrornew value to set the latest error value to.

◆ resetIntegral()

template<typename T>
void grem::PIDController< T >::resetIntegral ( T newIntegral = {})
inlineconstexpr

Reset the PID controller's accumulated integral to a specific value.

Parameters
newIntegralnew value to set the accumulated integral value to.

◆ update()

template<typename T>
template<typename Coefficient>
auto grem::PIDController< T >::update ( T newSignalError,
Coefficient proportionalGain,
Coefficient integralGain,
Coefficient derivativeGain )
inlinenodiscardconstexpr

Update the controller state and get the next control variable value to use in order to steer the process variable towards a given setpoint based on the next discrete input signal sample value.

Parameters
newSignalErrorerror between the new sample value of the input signal and the desired setpoint to steer towards, calculated as desiredSignalValue - newSignalValue.
proportionalGainhow much the current error should contribute to the output.
integralGainhow much the accumulated error should contribute to the output. Should be proportional to the sample interval duration.
derivativeGainhow much the change in error should contribute to the output. Should be inversely proportional to the sample interval duration.

The documentation for this class was generated from the following file: