![]() |
Dynamixel
2.9.5
RoadNarrows Robotics Dynamixel Package
|
Proportional–Integral–Derivative Controller for Dynamixel servos. More...
#include <DynaPid.h>
Public Member Functions | |
| DynaPid (double fKp=PidKpDft, double fKi=PidKiDft, double fKd=PidKdDft, double fWi=WiSumErrDft) | |
| Default constructor. More... | |
| DynaPid (const DynaPid &src) | |
| Copy constructor. | |
| virtual | ~DynaPid () |
| Default destructor. | |
| virtual void | SetConstants (double fKp, double fKi, double fKd) |
| Set PID constants. More... | |
| double | GetKp () const |
| Get PID proportional constant. More... | |
| double | GetKi () const |
| Get PID integral constant. More... | |
| double | GetKd () const |
| Get PID derivative constant. More... | |
| double | GetSP () const |
| Get PID setpoint. More... | |
| double | GetCV () const |
| Get PID control variable. More... | |
| double | GetOutput () const |
| Get PID output. More... | |
| double | GetError () const |
| Get current error. More... | |
| virtual void | InitControl () |
| Initialize the PID control variables. | |
| virtual void | SpecifySetPoint (double fSP, bool bUnwind=false) |
| Specify the setpoint. More... | |
| virtual double | Control (double fPV, double dt) |
| Apply PID control. More... | |
| DynaPid & | operator= (const DynaPid &rhs) |
| Assignment operator. More... | |
Static Public Attributes | |
| static const double | PidKpDft = 0.5 |
| default Kp constant | |
| static const double | PidKiDft = 1.0 |
| default Ki constant | |
| static const double | PidKdDft = 0.1 |
| default Kd constant | |
| static const double | WiSumErrDft = 0.1 |
| default sum error weight | |
Protected Member Functions | |
| virtual double | error (double fPV) |
| Calculate error from setpoint and current process variable value. More... | |
| virtual double | toOutput (double fCV) |
| Convert control variable to application-specific output value. More... | |
Protected Attributes | |
| double | m_fSP |
| setpoint | |
| double | m_fPV |
| process variable | |
| double | m_fKp |
| proportional constant | |
| double | m_fKi |
| integral constant | |
| double | m_fKd |
| derivative constant | |
| double | m_fWi |
| weighted sum of errors moving average constant | |
| bool | m_bHasPrev |
| has previous error | |
| double | m_fErrPrev |
| previous error | |
| double | m_fErr |
| error | |
| double | m_fErrSum |
| sum of errors | |
| double | m_fCV |
| control variable value | |
| double | m_fOutput |
| control variable output (could be same as CV) | |
Proportional–Integral–Derivative Controller for Dynamixel servos.
| setpoint (SP) | = | application specific |
| process variable (PV) | = | application specific |
| control variable (CV) | = | application specific |
| CV | = | Kp * errj + Ki * Σjerrk * dtk + Kd * (errj - errj-1) / dtj |
| output | = | converted control variable |
| j | this time step |
| j-1 | previous time step |
| dtk | delta time between time steps k-1 and k |
| errk | error = SP - PVk |
| PVk | process variable at time step k |
| Kp | proportional constant |
| Ki | integral constant |
| Kd | derivative constant |
|
inline |
Default constructor.
| fKp | PID proportional constant. |
| fKi | PID integral constant. |
| fKd | PID derivative constant. |
| fWi | PID integral sum of errors weight constant. |
Definition at line 120 of file DynaPid.h.
|
virtual |
Apply PID control.
| fPV | Process variable. |
| dt | Delta time step (seconds). |
Definition at line 83 of file DynaPid.cxx.
Referenced by DynaPidSpeed::Control(), and DynaBgThread::execPosCtl().
|
inlineprotectedvirtual |
Calculate error from setpoint and current process variable value.
| fPV | Process variable value. |
Reimplemented in DynaPidPos.
|
inline |
|
inline |
Get current error.
Definition at line 199 of file DynaPid.h.
Referenced by DynaBgThread::execPosCtl().
|
inline |
|
inline |
|
inline |
|
inline |
Get PID output.
Definition at line 193 of file DynaPid.h.
|
inline |
Assignment operator.
| rhs | Right hand side object. |
Definition at line 245 of file DynaPid.h.
References m_fKd, m_fKi, m_fKp, and m_fWi.
|
inlinevirtual |
|
virtual |
Specify the setpoint.
The PID can also be unwound. This PID technique is used when a new setpoint causes the PID to behave badly, normally through integral windup. Unwinding resets the accumulated sum of errors integral term to zero.
| fSP | New setpoint. |
| bUnwind | Do [not] reset controller integral sum of errors term |
Reimplemented in DynaPidSpeed.
Definition at line 71 of file DynaPid.cxx.
Referenced by DynaPidPos::SpecifySetPoint(), and DynaPidSpeed::SpecifySetPoint().
|
inlineprotectedvirtual |
Convert control variable to application-specific output value.
| fCV | Control variable value. |
Reimplemented in DynaPidPos.