YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
yarp::dev::ImplementPidControl Class Reference

#include <yarp/dev/ImplementPidControl.h>

+ Inheritance diagram for yarp::dev::ImplementPidControl:

Public Member Functions

 ImplementPidControl (yarp::dev::IPidControlRaw *y)
 
virtual ~ImplementPidControl ()
 
yarp::dev::ReturnValue getAvailablePids (int j, std::vector< PidControlTypeEnum > &avail) override
 Return a list of available pid types mode for the given joint.
 
yarp::dev::ReturnValue setPid (const PidControlTypeEnum &pidtype, int j, const Pid &pid) override
 Set new PID value for a joint axis.
 
yarp::dev::ReturnValue setPids (const PidControlTypeEnum &pidtype, const Pid *pids) override
 Set new PID value on multiple axes.
 
yarp::dev::ReturnValue setPidReference (const PidControlTypeEnum &pidtype, int j, double ref) override
 Set the controller reference for a given axis.
 
yarp::dev::ReturnValue setPidReferences (const PidControlTypeEnum &pidtype, const double *refs) override
 Set the controller reference, multiple axes.
 
yarp::dev::ReturnValue setPidErrorLimit (const PidControlTypeEnum &pidtype, int j, double limit) override
 Set the error limit for the controller on a specific joint.
 
yarp::dev::ReturnValue setPidErrorLimits (const PidControlTypeEnum &pidtype, const double *limits) override
 Get the error limit for the controller on all joints.
 
yarp::dev::ReturnValue getPidError (const PidControlTypeEnum &pidtype, int j, double *err) override
 Get the current error for a joint.
 
yarp::dev::ReturnValue getPidErrors (const PidControlTypeEnum &pidtype, double *errs) override
 Get the error of all joints.
 
yarp::dev::ReturnValue getPidOutput (const PidControlTypeEnum &pidtype, int j, double *out) override
 Get the output of the controller (e.g.
 
yarp::dev::ReturnValue getPidOutputs (const PidControlTypeEnum &pidtype, double *outs) override
 Get the output of the controllers (e.g.
 
yarp::dev::ReturnValue getPid (const PidControlTypeEnum &pidtype, int j, Pid *pid) override
 Get current PID value for a specific joint.
 
yarp::dev::ReturnValue getPids (const PidControlTypeEnum &pidtype, Pid *pids) override
 Get current PID value for a specific joint.
 
yarp::dev::ReturnValue getPidReference (const PidControlTypeEnum &pidtype, int j, double *ref) override
 Get the current reference of the PID controller for a specific joint.
 
yarp::dev::ReturnValue getPidReferences (const PidControlTypeEnum &pidtype, double *refs) override
 Get the current reference of all PID controllers.
 
yarp::dev::ReturnValue getPidErrorLimit (const PidControlTypeEnum &pidtype, int j, double *ref) override
 Get the error limit for the controller on a specific joint.
 
yarp::dev::ReturnValue getPidErrorLimits (const PidControlTypeEnum &pidtype, double *refs) override
 Get the error limit for all controllers.
 
yarp::dev::ReturnValue resetPid (const PidControlTypeEnum &pidtype, int j) override
 Reset the controller of a given joint, usually sets the current status of the joint as the reference value for the PID, and resets the integrator.
 
yarp::dev::ReturnValue enablePid (const PidControlTypeEnum &pidtype, int j) override
 Enable the PID computation for a joint.
 
yarp::dev::ReturnValue disablePid (const PidControlTypeEnum &pidtype, int j) override
 Disable the PID computation for a joint.
 
yarp::dev::ReturnValue setPidOffset (const PidControlTypeEnum &pidtype, int j, double v) override
 Set an offset value for a given controller.
 
yarp::dev::ReturnValue setPidFeedforward (const PidControlTypeEnum &pidtype, int j, double v) override
 Set the feedforward value for the specified PID controller.
 
yarp::dev::ReturnValue getPidOffset (const PidControlTypeEnum &pidtype, int j, double &v) override
 Get the currently set offset value for the specified PID controller.
 
yarp::dev::ReturnValue getPidFeedforward (const PidControlTypeEnum &pidtype, int j, double &v) override
 Get the currently set feedforward value for the specified PID controller.
 
yarp::dev::ReturnValue isPidEnabled (const PidControlTypeEnum &pidtype, int j, bool &enabled) override
 Get the current status (enabled/disabled) of the PID.
 
yarp::dev::ReturnValue getPidExtraInfo (const PidControlTypeEnum &pidtype, int j, yarp::dev::PidExtraInfo &units) override
 Get PID extra info and measurement units for a specific joint.
 
yarp::dev::ReturnValue getPidExtraInfos (const PidControlTypeEnum &pidtype, std::vector< yarp::dev::PidExtraInfo > &units) override
 Get PID extra info and measurement units for a specific joint.
 
void b ()
 
- Public Member Functions inherited from yarp::dev::IPidControl
virtual ~IPidControl ()
 Destructor.
 

Protected Member Functions

bool initialize (int size, const int *amap, const double *enc, const double *zos, const double *newtons, const double *amps, const double *dutys)
 Initialize the internal data and alloc memory.
 
bool uninitialize ()
 Clean up internal data and memory.
 
bool setConversionUnits (const PidControlTypeEnum &pidtype, const PidFeedbackUnitsEnum fbk_conv_units, const PidOutputUnitsEnum out_conv_units)
 

Protected Attributes

IPidControlRaw * m_iraw =nullptr
 
void * m_helper =nullptr
 
std::vector< int > m_buffer_ints
 
std::vector< double > m_buffer_doubles
 
std::vector< Pid > m_buffer_pids
 
std::mutex m_imp_mutex
 

Detailed Description

Definition at line 22 of file ImplementPidControl.h.

Constructor & Destructor Documentation

◆ ImplementPidControl()

ImplementPidControl::ImplementPidControl ( yarp::dev::IPidControlRaw *  y)

Definition at line 22 of file ImplementPidControl.cpp.

◆ ~ImplementPidControl()

ImplementPidControl::~ImplementPidControl ( )
virtual

Definition at line 28 of file ImplementPidControl.cpp.

Member Function Documentation

◆ b()

void yarp::dev::ImplementPidControl::b ( )

◆ disablePid()

ReturnValue ImplementPidControl::disablePid ( const PidControlTypeEnum &  pidtype,
int  j 
)
overridevirtual

Disable the PID computation for a joint.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
Returns
true on success, false on failure.

Implements yarp::dev::IPidControl.

Definition at line 363 of file ImplementPidControl.cpp.

◆ enablePid()

ReturnValue ImplementPidControl::enablePid ( const PidControlTypeEnum &  pidtype,
int  j 
)
overridevirtual

Enable the PID computation for a joint.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
Returns
true on success, false on failure.

Implements yarp::dev::IPidControl.

Definition at line 352 of file ImplementPidControl.cpp.

◆ getAvailablePids()

ReturnValue ImplementPidControl::getAvailablePids ( int  j,
std::vector< PidControlTypeEnum > &  avail 
)
overridevirtual

Return a list of available pid types mode for the given joint.

Parameters
jjoint number
availa vector that will contain the list of available control modes for joint j.
Returns
true/false on success/failure

Implements yarp::dev::IPidControl.

Definition at line 64 of file ImplementPidControl.cpp.

◆ getPid()

ReturnValue ImplementPidControl::getPid ( const PidControlTypeEnum &  pidtype,
int  j,
Pid *  pid 
)
overridevirtual

Get current PID value for a specific joint.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
pidpointer to storage for the return value.
Returns
success/failure

Implements yarp::dev::IPidControl.

Definition at line 232 of file ImplementPidControl.cpp.

◆ getPidError()

ReturnValue ImplementPidControl::getPidError ( const PidControlTypeEnum &  pidtype,
int  j,
double *  err 
)
overridevirtual

Get the current error for a joint.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
errpointer to the storage for the return value
Returns
true/false on success failure

Implements yarp::dev::IPidControl.

Definition at line 158 of file ImplementPidControl.cpp.

◆ getPidErrorLimit()

ReturnValue ImplementPidControl::getPidErrorLimit ( const PidControlTypeEnum &  pidtype,
int  j,
double *  limit 
)
overridevirtual

Get the error limit for the controller on a specific joint.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
limitpointer to storage
Returns
success/failure

Implements yarp::dev::IPidControl.

Definition at line 309 of file ImplementPidControl.cpp.

◆ getPidErrorLimits()

ReturnValue ImplementPidControl::getPidErrorLimits ( const PidControlTypeEnum &  pidtype,
double *  limits 
)
overridevirtual

Get the error limit for all controllers.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
limitspointer to the array that will store the output
Returns
success or failure

Implements yarp::dev::IPidControl.

Definition at line 327 of file ImplementPidControl.cpp.

◆ getPidErrors()

ReturnValue ImplementPidControl::getPidErrors ( const PidControlTypeEnum &  pidtype,
double *  errs 
)
overridevirtual

Get the error of all joints.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
errspointer to the vector that will store the errors

Implements yarp::dev::IPidControl.

Definition at line 175 of file ImplementPidControl.cpp.

◆ getPidExtraInfo()

yarp::dev::ReturnValue ImplementPidControl::getPidExtraInfo ( const PidControlTypeEnum &  pidtype,
int  j,
yarp::dev::PidExtraInfo &  info 
)
overridevirtual

Get PID extra info and measurement units for a specific joint.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
infothe measurement units for the specified PID.
Returns
success/failure

Implements yarp::dev::IPidControl.

Definition at line 455 of file ImplementPidControl.cpp.

◆ getPidExtraInfos()

yarp::dev::ReturnValue ImplementPidControl::getPidExtraInfos ( const PidControlTypeEnum &  pidtype,
std::vector< yarp::dev::PidExtraInfo > &  info 
)
overridevirtual

Get PID extra info and measurement units for a specific joint.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
infovector that will store the info about of the pids.
Returns
success/failure

Implements yarp::dev::IPidControl.

Definition at line 465 of file ImplementPidControl.cpp.

◆ getPidFeedforward()

ReturnValue ImplementPidControl::getPidFeedforward ( const PidControlTypeEnum &  pidtype,
int  j,
double &  v 
)
overridevirtual

Get the currently set feedforward value for the specified PID controller.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
vthe feedforward value
Returns
true on success, false on failure.

Implements yarp::dev::IPidControl.

Definition at line 419 of file ImplementPidControl.cpp.

◆ getPidOffset()

ReturnValue ImplementPidControl::getPidOffset ( const PidControlTypeEnum &  pidtype,
int  j,
double &  v 
)
overridevirtual

Get the currently set offset value for the specified PID controller.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
vthe offset value
Returns
true on success, false on failure.

Implements yarp::dev::IPidControl.

Definition at line 402 of file ImplementPidControl.cpp.

◆ getPidOutput()

ReturnValue ImplementPidControl::getPidOutput ( const PidControlTypeEnum &  pidtype,
int  j,
double *  out 
)
overridevirtual

Get the output of the controller (e.g.

pwm value)

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
outpointer to storage for return value
Returns
success/failure

Implements yarp::dev::IPidControl.

Definition at line 189 of file ImplementPidControl.cpp.

◆ getPidOutputs()

ReturnValue ImplementPidControl::getPidOutputs ( const PidControlTypeEnum &  pidtype,
double *  outs 
)
overridevirtual

Get the output of the controllers (e.g.

pwm value)

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
outspointer to the vector that will store the output values

Implements yarp::dev::IPidControl.

Definition at line 210 of file ImplementPidControl.cpp.

◆ getPidReference()

ReturnValue ImplementPidControl::getPidReference ( const PidControlTypeEnum &  pidtype,
int  j,
double *  ref 
)
overridevirtual

Get the current reference of the PID controller for a specific joint.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
refpointer to storage for return value
Returns
reference value

Implements yarp::dev::IPidControl.

Definition at line 276 of file ImplementPidControl.cpp.

◆ getPidReferences()

ReturnValue ImplementPidControl::getPidReferences ( const PidControlTypeEnum &  pidtype,
double *  refs 
)
overridevirtual

Get the current reference of all PID controllers.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
refsvector that will store the output.

Implements yarp::dev::IPidControl.

Definition at line 294 of file ImplementPidControl.cpp.

◆ getPids()

ReturnValue ImplementPidControl::getPids ( const PidControlTypeEnum &  pidtype,
Pid *  pids 
)
overridevirtual

Get current PID value for a specific joint.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
pidsvector that will store the values of the pids.
Returns
success/failure

Implements yarp::dev::IPidControl.

Definition at line 251 of file ImplementPidControl.cpp.

◆ initialize()

bool ImplementPidControl::initialize ( int  size,
const int *  amap,
const double *  enc,
const double *  zos,
const double *  newtons,
const double *  amps,
const double *  dutys 
)
protected

Initialize the internal data and alloc memory.

Parameters
sizeis the number of controlled axes the driver deals with.
amapis a lookup table mapping axes onto physical drivers.
Returns
true if initialized succeeded, false if it wasn't executed, or assert.

Definition at line 33 of file ImplementPidControl.cpp.

◆ isPidEnabled()

ReturnValue ImplementPidControl::isPidEnabled ( const PidControlTypeEnum &  pidtype,
int  j,
bool &  enabled 
)
overridevirtual

Get the current status (enabled/disabled) of the PID.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
enabledthe current status of the PID controller.
Returns
true on success, false on failure.

Implements yarp::dev::IPidControl.

Definition at line 436 of file ImplementPidControl.cpp.

◆ resetPid()

ReturnValue ImplementPidControl::resetPid ( const PidControlTypeEnum &  pidtype,
int  j 
)
overridevirtual

Reset the controller of a given joint, usually sets the current status of the joint as the reference value for the PID, and resets the integrator.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
Returns
true on success, false on failure.

Implements yarp::dev::IPidControl.

Definition at line 341 of file ImplementPidControl.cpp.

◆ setConversionUnits()

bool ImplementPidControl::setConversionUnits ( const PidControlTypeEnum &  pidtype,
const PidFeedbackUnitsEnum  fbk_conv_units,
const PidOutputUnitsEnum  out_conv_units 
)
protected

Definition at line 447 of file ImplementPidControl.cpp.

◆ setPid()

ReturnValue ImplementPidControl::setPid ( const PidControlTypeEnum &  pidtype,
int  j,
const Pid &  pid 
)
overridevirtual

Set new PID value for a joint axis.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
pidnew PID value
Returns
true/false on success/failure

Implements yarp::dev::IPidControl.

Definition at line 75 of file ImplementPidControl.cpp.

◆ setPidErrorLimit()

ReturnValue ImplementPidControl::setPidErrorLimit ( const PidControlTypeEnum &  pidtype,
int  j,
double  limit 
)
overridevirtual

Set the error limit for the controller on a specific joint.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
limitlimit value
Returns
true/false on success/failure

Implements yarp::dev::IPidControl.

Definition at line 133 of file ImplementPidControl.cpp.

◆ setPidErrorLimits()

ReturnValue ImplementPidControl::setPidErrorLimits ( const PidControlTypeEnum &  pidtype,
const double *  limits 
)
overridevirtual

Get the error limit for the controller on all joints.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
limitspointer to the vector with the new limits
Returns
true/false on success/failure

Implements yarp::dev::IPidControl.

Definition at line 145 of file ImplementPidControl.cpp.

◆ setPidFeedforward()

ReturnValue ImplementPidControl::setPidFeedforward ( const PidControlTypeEnum &  pidtype,
int  j,
double  v 
)
overridevirtual

Set the feedforward value for the specified PID controller.

This value will be multiplied by the PID feedforward gain.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
vthe feedforward value
Returns
true on success, false on failure.

Implements yarp::dev::IPidControl.

Definition at line 388 of file ImplementPidControl.cpp.

◆ setPidOffset()

ReturnValue ImplementPidControl::setPidOffset ( const PidControlTypeEnum &  pidtype,
int  j,
double  v 
)
overridevirtual

Set an offset value for a given controller.

The value will added to the output of the PID controller

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
vthe offset value
Returns
true on success, false on failure.

Implements yarp::dev::IPidControl.

Definition at line 374 of file ImplementPidControl.cpp.

◆ setPidReference()

ReturnValue ImplementPidControl::setPidReference ( const PidControlTypeEnum &  pidtype,
int  j,
double  ref 
)
overridevirtual

Set the controller reference for a given axis.

Warning this method can result in very large torques and should be used carefully. If you do not understand this warning you should avoid using this method. Have a look at other interfaces (e.g. position control).

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
jjoint number
refnew reference point
Returns
true/false upon success/failure

Implements yarp::dev::IPidControl.

Definition at line 108 of file ImplementPidControl.cpp.

◆ setPidReferences()

ReturnValue ImplementPidControl::setPidReferences ( const PidControlTypeEnum &  pidtype,
const double *  refs 
)
overridevirtual

Set the controller reference, multiple axes.

Warning this method can result in very large torques and should be used carefully. If you do not understand this warning you should avoid using this method. Have a look at other interfaces (e.g. position control).

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
refspointer to the vector that contains the new reference points.
Returns
true/false upon success/failure

Implements yarp::dev::IPidControl.

Definition at line 120 of file ImplementPidControl.cpp.

◆ setPids()

ReturnValue ImplementPidControl::setPids ( const PidControlTypeEnum &  pidtype,
const Pid *  pids 
)
overridevirtual

Set new PID value on multiple axes.

Parameters
pidtypethe id of the PID that will be affected by the command (e.g. position, velocity etc)
pidspointer to a vector of pids
Returns
true/false upon success/failure

Implements yarp::dev::IPidControl.

Definition at line 87 of file ImplementPidControl.cpp.

◆ uninitialize()

bool ImplementPidControl::uninitialize ( )
protected

Clean up internal data and memory.

Returns
true if uninitialization is executed, false otherwise.

Definition at line 53 of file ImplementPidControl.cpp.

Member Data Documentation

◆ m_buffer_doubles

std::vector<double> yarp::dev::ImplementPidControl::m_buffer_doubles
protected

Definition at line 28 of file ImplementPidControl.h.

◆ m_buffer_ints

std::vector<int> yarp::dev::ImplementPidControl::m_buffer_ints
protected

Definition at line 27 of file ImplementPidControl.h.

◆ m_buffer_pids

std::vector<Pid> yarp::dev::ImplementPidControl::m_buffer_pids
protected

Definition at line 29 of file ImplementPidControl.h.

◆ m_helper

void* yarp::dev::ImplementPidControl::m_helper =nullptr
protected

Definition at line 26 of file ImplementPidControl.h.

◆ m_imp_mutex

std::mutex yarp::dev::ImplementPidControl::m_imp_mutex
protected

Definition at line 30 of file ImplementPidControl.h.

◆ m_iraw

IPidControlRaw* yarp::dev::ImplementPidControl::m_iraw =nullptr
protected

Definition at line 25 of file ImplementPidControl.h.


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