File control/src/Controller/PID.hpp#

Go to the source code of this file

Proportional-Integral-Derivative Controller.

class PID : public Actuator

Public Functions

PID(SP::ControlSensor sensor, SP::SimpleMatrix B = std::shared_ptr<SimpleMatrix>())

Constructor.

Parameters:
virtual ~PID()

destructor

virtual void initialize(const NonSmoothDynamicalSystem &nsds, const Simulation &s)

initialize actuator data.

Parameters:
  • nsds – a NonSmoothDynamicalSystem

  • s – the simulation

virtual void actuate()

Compute the new control law at each event Here we are using the following formula: \( u_k = u_{k-1} + c_1 e_k + c_2 e_{k-1} + c_3 e_{k-2} \) , where.

\[\begin{split} c_1 &= K_P - \frac{K_D}{\Delta t} + K_I \Delta t \\ c_2 &= -1 - \frac{2K_D}{\Delta t} \\ c_3 &= \frac{K_D}{\Delta t} \end{split}\]

void setK(SP::SiconosVector K)

Set K.

Parameters:

K – SP::SiconosVector \( [K_P, K_I, K_D] \)

inline void setRef(double reference)

Set the value of _ref to reference.

Parameters:

reference – the new value

virtual void setTimeDiscretisation(const TimeDiscretisation &td)

Get the timestep from the TimeDiscretisation associated with this PID controller.

Parameters:

td – the TimeDiscretisation for this Actuator

inline void setDeltaT(double deltaT)#
virtual void display() const

display the data of the Actuator on the standard output

Private Functions

inline PID()#

default constructor

ACCEPT_SERIALIZATION(PID)#

Private Members

std::shared_ptr<boost::circular_buffer<double>> _err#

error vector

double _ref#

reference we are tracking

double _curDeltaT#
SP::SiconosVector _K#

vector of gains