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

Default implementation of the IPositionControl interface. More...

#include <yarp/dev/ImplementPositionControl.h>

+ Inheritance diagram for yarp::dev::ImplementPositionControl:

Public Member Functions

 ImplementPositionControl (yarp::dev::IPositionControlRaw *y)
 Constructor.
 
virtual ~ImplementPositionControl ()
 Destructor.
 
yarp::dev::ReturnValue getAxes (size_t &axis) override
 Get the number of controlled axes.
 
yarp::dev::ReturnValue positionMove (int j, double ref) override
 Set new reference point for a single axis.
 
yarp::dev::ReturnValue positionMove (const int n_joint, const int *joints, const double *refs) override
 Set new reference point for a subset of joints.
 
yarp::dev::ReturnValue positionMove (const double *refs) override
 Set new reference point for all axes.
 
yarp::dev::ReturnValue relativeMove (int j, double delta) override
 Set relative position.
 
yarp::dev::ReturnValue relativeMove (const int n_joint, const int *joints, const double *deltas) override
 Set relative position for a subset of joints.
 
yarp::dev::ReturnValue relativeMove (const double *deltas) override
 Set relative position, all joints.
 
yarp::dev::ReturnValue checkMotionDone (bool &flag) override
 Check if the current trajectory is terminated.
 
yarp::dev::ReturnValue checkMotionDone (const std::vector< int > &joints, bool &flags) override
 Check if the current trajectory is terminated.
 
yarp::dev::ReturnValue checkMotionDone (int j, bool &flag) override
 Check if the current trajectory is terminated.
 
yarp::dev::ReturnValue setTrajSpeed (int j, double sp) override
 Set reference speed for a joint, this is the speed used during the interpolation of the trajectory.
 
yarp::dev::ReturnValue setTrajSpeeds (const int n_joint, const int *joints, const double *spds) override
 Set reference speed on all joints.
 
yarp::dev::ReturnValue setTrajSpeeds (const double *spds) override
 Set reference speed on all joints.
 
yarp::dev::ReturnValue setTrajAcceleration (int j, double acc) override
 Set reference acceleration for a joint.
 
yarp::dev::ReturnValue setTrajAccelerations (const int n_joint, const int *joints, const double *accs) override
 Set reference acceleration on all joints.
 
yarp::dev::ReturnValue setTrajAccelerations (const double *accs) override
 Set reference acceleration on all joints.
 
yarp::dev::ReturnValue getTrajSpeed (int j, double *ref) override
 Get reference speed for a joint.
 
yarp::dev::ReturnValue getTrajSpeeds (const int n_joint, const int *joints, double *spds) override
 Get reference speed of all joints.
 
yarp::dev::ReturnValue getTrajSpeeds (double *spds) override
 Get reference speed of all joints.
 
yarp::dev::ReturnValue getTrajAcceleration (int j, double *acc) override
 Get reference acceleration for a joint.
 
yarp::dev::ReturnValue getTrajAccelerations (const int n_joint, const int *joints, double *accs) override
 Get reference acceleration for a joint.
 
yarp::dev::ReturnValue getTrajAccelerations (double *accs) override
 Get reference acceleration of all joints.
 
yarp::dev::ReturnValue stop (int j) override
 Stop motion, single joint.
 
yarp::dev::ReturnValue stop (const int n_joint, const int *joints) override
 Stop motion for subset of joints.
 
yarp::dev::ReturnValue stop () override
 Stop motion, multiple joints.
 
yarp::dev::ReturnValue getTargetPosition (const int joint, double *ref) override
 Get the last position reference for the specified axis.
 
yarp::dev::ReturnValue getTargetPositions (double *refs) override
 Get the last position reference for all axes.
 
yarp::dev::ReturnValue getTargetPositions (const int n_joint, const int *joints, double *refs) override
 Get the last position reference for the specified group of axes.
 
- Public Member Functions inherited from yarp::dev::IPositionControl
virtual ~IPositionControl ()
 Destructor.
 

Protected Member Functions

bool initialize (int size, const int *amap, const double *enc, const double *zos)
 Initialize the internal data and alloc memory.
 
bool uninitialize ()
 Clean up internal data and memory.
 

Protected Attributes

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

Detailed Description

Default implementation of the IPositionControl interface.

This class can be used to easily provide an implementation of IPositionControl.

Definition at line 29 of file ImplementPositionControl.h.

Constructor & Destructor Documentation

◆ ImplementPositionControl()

ImplementPositionControl::ImplementPositionControl ( yarp::dev::IPositionControlRaw *  y)

Constructor.

Parameters
yis the pointer to the class instance inheriting from this implementation.

Definition at line 21 of file ImplementPositionControl.cpp.

◆ ~ImplementPositionControl()

ImplementPositionControl::~ImplementPositionControl ( )
virtual

Destructor.

Perform uninitialize if needed.

Definition at line 27 of file ImplementPositionControl.cpp.

Member Function Documentation

◆ checkMotionDone() [1/3]

ReturnValue ImplementPositionControl::checkMotionDone ( bool &  flag)
overridevirtual

Check if the current trajectory is terminated.

Non blocking.

Parameters
flagis a pointer to return value ("and" of all joints)
Returns
true/false on network communication (value you actually want is stored in *flag)

Implements yarp::dev::IPositionControl.

Definition at line 174 of file ImplementPositionControl.cpp.

◆ checkMotionDone() [2/3]

ReturnValue ImplementPositionControl::checkMotionDone ( const std::vector< int > &  joints,
bool &  flag 
)
overridevirtual

Check if the current trajectory is terminated.

Non blocking.

Parameters
jointsarray of joint numbers
flaglogical "and" of all set of joints
Returns
true/false if network communication went well.

Implements yarp::dev::IPositionControl.

Definition at line 160 of file ImplementPositionControl.cpp.

◆ checkMotionDone() [3/3]

ReturnValue ImplementPositionControl::checkMotionDone ( int  j,
bool &  flag 
)
overridevirtual

Check if the current trajectory is terminated.

Non blocking.

Parameters
jis the axis number
flagis a pointer to return value
Returns
true/false on network communication (value you actually want is stored in *flag)

Implements yarp::dev::IPositionControl.

Definition at line 150 of file ImplementPositionControl.cpp.

◆ getAxes()

ReturnValue ImplementPositionControl::getAxes ( size_t &  axis)
overridevirtual

Get the number of controlled axes.

This command asks the number of controlled axes for the current physical interface.

Returns
the number of controlled axes.

Implements yarp::dev::IPositionControl.

Definition at line 392 of file ImplementPositionControl.cpp.

◆ getTargetPosition()

ReturnValue ImplementPositionControl::getTargetPosition ( const int  joint,
double *  ref 
)
overridevirtual

Get the last position reference for the specified axis.

This is the dual of PositionMove and shall return only values sent using IPositionControl interface. If other interfaces like IPositionDirect are implemented by the device, this call must ignore their values, i.e. this call must never return a reference sent using IPositionDirect::SetPosition

Parameters
reflast reference sent using PositionMove functions
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 402 of file ImplementPositionControl.cpp.

◆ getTargetPositions() [1/2]

ReturnValue ImplementPositionControl::getTargetPositions ( const int  n_joint,
const int *  joints,
double *  refs 
)
overridevirtual

Get the last position reference for the specified group of axes.

This is the dual of PositionMove and shall return only values sent using IPositionControl interface. If other interfaces like IPositionDirect are implemented by the device, this call must ignore their values, i.e. this call must never return a reference sent using IPositionDirect::SetPosition

Parameters
reflast reference sent using PositionMove functions
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 429 of file ImplementPositionControl.cpp.

◆ getTargetPositions() [2/2]

ReturnValue ImplementPositionControl::getTargetPositions ( double *  refs)
overridevirtual

Get the last position reference for all axes.

This is the dual of PositionMove and shall return only values sent using IPositionControl interface. If other interfaces like IPositionDirect are implemented by the device, this call must ignore their values, i.e. this call must never return a reference sent using IPositionDirect::SetPosition

Parameters
reflast reference sent using PositionMove functions
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 418 of file ImplementPositionControl.cpp.

◆ getTrajAcceleration()

ReturnValue ImplementPositionControl::getTrajAcceleration ( int  j,
double *  acc 
)
overridevirtual

Get reference acceleration for a joint.

Returns the acceleration used to generate the trajectory profile.

Parameters
jjoint number
accpointer to storage for the return value
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 343 of file ImplementPositionControl.cpp.

◆ getTrajAccelerations() [1/2]

ReturnValue ImplementPositionControl::getTrajAccelerations ( const int  n_joint,
const int *  joints,
double *  accs 
)
overridevirtual

Get reference acceleration for a joint.

Returns the acceleration used to generate the trajectory profile.

Parameters
jointspointer to the array of joint numbers
accspointer to the array that will store the acceleration values
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 321 of file ImplementPositionControl.cpp.

◆ getTrajAccelerations() [2/2]

ReturnValue ImplementPositionControl::getTrajAccelerations ( double *  accs)
overridevirtual

Get reference acceleration of all joints.

These are the values used during the interpolation of the trajectory.

Parameters
accspointer to the array that will store the acceleration values.
Returns
true/false on success or failure

Implements yarp::dev::IPositionControl.

Definition at line 310 of file ImplementPositionControl.cpp.

◆ getTrajSpeed()

ReturnValue ImplementPositionControl::getTrajSpeed ( int  j,
double *  ref 
)
overridevirtual

Get reference speed for a joint.

Returns the speed used to generate the trajectory profile.

Parameters
jjoint number
refpointer to storage for the return value
Returns
true/false on success or failure

Implements yarp::dev::IPositionControl.

Definition at line 260 of file ImplementPositionControl.cpp.

◆ getTrajSpeeds() [1/2]

ReturnValue ImplementPositionControl::getTrajSpeeds ( const int  n_joint,
const int *  joints,
double *  spds 
)
overridevirtual

Get reference speed of all joints.

These are the values used during the interpolation of the trajectory.

Parameters
jointspointer to the array of joint numbers
spdspointer to the array that will store the speed values.
Returns
true/false upon success/failure

Implements yarp::dev::IPositionControl.

Definition at line 277 of file ImplementPositionControl.cpp.

◆ getTrajSpeeds() [2/2]

ReturnValue ImplementPositionControl::getTrajSpeeds ( double *  spds)
overridevirtual

Get reference speed of all joints.

These are the values used during the interpolation of the trajectory.

Parameters
spdspointer to the array that will store the speed values.

Implements yarp::dev::IPositionControl.

Definition at line 299 of file ImplementPositionControl.cpp.

◆ initialize()

bool ImplementPositionControl::initialize ( int  size,
const int *  amap,
const double *  enc,
const double *  zos 
)
protected

Initialize the internal data and alloc memory.

Allocate memory for internal data.

Parameters
sizeis the number of controlled axes the driver deals with.
amapis a lookup table mapping axes onto physical drivers.
encis an array containing the encoder to angles conversion factors.
zosis an array containing the zeros of the encoders. respect to the control/output values of the driver.
Returns
true if initialized succeeded, false if it wasn't executed, or assert.
Parameters
sizethe number of joints
amapaxis map for this device wrapper
encencoder conversion factor, from high level to hardware
zosoffset for setting the zero point. Units are relative to high level user interface (degrees)
Returns
true if uninitialization is executed, false otherwise.

Definition at line 40 of file ImplementPositionControl.cpp.

◆ positionMove() [1/3]

ReturnValue ImplementPositionControl::positionMove ( const double *  refs)
overridevirtual

Set new reference point for all axes.

Parameters
refsarray, new reference points.
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 98 of file ImplementPositionControl.cpp.

◆ positionMove() [2/3]

ReturnValue ImplementPositionControl::positionMove ( const int  n_joint,
const int *  joints,
const double *  refs 
)
overridevirtual

Set new reference point for a subset of joints.

Parameters
jointspointer to the array of joint numbers
refspointer to the array specifying the new reference points
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 81 of file ImplementPositionControl.cpp.

◆ positionMove() [3/3]

ReturnValue ImplementPositionControl::positionMove ( int  j,
double  ref 
)
overridevirtual

Set new reference point for a single axis.

Parameters
jjoint number
refspecifies the new ref point
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 70 of file ImplementPositionControl.cpp.

◆ relativeMove() [1/3]

ReturnValue ImplementPositionControl::relativeMove ( const double *  deltas)
overridevirtual

Set relative position, all joints.

Parameters
deltaspointer to the relative commands
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 139 of file ImplementPositionControl.cpp.

◆ relativeMove() [2/3]

ReturnValue ImplementPositionControl::relativeMove ( const int  n_joint,
const int *  joints,
const double *  deltas 
)
overridevirtual

Set relative position for a subset of joints.

Parameters
jointspointer to the array of joint numbers
deltaspointer to the array of relative commands
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 122 of file ImplementPositionControl.cpp.

◆ relativeMove() [3/3]

ReturnValue ImplementPositionControl::relativeMove ( int  j,
double  delta 
)
overridevirtual

Set relative position.

The command is relative to the current position of the axis.

Parameters
jjoint axis number
deltarelative command
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 110 of file ImplementPositionControl.cpp.

◆ setTrajAcceleration()

ReturnValue ImplementPositionControl::setTrajAcceleration ( int  j,
double  acc 
)
overridevirtual

Set reference acceleration for a joint.

This value is used during the trajectory generation.

Parameters
jjoint number
accacceleration value
Returns
true/false upon success/failure

Implements yarp::dev::IPositionControl.

Definition at line 219 of file ImplementPositionControl.cpp.

◆ setTrajAccelerations() [1/2]

ReturnValue ImplementPositionControl::setTrajAccelerations ( const double *  accs)
overridevirtual

Set reference acceleration on all joints.

This is the value that is used during the generation of the trajectory.

Parameters
accspointer to the array of acceleration values
Returns
true/false upon success/failure

Implements yarp::dev::IPositionControl.

Definition at line 248 of file ImplementPositionControl.cpp.

◆ setTrajAccelerations() [2/2]

ReturnValue ImplementPositionControl::setTrajAccelerations ( const int  n_joint,
const int *  joints,
const double *  accs 
)
overridevirtual

Set reference acceleration on all joints.

This is the value that is used during the generation of the trajectory.

Parameters
jointspointer to the array of joint numbers
accspointer to the array with acceleration values
Returns
true/false upon success/failure

Implements yarp::dev::IPositionControl.

Definition at line 231 of file ImplementPositionControl.cpp.

◆ setTrajSpeed()

ReturnValue ImplementPositionControl::setTrajSpeed ( int  j,
double  sp 
)
overridevirtual

Set reference speed for a joint, this is the speed used during the interpolation of the trajectory.

Parameters
jjoint number
spspeed value
Returns
true/false upon success/failure

Implements yarp::dev::IPositionControl.

Definition at line 181 of file ImplementPositionControl.cpp.

◆ setTrajSpeeds() [1/2]

ReturnValue ImplementPositionControl::setTrajSpeeds ( const double *  spds)
overridevirtual

Set reference speed on all joints.

These values are used during the interpolation of the trajectory.

Parameters
spdspointer to the array of speed values.
Returns
true/false upon success/failure

Implements yarp::dev::IPositionControl.

Definition at line 208 of file ImplementPositionControl.cpp.

◆ setTrajSpeeds() [2/2]

ReturnValue ImplementPositionControl::setTrajSpeeds ( const int  n_joint,
const int *  joints,
const double *  spds 
)
overridevirtual

Set reference speed on all joints.

These values are used during the interpolation of the trajectory.

Parameters
jointspointer to the array of joint numbers
spdspointer to the array with speed values.
Returns
true/false upon success/failure

Implements yarp::dev::IPositionControl.

Definition at line 192 of file ImplementPositionControl.cpp.

◆ stop() [1/3]

ReturnValue ImplementPositionControl::stop ( )
overridevirtual

Stop motion, multiple joints.

Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 385 of file ImplementPositionControl.cpp.

◆ stop() [2/3]

ReturnValue ImplementPositionControl::stop ( const int  n_joint,
const int *  joints 
)
overridevirtual

Stop motion for subset of joints.

Parameters
jointspointer to the array of joint numbers
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 370 of file ImplementPositionControl.cpp.

◆ stop() [3/3]

ReturnValue ImplementPositionControl::stop ( int  j)
overridevirtual

Stop motion, single joint.

Parameters
jjoint number
Returns
true/false on success/failure

Implements yarp::dev::IPositionControl.

Definition at line 359 of file ImplementPositionControl.cpp.

◆ uninitialize()

bool ImplementPositionControl::uninitialize ( )
protected

Clean up internal data and memory.

Returns
true if uninitialization is executed, false otherwise.

Definition at line 59 of file ImplementPositionControl.cpp.

Member Data Documentation

◆ m_buffer_doubles

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

Definition at line 35 of file ImplementPositionControl.h.

◆ m_buffer_ints

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

Definition at line 34 of file ImplementPositionControl.h.

◆ m_helper

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

Definition at line 33 of file ImplementPositionControl.h.

◆ m_imp_mutex

std::mutex yarp::dev::ImplementPositionControl::m_imp_mutex
protected

Definition at line 36 of file ImplementPositionControl.h.

◆ m_iraw

IPositionControlRaw* yarp::dev::ImplementPositionControl::m_iraw =nullptr
protected

Definition at line 32 of file ImplementPositionControl.h.


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