YARP CiA-402 EtherCAT Device 0.6.0
YARP device plugin for EtherCAT CiA-402 drives
Loading...
Searching...
No Matches
yarp::dev::CiA402MotionControl::Impl Struct Reference
Collaboration diagram for yarp::dev::CiA402MotionControl::Impl:
[legend]

Classes

struct  Limits
struct  VariablesReadFromMotors
struct  ControlModeState
struct  SetPoints
struct  PositionProfileState

Public Types

enum class  PosSrc { S6064 , Enc1 , Enc2 }
enum class  VelSrc { S606C , Enc1 , Enc2 }
enum class  Mount { None , Motor , Joint }
enum class  SensorSrc { Unknown , Enc1 , Enc2 }

Public Member Functions

 Impl ()=default
 ~Impl ()=default
int32_t jointDegToTargetCounts (size_t j, double jointDeg) const
double targetCountsToJointDeg (size_t j, int32_t counts) const
bool setPositionCountsLimits (int axis, int32_t minCounts, int32_t maxCounts)
bool readEncoderResolutions ()
bool readSiVelocityUnits ()
double loopCountsToJointDeg (std::size_t j, double counts) const
bool setPositionWindowDeg (int j, double winDeg, double winTime_ms)
bool getPositionControlStrategy (uint16_t &strategyValue)
bool setPositionControlStrategy (uint16_t strategyValue)
bool readSimplePidGains (std::vector< double > &kpNmPerDeg, std::vector< double > &kdNmSecPerDeg)
bool configureSimplePidGains (const std::vector< double > &kpNmPerDeg, const std::vector< double > &kdNmSecPerDeg)
bool readMotorConstants ()
bool readGearRatios ()
bool readTorqueValues ()
bool configureMaxTorqueFromJointNm (const std::vector< double > &maxJointTorqueNm)
void setSDORefSpeed (int j, double spDegS)
bool setSetPoints ()
bool readFeedback ()
int ciaOpToYarpWithFlavor (int op, int cstFlavor)
std::string describe603F (uint16_t code)

Static Public Member Functions

static std::tuple< double, double, const char * > decode60A9 (uint32_t v)
static int yarpToCiaOp (int cm)
static int ciaOpToYarp (int op)
static std::string_view yarpToString (int op)

Public Attributes

::CiA402::EthercatManager ethercatManager
std::mutex CiA402MotionControlMutex
size_t numAxes {0}
int firstSlave {1}
std::string expectedName {}
std::vector< double > gearRatio
std::vector< double > gearRatioInv
std::vector< double > torqueConstants
std::vector< double > maxCurrentsA
std::vector< double > ratedMotorTorqueNm
std::vector< double > maxMotorTorqueNm
std::vector< uint32_t > enc1Res
std::vector< uint32_t > enc2Res
std::vector< double > enc1ResInv
std::vector< double > enc2ResInv
std::vector< Mount > enc1Mount
std::vector< Mount > enc2Mount
std::vector< PosSrc > posSrcJoint
std::vector< PosSrc > posSrcMotor
std::vector< VelSrc > velSrcJoint
std::vector< VelSrc > velSrcMotor
std::vector< SensorSrc > posLoopSrc
std::vector< SensorSrc > velLoopSrc
std::vector< double > velToDegS
std::vector< double > degSToVel
std::vector< bool > invertedMotionSenseDirection
struct yarp::dev::CiA402MotionControl::Impl::Limits limits
VariablesReadFromMotors variables
ControlModeState controlModeState
SetPoints setPoints
std::vector< std::unique_ptr< CiA402::StateMachine > > sm
std::vector< bool > velLatched
std::vector< bool > trqLatched
std::vector< bool > currLatched
std::vector< bool > posLatched
std::vector< double > torqueSeedNm
std::vector< int > lastActiveMode
std::vector< uint32_t > tsLastRaw
std::vector< uint64_t > tsWraps
PositionProfileState ppState
bool opRequested {false}
std::chrono::steady_clock::time_point avgWindowStart {std::chrono::steady_clock::now()}
double runTimeAccumSec {0.0}
std::size_t runTimeSamples {0}
yarp::dev::InteractionModeEnum dummyInteractionMode

Static Public Attributes

static constexpr std::string_view kClassName = "CiA402MotionControl"
static constexpr double MICROSECONDS_TO_SECONDS = 1e-6
static constexpr uint64_t TIMESTAMP_WRAP_PERIOD_US = (((uint64_t)1 << 32) - 1) / 100 + 1
static constexpr uint32_t TIMESTAMP_WRAP_HALF_RANGE = TIMESTAMP_WRAP_PERIOD_US / 2

Detailed Description

Private implementation holding configuration, runtime state, and helpers. Concurrency:

  • variables.mutex guards feedback snapshots returned to YARP APIs
  • controlModeState.mutex guards target/active control modes
  • setPoints.mutex guards user setpoints and their first‑cycle latches Units:
  • Positions: degrees (joint and motor)
  • Velocities: degrees/second
  • Torques: joint Nm (converted to motor Nm and then to per‑thousand for PDOs)

Definition at line 40 of file CiA402MotionControl.cpp.

Member Enumeration Documentation

◆ Mount

Enumerator
None 
Motor 
Joint 

Definition at line 56 of file CiA402MotionControl.cpp.

◆ PosSrc

Enumerator
S6064 
Enc1 
Enc2 

Definition at line 42 of file CiA402MotionControl.cpp.

◆ SensorSrc

Enumerator
Unknown 
Enc1 
Enc2 

Definition at line 63 of file CiA402MotionControl.cpp.

◆ VelSrc

Enumerator
S606C 
Enc1 
Enc2 

Definition at line 49 of file CiA402MotionControl.cpp.

Constructor & Destructor Documentation

◆ Impl()

yarp::dev::CiA402MotionControl::Impl::Impl ( )
default

◆ ~Impl()

yarp::dev::CiA402MotionControl::Impl::~Impl ( )
default

Member Function Documentation

◆ ciaOpToYarp()

int yarp::dev::CiA402MotionControl::Impl::ciaOpToYarp ( int op)
inlinestatic

Definition at line 1676 of file CiA402MotionControl.cpp.

◆ ciaOpToYarpWithFlavor()

int yarp::dev::CiA402MotionControl::Impl::ciaOpToYarpWithFlavor ( int op,
int cstFlavor )
inline

Definition at line 1667 of file CiA402MotionControl.cpp.

◆ configureMaxTorqueFromJointNm()

bool yarp::dev::CiA402MotionControl::Impl::configureMaxTorqueFromJointNm ( const std::vector< double > & maxJointTorqueNm)
inline

Definition at line 1007 of file CiA402MotionControl.cpp.

◆ configureSimplePidGains()

bool yarp::dev::CiA402MotionControl::Impl::configureSimplePidGains ( const std::vector< double > & kpNmPerDeg,
const std::vector< double > & kdNmSecPerDeg )
inline

Definition at line 732 of file CiA402MotionControl.cpp.

◆ decode60A9()

std::tuple< double, double, const char * > yarp::dev::CiA402MotionControl::Impl::decode60A9 ( uint32_t v)
inlinestatic

Definition at line 473 of file CiA402MotionControl.cpp.

◆ describe603F()

std::string yarp::dev::CiA402MotionControl::Impl::describe603F ( uint16_t code)
inline

Decode CiA 402 error code (0x603F:00) into a human‑readable string. Includes explicit vendor codes seen in the field and broader family fallbacks.

Definition at line 1726 of file CiA402MotionControl.cpp.

◆ getPositionControlStrategy()

bool yarp::dev::CiA402MotionControl::Impl::getPositionControlStrategy ( uint16_t & strategyValue)
inline

Definition at line 627 of file CiA402MotionControl.cpp.

◆ jointDegToTargetCounts()

int32_t yarp::dev::CiA402MotionControl::Impl::jointDegToTargetCounts ( size_t j,
double jointDeg ) const
inline

Definition at line 307 of file CiA402MotionControl.cpp.

◆ loopCountsToJointDeg()

double yarp::dev::CiA402MotionControl::Impl::loopCountsToJointDeg ( std::size_t j,
double counts ) const
inline

Definition at line 537 of file CiA402MotionControl.cpp.

◆ readEncoderResolutions()

bool yarp::dev::CiA402MotionControl::Impl::readEncoderResolutions ( )
inline

Definition at line 429 of file CiA402MotionControl.cpp.

◆ readFeedback()

bool yarp::dev::CiA402MotionControl::Impl::readFeedback ( )
inline

Definition at line 1363 of file CiA402MotionControl.cpp.

◆ readGearRatios()

bool yarp::dev::CiA402MotionControl::Impl::readGearRatios ( )
inline

Read the gear-ratio (motor-revs : load-revs) for every axis and cache both the ratio and its inverse.

0x6091:01 numerator (UNSIGNED32, default 1) 0x6091:02 denominator (UNSIGNED32, default 1)

If the object is missing or invalid the code silently falls back to 1:1.

Definition at line 907 of file CiA402MotionControl.cpp.

◆ readMotorConstants()

bool yarp::dev::CiA402MotionControl::Impl::readMotorConstants ( )
inline

Definition at line 827 of file CiA402MotionControl.cpp.

◆ readSimplePidGains()

bool yarp::dev::CiA402MotionControl::Impl::readSimplePidGains ( std::vector< double > & kpNmPerDeg,
std::vector< double > & kdNmSecPerDeg )
inline

Definition at line 679 of file CiA402MotionControl.cpp.

◆ readSiVelocityUnits()

bool yarp::dev::CiA402MotionControl::Impl::readSiVelocityUnits ( )
inline

Definition at line 499 of file CiA402MotionControl.cpp.

◆ readTorqueValues()

bool yarp::dev::CiA402MotionControl::Impl::readTorqueValues ( )
inline

Definition at line 965 of file CiA402MotionControl.cpp.

◆ setPositionControlStrategy()

bool yarp::dev::CiA402MotionControl::Impl::setPositionControlStrategy ( uint16_t strategyValue)
inline

Definition at line 650 of file CiA402MotionControl.cpp.

◆ setPositionCountsLimits()

bool yarp::dev::CiA402MotionControl::Impl::setPositionCountsLimits ( int axis,
int32_t minCounts,
int32_t maxCounts )
inline

Definition at line 394 of file CiA402MotionControl.cpp.

◆ setPositionWindowDeg()

bool yarp::dev::CiA402MotionControl::Impl::setPositionWindowDeg ( int j,
double winDeg,
double winTime_ms )
inline

Definition at line 583 of file CiA402MotionControl.cpp.

◆ setSDORefSpeed()

void yarp::dev::CiA402MotionControl::Impl::setSDORefSpeed ( int j,
double spDegS )
inline

Definition at line 1085 of file CiA402MotionControl.cpp.

◆ setSetPoints()

bool yarp::dev::CiA402MotionControl::Impl::setSetPoints ( )
inline

Push user setpoints into RxPDOs according to the active control mode.

  • Torque (CST): joint Nm → motor Nm → per‑thousand of rated motor torque (0x6071)
  • Velocity (CSV): joint deg/s → loop‑shaft deg/s (mount aware) → rpm (0x60FF) First‑cycle latches (velLatched/trqLatched) zero the command once when entering.

Definition at line 1119 of file CiA402MotionControl.cpp.

◆ targetCountsToJointDeg()

double yarp::dev::CiA402MotionControl::Impl::targetCountsToJointDeg ( size_t j,
int32_t counts ) const
inline

Definition at line 350 of file CiA402MotionControl.cpp.

◆ yarpToCiaOp()

int yarp::dev::CiA402MotionControl::Impl::yarpToCiaOp ( int cm)
inlinestatic

Definition at line 1642 of file CiA402MotionControl.cpp.

◆ yarpToString()

std::string_view yarp::dev::CiA402MotionControl::Impl::yarpToString ( int op)
inlinestatic

Definition at line 1698 of file CiA402MotionControl.cpp.

Member Data Documentation

◆ avgWindowStart

std::chrono::steady_clock::time_point yarp::dev::CiA402MotionControl::Impl::avgWindowStart {std::chrono::steady_clock::now()}

Definition at line 294 of file CiA402MotionControl.cpp.

◆ CiA402MotionControlMutex

std::mutex yarp::dev::CiA402MotionControl::Impl::CiA402MotionControlMutex

Definition at line 77 of file CiA402MotionControl.cpp.

◆ controlModeState

ControlModeState yarp::dev::CiA402MotionControl::Impl::controlModeState

Definition at line 181 of file CiA402MotionControl.cpp.

◆ currLatched

std::vector<bool> yarp::dev::CiA402MotionControl::Impl::currLatched

Definition at line 273 of file CiA402MotionControl.cpp.

◆ degSToVel

std::vector<double> yarp::dev::CiA402MotionControl::Impl::degSToVel

Definition at line 112 of file CiA402MotionControl.cpp.

◆ dummyInteractionMode

yarp::dev::InteractionModeEnum yarp::dev::CiA402MotionControl::Impl::dummyInteractionMode
Initial value:
{
yarp::dev::InteractionModeEnum::VOCAB_IM_STIFF}

Dummy interaction mode for all the joints

Definition at line 299 of file CiA402MotionControl.cpp.

◆ enc1Mount

std::vector<Mount> yarp::dev::CiA402MotionControl::Impl::enc1Mount

Definition at line 106 of file CiA402MotionControl.cpp.

◆ enc1Res

std::vector<uint32_t> yarp::dev::CiA402MotionControl::Impl::enc1Res

Definition at line 104 of file CiA402MotionControl.cpp.

◆ enc1ResInv

std::vector<double> yarp::dev::CiA402MotionControl::Impl::enc1ResInv

Definition at line 105 of file CiA402MotionControl.cpp.

◆ enc2Mount

std::vector<Mount> yarp::dev::CiA402MotionControl::Impl::enc2Mount

Definition at line 106 of file CiA402MotionControl.cpp.

◆ enc2Res

std::vector<uint32_t> yarp::dev::CiA402MotionControl::Impl::enc2Res

Definition at line 104 of file CiA402MotionControl.cpp.

◆ enc2ResInv

std::vector<double> yarp::dev::CiA402MotionControl::Impl::enc2ResInv

Definition at line 105 of file CiA402MotionControl.cpp.

◆ ethercatManager

::CiA402::EthercatManager yarp::dev::CiA402MotionControl::Impl::ethercatManager

Definition at line 74 of file CiA402MotionControl.cpp.

◆ expectedName

std::string yarp::dev::CiA402MotionControl::Impl::expectedName {}

Definition at line 93 of file CiA402MotionControl.cpp.

◆ firstSlave

int yarp::dev::CiA402MotionControl::Impl::firstSlave {1}

Definition at line 92 of file CiA402MotionControl.cpp.

◆ gearRatio

std::vector<double> yarp::dev::CiA402MotionControl::Impl::gearRatio

Definition at line 98 of file CiA402MotionControl.cpp.

◆ gearRatioInv

std::vector<double> yarp::dev::CiA402MotionControl::Impl::gearRatioInv

Definition at line 99 of file CiA402MotionControl.cpp.

◆ invertedMotionSenseDirection

std::vector<bool> yarp::dev::CiA402MotionControl::Impl::invertedMotionSenseDirection

Definition at line 113 of file CiA402MotionControl.cpp.

◆ kClassName

std::string_view yarp::dev::CiA402MotionControl::Impl::kClassName = "CiA402MotionControl"
staticconstexpr

Definition at line 71 of file CiA402MotionControl.cpp.

◆ lastActiveMode

std::vector<int> yarp::dev::CiA402MotionControl::Impl::lastActiveMode

Definition at line 276 of file CiA402MotionControl.cpp.

◆ limits

struct yarp::dev::CiA402MotionControl::Impl::Limits yarp::dev::CiA402MotionControl::Impl::limits

◆ maxCurrentsA

std::vector<double> yarp::dev::CiA402MotionControl::Impl::maxCurrentsA

Definition at line 101 of file CiA402MotionControl.cpp.

◆ maxMotorTorqueNm

std::vector<double> yarp::dev::CiA402MotionControl::Impl::maxMotorTorqueNm

Definition at line 103 of file CiA402MotionControl.cpp.

◆ MICROSECONDS_TO_SECONDS

double yarp::dev::CiA402MotionControl::Impl::MICROSECONDS_TO_SECONDS = 1e-6
staticconstexpr

Definition at line 80 of file CiA402MotionControl.cpp.

◆ numAxes

size_t yarp::dev::CiA402MotionControl::Impl::numAxes {0}

Definition at line 91 of file CiA402MotionControl.cpp.

◆ opRequested

bool yarp::dev::CiA402MotionControl::Impl::opRequested {false}

Definition at line 291 of file CiA402MotionControl.cpp.

◆ posLatched

std::vector<bool> yarp::dev::CiA402MotionControl::Impl::posLatched

Definition at line 274 of file CiA402MotionControl.cpp.

◆ posLoopSrc

std::vector<SensorSrc> yarp::dev::CiA402MotionControl::Impl::posLoopSrc

Definition at line 109 of file CiA402MotionControl.cpp.

◆ posSrcJoint

std::vector<PosSrc> yarp::dev::CiA402MotionControl::Impl::posSrcJoint

Definition at line 107 of file CiA402MotionControl.cpp.

◆ posSrcMotor

std::vector<PosSrc> yarp::dev::CiA402MotionControl::Impl::posSrcMotor

Definition at line 107 of file CiA402MotionControl.cpp.

◆ ppState

PositionProfileState yarp::dev::CiA402MotionControl::Impl::ppState

Definition at line 289 of file CiA402MotionControl.cpp.

◆ ratedMotorTorqueNm

std::vector<double> yarp::dev::CiA402MotionControl::Impl::ratedMotorTorqueNm

Definition at line 102 of file CiA402MotionControl.cpp.

◆ runTimeAccumSec

double yarp::dev::CiA402MotionControl::Impl::runTimeAccumSec {0.0}

Definition at line 295 of file CiA402MotionControl.cpp.

◆ runTimeSamples

std::size_t yarp::dev::CiA402MotionControl::Impl::runTimeSamples {0}

Definition at line 296 of file CiA402MotionControl.cpp.

◆ setPoints

SetPoints yarp::dev::CiA402MotionControl::Impl::setPoints

Definition at line 267 of file CiA402MotionControl.cpp.

◆ sm

std::vector<std::unique_ptr<CiA402::StateMachine> > yarp::dev::CiA402MotionControl::Impl::sm

Definition at line 270 of file CiA402MotionControl.cpp.

◆ TIMESTAMP_WRAP_HALF_RANGE

uint32_t yarp::dev::CiA402MotionControl::Impl::TIMESTAMP_WRAP_HALF_RANGE = TIMESTAMP_WRAP_PERIOD_US / 2
staticconstexpr

Definition at line 88 of file CiA402MotionControl.cpp.

◆ TIMESTAMP_WRAP_PERIOD_US

uint64_t yarp::dev::CiA402MotionControl::Impl::TIMESTAMP_WRAP_PERIOD_US = (((uint64_t)1 << 32) - 1) / 100 + 1
staticconstexpr

Definition at line 84 of file CiA402MotionControl.cpp.

◆ torqueConstants

std::vector<double> yarp::dev::CiA402MotionControl::Impl::torqueConstants

Definition at line 100 of file CiA402MotionControl.cpp.

◆ torqueSeedNm

std::vector<double> yarp::dev::CiA402MotionControl::Impl::torqueSeedNm

Definition at line 275 of file CiA402MotionControl.cpp.

◆ trqLatched

std::vector<bool> yarp::dev::CiA402MotionControl::Impl::trqLatched

Definition at line 273 of file CiA402MotionControl.cpp.

◆ tsLastRaw

std::vector<uint32_t> yarp::dev::CiA402MotionControl::Impl::tsLastRaw

Definition at line 279 of file CiA402MotionControl.cpp.

◆ tsWraps

std::vector<uint64_t> yarp::dev::CiA402MotionControl::Impl::tsWraps

Definition at line 280 of file CiA402MotionControl.cpp.

◆ variables

VariablesReadFromMotors yarp::dev::CiA402MotionControl::Impl::variables

Definition at line 163 of file CiA402MotionControl.cpp.

◆ velLatched

std::vector<bool> yarp::dev::CiA402MotionControl::Impl::velLatched

Definition at line 273 of file CiA402MotionControl.cpp.

◆ velLoopSrc

std::vector<SensorSrc> yarp::dev::CiA402MotionControl::Impl::velLoopSrc

Definition at line 110 of file CiA402MotionControl.cpp.

◆ velSrcJoint

std::vector<VelSrc> yarp::dev::CiA402MotionControl::Impl::velSrcJoint

Definition at line 108 of file CiA402MotionControl.cpp.

◆ velSrcMotor

std::vector<VelSrc> yarp::dev::CiA402MotionControl::Impl::velSrcMotor

Definition at line 108 of file CiA402MotionControl.cpp.

◆ velToDegS

std::vector<double> yarp::dev::CiA402MotionControl::Impl::velToDegS

Definition at line 111 of file CiA402MotionControl.cpp.


The documentation for this struct was generated from the following file: