PID

class PID : public vslib::Component

Public Functions

inline PID(std::string_view name, Component &parent)

PID controller constructor. Allows to set the name of the Component, set this controller as a child of a given parent Component, and specify an anti-windup function, which by default does not do anything.

Parameters:
  • name – Name identification of the PID controller

  • parent – Parent of this controller

inline void updateInputHistories(const double reference, const double measurement) noexcept

Updates histories of measurements and references and moves the head of the history buffer.

Parameters:
  • reference – Current value of the set-point reference

  • measurement – Current value of the process value

inline double control(const double reference, const double measurement) noexcept

Computes one iteration of the controller.

Parameters:
  • reference – Reference value for the controller

  • measurement – Value of the controlled process

Returns:

Result of this iteration

inline void updateReference(const double updated_actuation)

Updates the most recent reference in the history, used in cases actuation goes over the limit.

Parameters:

updated_actuation – Actuation that actually took place after clipping of the calculated actuation

inline void reset() noexcept

Resets the controller to the initial state by zeroing the history.

inline const auto &getR() const

Returns the r polynomial coefficients.

Returns:

r polynomial coefficients

inline const auto &getS() const

Returns the s polynomial coefficients.

Returns:

s polynomial coefficients

inline const auto &getT() const

Returns the t polynomial coefficients.

Returns:

t polynomial coefficients

inline virtual std::optional<fgc4::utils::Warning> verifyParameters() override

Update parameters method, called after any Parameter of this Component is modified.

Returns:

Optionally returns a Warning with pertinent information if verification was unsuccessful, nothing otherwise

Public Members

Parameter<double> kp

Proportional gain coefficient.

Parameter<double> ki

Integral gain coefficient.

Parameter<double> kd

Derivative gain coefficient.

Parameter<double> kff

Feed-forward scaling coefficient.

Parameter<double> b

Reference signal proportional gain scaling (from DSP regFGC3)

Parameter<double> c

Reference signal derivative gain scaling (from High-Performance Digital Control)

Parameter<double> N

Filter order for derivative input.

Parameter<double> T

Control period.

Parameter<double> f0

Pre-warping frequency.

LimitRange<double> actuation_limits

Range limiting of the actuation output.