![]() |
Dynamixel
2.9.5
RoadNarrows Robotics Dynamixel Package
|
Position PID class. More...
#include <DynaPidPos.h>
Public Member Functions | |
DynaPidPos (double fKp=0.5, double fKi=0.0, double fKd=0.005, double fWi=0.25) | |
Default constructor. More... | |
DynaPidPos (const DynaPid &src) | |
Copy constructor. | |
virtual | ~DynaPidPos () |
Default destructor. | |
DynaPidPos & | operator= (const DynaPidPos &rhs) |
Assignment operator. | |
virtual void | SpecifySetPoint (int nOdPosStart, int nOdPosGoal, int nSpeedLim, int nCurSpeed, bool bIsReversed, bool bUnwind=false) |
Specify position setpoint. More... | |
![]() | |
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 | TuneMaxSpeedDelta = 1000.0 |
max speed change deltas More... | |
static const double | TuneAbsMinSpeed = 0.0 |
absolute minimum speed | |
![]() | |
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 | |
void | initParams () |
Initialize parameters. | |
virtual double | error (double fPVodPosCur) |
Calculate error from goal postion setpoint and current position variable value. More... | |
virtual double | toOutput (double fCVSpeed) |
Convert control variable to application-specific output value. More... | |
Protected Attributes | |
int | m_nOdPosStart |
starting odometer position | |
int | m_nOdPosGoal |
goal ing odometer position (set point) | |
int | m_nSpeedLim |
speed limit (max neg/pos speed) | |
int | m_nOdDir |
odometer direction | |
int | m_nOdPosCur |
current odometer position | |
double | m_fSpeedAbsMax |
absolute speed limit >= 0 | |
double | m_fPrevSpeed |
previous speed | |
![]() | |
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) | |
Position PID class.
Definition at line 74 of file DynaPidPos.h.
|
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 88 of file DynaPidPos.h.
|
protectedvirtual |
Calculate error from goal postion setpoint and current position variable value.
fPVOdPosCur | Current odometer position process variable value. |
Reimplemented from DynaPid.
Definition at line 91 of file DynaPidPos.cxx.
|
virtual |
Specify position 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.
nOdPosStart | Starting position (odometer ticks). |
nOdPosGoal | New goal position setpoint (odometer ticks). |
nSpeedLim | Speed limit (raw). |
nCurSpeed | Current servo speed (raw). |
bIsReversed | Odometer is [not] reversed from encoder. |
bUnwind | Do [not] reset controller integral sum of errors term |
Definition at line 71 of file DynaPidPos.cxx.
References DynaPid::SpecifySetPoint().
Referenced by DynaBgThread::WriteGoalPos().
|
protectedvirtual |
Convert control variable to application-specific output value.
fCVSpeed | Speed control variable value. |
Reimplemented from DynaPid.
Definition at line 98 of file DynaPidPos.cxx.
|
static |