17#include <yarp/os/Bottle.h>
18#include <yarp/os/Time.h>
21#include <FeatureInterface.h>
22#include <yarp/conf/environment.h>
24#include <yarp/os/LogStream.h>
26#include <yarp/os/NetType.h>
27#include <yarp/dev/ControlBoardHelper.h>
32#include "EoProtocol.h"
33#include "EoProtocolMN.h"
34#include "EoProtocolMC.h"
35#include "EoProtocolAS.h"
41using namespace yarp::os;
42using namespace yarp::os::impl;
50#define ASK_REFERENCE_TO_FIRMWARE 1
52#define PARSER_MOTION_CONTROL_VERSION 6
57 yError() << txt <<
" is not yet implemented for embObjMotionControl";
63 yError() << txt <<
" has been deprecated for embObjMotionControl";
67#define NV_NOT_FOUND return nv_not_found();
71 yError () <<
" nv_not_found!! This may mean that this variable is not handled by this EMS\n";
77std::string embObjMotionControl::getBoardInfo(
void)
81 return " BOARD name_unknown (IP unknown) ";
90bool embObjMotionControl::alloc(
int nj)
92 _axisMap = allocAndCheck<int>(nj);
94 _encodersStamp = allocAndCheck<double>(nj);
95 _gearbox_M2J = allocAndCheck<double>(nj);
96 _gearbox_E2J = allocAndCheck<double>(nj);
97 _deadzone = allocAndCheck<double>(nj);
98 _foc_based_info= allocAndCheck<eomc::focBasedSpecificInfo_t>(nj);
104 _impedance_limits=allocAndCheck<eomc::impedanceLimits_t>(nj);
105 checking_motiondone=allocAndCheck<bool>(nj);
106 _last_position_move_time=allocAndCheck<double>(nj);
109 _ref_command_positions = allocAndCheck<double>(nj);
110 _ref_positions = allocAndCheck<double>(nj);
111 _ref_command_speeds = allocAndCheck<double>(nj);
112 _ref_speeds = allocAndCheck<double>(nj);
113 _ref_accs = allocAndCheck<double>(nj);
115 _enabledAmp = allocAndCheck<bool>(nj);
116 _enabledPid = allocAndCheck<bool>(nj);
117 _calibrated = allocAndCheck<bool>(nj);
118 _cacheImpedance = allocAndCheck<eOmc_impedance_t>(nj);
120 _rotorsLimits.resize(nj);
121 _jointsLimits.resize(nj);
122 _currentLimits.resize(nj);
123 _temperatureLimits.resize(nj);
125 _joint2set.resize(nj);
126 _timeouts.resize(nj);
127 _impedance_params.resize(nj);
128 _lugre_params.resize(nj);
129 _axesInfo.resize(nj);
130 _jointEncs.resize(nj);
131 _motorEncs.resize(nj);
132 _kalman_params.resize(nj);
133 _temperatureSensorsVector.resize(nj);
134 _temperatureExceededLimitWatchdog.resize(nj);
135 _temperatureSensorErrorWatchdog.resize(nj);
136 _temperatureSpikesFilter.resize(nj);
140 for(
int i = 0; i < nj; ++i)
142 _temperatureExceededLimitWatchdog.at(i).setThreshold(txrate);
143 _temperatureSensorErrorWatchdog.at(i).setThreshold(txrate);
149bool embObjMotionControl::dealloc()
151 checkAndDestroy(_axisMap);
152 checkAndDestroy(_encodersStamp);
153 checkAndDestroy(_gearbox_M2J);
154 checkAndDestroy(_gearbox_E2J);
155 checkAndDestroy(_deadzone);
156 checkAndDestroy(_impedance_limits);
157 checkAndDestroy(checking_motiondone);
158 checkAndDestroy(_ref_command_positions);
159 checkAndDestroy(_ref_positions);
160 checkAndDestroy(_ref_command_speeds);
161 checkAndDestroy(_ref_speeds);
162 checkAndDestroy(_ref_accs);
164 checkAndDestroy(_enabledAmp);
165 checkAndDestroy(_enabledPid);
166 checkAndDestroy(_calibrated);
167 checkAndDestroy(_foc_based_info);
189 ImplementControlCalibration(this),
190 ImplementAmplifierControl(this),
191 ImplementPidControl(this),
192 ImplementEncodersTimed(this),
193 ImplementPositionControl(this),
194 ImplementVelocityControl(this),
195 ImplementControlMode(this),
196 ImplementImpedanceControl(this),
197 ImplementMotorEncoders(this),
198#ifdef IMPLEMENT_DEBUG_INTERFACE
201 ImplementTorqueControl(this),
202 ImplementControlLimits(this),
203 ImplementPositionDirect(this),
204 ImplementInteractionMode(this),
205 ImplementMotor(this),
206 ImplementRemoteVariables(this),
207 ImplementAxisInfo(this),
208 ImplementPWMControl(this),
209 ImplementCurrentControl(this),
210 ImplementJointFault(this),
211 SAFETY_THRESHOLD(2.0),
215 _temperatureLimits(0),
219 _impedance_params(0),
225 _temperatureSensorsVector(0),
226 _temperatureExceededLimitWatchdog(0),
227 _temperatureSensorErrorWatchdog(0),
228 _temperatureSpikesFilter(0),
229 _rawDataAuxVector(0),
230 _rawValuesMetadataMap({})
244 _encodersStamp = NULL;
245 _foc_based_info = NULL;
246 _cacheImpedance = NULL;
247 _impedance_limits = NULL;
249 _ref_command_speeds = NULL;
250 _ref_command_positions= NULL;
251 _ref_positions = NULL;
253 _measureConverter = NULL;
255 checking_motiondone = NULL;
266 _last_position_move_time = NULL;
268 behFlags.useRawEncoderData =
false;
269 behFlags.pwmIsLimited =
false;
271 std::string tmp = yarp::conf::environment::get_string(
"ETH_VERBOSEWHENOK");
274 behFlags.verbosewhenok = (bool)yarp::conf::numeric::from_string(tmp, 0U);
278 behFlags.verbosewhenok =
false;
283#ifdef NETWORK_PERFORMANCE_BENCHMARK
287 m_responseTimingVerifier.init(0.003, 0.00025, 0.001, 0.01, 0.0005, 30);
295 yTrace() <<
"embObjMotionControl::~embObjMotionControl()";
303 if(NULL != _mcparser)
321 ImplementControlCalibration::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
322 ImplementAmplifierControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.ampsToSensor);
323 ImplementEncodersTimed::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
324 ImplementMotorEncoders::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
325 ImplementPositionControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
326 ImplementPidControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.newtonsToSensor,
f.ampsToSensor,
f.dutycycleToPWM);
327 ImplementControlMode::initialize(_njoints, _axisMap);
328 ImplementVelocityControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
329 ImplementControlLimits::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
330 ImplementImpedanceControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.newtonsToSensor);
331 ImplementTorqueControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.newtonsToSensor,
f.ampsToSensor,
f.dutycycleToPWM,
f.bemf2raw,
f.ktau2raw);
332 ImplementPositionDirect::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
333 ImplementInteractionMode::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
334 ImplementMotor::initialize(_njoints, _axisMap);
335 ImplementRemoteVariables::initialize(_njoints, _axisMap);
336 ImplementAxisInfo::initialize(_njoints, _axisMap);
337 ImplementCurrentControl::initialize(_njoints, _axisMap,
f.ampsToSensor);
338 ImplementPWMControl::initialize(_njoints, _axisMap,
f.dutycycleToPWM);
339 ImplementJointFault::initialize(_njoints, _axisMap);
350 if(NULL == ethManager)
352 yFatal() <<
"embObjMotionControl::open() fails to instantiate ethManager";
356 eOipv4addr_t ipv4addr;
357 string boardIPstring;
359 if(
false == ethManager->
verifyEthBoardInfo(config, ipv4addr, boardIPstring, boardName))
361 yError() <<
"embObjMotionControl::open(): object TheEthManager fails in parsing ETH propertiex from xml file";
380 yError() <<
"embObjMotionControl::open() fails because could not instantiate the ethResource for " << getBoardInfo() <<
" ... unable to continue";
384 if(!fromConfig(config))
386 yError() << getBoardInfo() <<
"Missing motion control parameters in config file";
392 yError() <<
"embObjMotionControl: failed verifyEPprotocol. Cannot continue!";
398 const eOmn_serv_parameter_t* servparam = &serviceConfig.
ethservice;
399 if(eomn_serv_MC_generic == serviceConfig.
ethservice.configuration.type)
405 mcdiagnostics.
config.mode = serviceConfig.
ethservice.configuration.diagnosticsmode;
406 mcdiagnostics.
config.par16 = serviceConfig.
ethservice.configuration.diagnosticsparam;
407 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
410 mcdiagnostics.
ports.resize(2);
411 for(
size_t i=0; i<mcdiagnostics.
ports.size(); i++)
413 mcdiagnostics.
ports[i] =
new BufferedPort<Bottle>;
424 event_downsampler->
config.
info = getBoardInfo();
425 event_downsampler->
start();
429 yError() <<
"embObjMotionControl::open() has an error in call of ethResources::serviceVerifyActivate() for" << getBoardInfo();
434 yDebug() <<
"embObjMotionControl:serviceVerifyActivate OK!";
439 yError() <<
"embObjMotionControl::open() has an error in call of embObjMotionControl::init() for" << getBoardInfo();
446 yDebug() <<
"embObjMotionControl::init() has succesfully initted" << getBoardInfo();
453 yError() <<
"embObjMotionControl::open() fails to start mc service for" << getBoardInfo() <<
": cannot continue";
461 yDebug() <<
"embObjMotionControl::open() correctly starts mc service of" << getBoardInfo();
469 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
500 SystemClock::delaySystem(0.001*mcdiagnostics.
config.par16);
507int embObjMotionControl::fromConfig_NumOfJoints(yarp::os::Searchable &config)
512 int jn = config.findGroup(
"GENERAL").check(
"Joints", Value(1),
"Number of degrees of freedom").asInt32();
519void embObjMotionControl::debugUtil_printJointsetInfo(
void)
522 yError() <<
"****** DEBUG PRINTS **********";
523 yError() <<
"joint to set:";
524 for(
int x=0;
x< _njoints;
x++)
525 yError() <<
" /t j " <<
x <<
": set " <<_joint2set[
x];
526 yError() <<
"jointmap:";
528 yError() <<
" number of sets" << _jsets.size();
529 for(
size_t x=0;
x< _jsets.size();
x++)
531 yError() <<
"set " <<
x<<
"has size " <<_jsets[
x].getNumberofJoints();
532 for(
int y=0;
y<_jsets[
x].getNumberofJoints();
y++)
533 yError() <<
"set " <<
x <<
": " << _jsets[
x].joints[
y];
535 yError() <<
"********* END ****************";
542bool embObjMotionControl::verifyUserControlLawConsistencyInJointSet(
eomc::PidInfo *pidInfo)
545 for(
size_t s=0; s<_jsets.size(); s++)
547 int numofjoints = _jsets[s].getNumberofJoints();
551 yError() <<
"embObjMC" << getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
554 int firstjoint = _jsets[s].joints[0];
556 for(
int k=1; k<numofjoints; k++)
558 int otherjoint = _jsets[s].joints[k];
560 if(pidInfo[firstjoint].usernamePidSelected != pidInfo[otherjoint].usernamePidSelected)
562 yError() <<
"embObjMC "<< getBoardInfo() <<
"Joints beloning to same set must be have same control law. Joint " << otherjoint <<
" differs from " << firstjoint <<
"Set num " << s ;
575bool embObjMotionControl::verifyUserControlLawConsistencyInJointSet(
eomc::TrqPidInfo *pidInfo)
577 for(
size_t s=0; s<_jsets.size(); s++)
579 int numofjoints = _jsets[s].getNumberofJoints();
583 yError() <<
"embObjMC "<< getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
586 int firstjoint = _jsets[s].joints[0];
588 for(
int k=1; k<numofjoints; k++)
590 int otherjoint = _jsets[s].joints[k];
592 if(pidInfo[firstjoint].usernamePidSelected != pidInfo[otherjoint].usernamePidSelected)
594 yError() <<
"embObjMC"<< getBoardInfo() <<
"Joints beloning to same set must be have same control law. Joint " << otherjoint <<
" differs from " << firstjoint <<
"Set num " << s ;
604bool embObjMotionControl::updatedJointsetsCfgWithControlInfo()
608 for(
size_t s=0; s<_jsets.size(); s++)
610 if(_jsets[s].getNumberofJoints() == 0)
612 yError() <<
"embObjMC"<< getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
616 int joint = _jsets[s].joints[0];
626 _jsets[s].cfg.pid_output_types.postrj_ctrl_out_type = _trj_pids[joint].
out_type;
627 _jsets[s].cfg.pid_output_types.veltrj_ctrl_out_type = _trj_pids[joint].
out_type;
628 _jsets[s].cfg.pid_output_types.mixtrj_ctrl_out_type = _trj_pids[joint].
out_type;
632 _jsets[s].cfg.pid_output_types.posdir_ctrl_out_type = _trj_pids[joint].
out_type;
633 _jsets[s].cfg.pid_output_types.veldir_ctrl_out_type = _trj_pids[joint].
out_type;
635 _jsets[s].cfg.pid_output_types.torque_ctrl_out_type = _trq_pids[joint].
out_type;
637 _jsets[s].cfg.pid_output_types.pwm_ctrl_out_type = eomc_ctrl_out_type_pwm;
639 if (_cur_pids[joint].enabled)
641 _jsets[s].cfg.pid_output_types.cur_ctrl_out_type = eomc_ctrl_out_type_cur;
645 _jsets[s].cfg.pid_output_types.cur_ctrl_out_type = eomc_ctrl_out_type_n_a;
654bool embObjMotionControl::saveCouplingsData(
void)
656 eOmc_4jomo_coupling_t *jc_dest;
658 static eOmc_4jomo_coupling_t dummyjomocoupling = {};
660 switch(serviceConfig.
ethservice.configuration.type)
662 case eomn_serv_MC_foc:
664 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.foc_based.jomocoupling);
667 case eomn_serv_MC_mc4plus:
669 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc4plus_based.jomocoupling);
672 case eomn_serv_MC_mc4plusmais:
674 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc4plusmais_based.jomocoupling);
678 case eomn_serv_MC_mc2pluspsc:
680 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc2pluspsc.jomocoupling);
684 case eomn_serv_MC_mc4plusfaps:
686 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc4plusfaps.jomocoupling);
690 case eomn_serv_MC_advfoc:
692 jc_dest = &dummyjomocoupling;
695 case eomn_serv_MC_mc4:
700 case eomn_serv_MC_generic:
712 memset(jc_dest, 0,
sizeof(eOmc_4jomo_coupling_t));
716 for(
int i=0; i<4; i++)
718 jc_dest->joint2set[i] = eomc_jointSetNum_none;
721 if(_joint2set.size() > 4 )
723 yError() <<
"embObjMC "<< getBoardInfo() <<
"Jointsset size is bigger than 4. I can't send jointset information to fw.";
727 for(
size_t i=0; i<_joint2set.size(); i++)
729 jc_dest->joint2set[i] = _joint2set[i];
732 for(
int i=0; i<4; i++)
734 for(
int j=0; j<4; j++)
736 jc_dest->joint2motor[i][j] = eo_common_float_to_Q17_14((
float)_couplingInfo.
matrixJ2M[4*i+j]);
737 jc_dest->motor2joint[i][j] = eo_common_float_to_Q17_14((
float)_couplingInfo.
matrixM2J[4*i+j]);
742 for(
int r=0; r<4; r++)
744 for(
int c=0; c<6; c++)
746 jc_dest->encoder2joint[r][c] = eo_common_float_to_Q17_14((
float)_couplingInfo.
matrixE2J[6*r+c]);
750 for(
size_t s=0; s< _jsets.size(); s++)
752 eOmc_jointset_configuration_t* cfg_ptr = _jsets[s].getConfiguration();
753 memcpy(&(jc_dest->jsetcfg[s]), cfg_ptr,
sizeof(eOmc_jointset_configuration_t));
757 if(eomn_serv_MC_advfoc == serviceConfig.
ethservice.configuration.type)
760 eOmc_adv4jomo_coupling_t *ajc = &serviceConfig.
ethservice.configuration.data.mc.advfoc.adv4jomocoupling;
761 ajc->type = eommccoupling_traditional4x4;
763 std::memmove(&ajc->data.coupling4x4.joint2set[0], &jc_dest->joint2set[0], 4*
sizeof(uint8_t));
764 std::memmove(&ajc->data.coupling4x4.jsetcfg[0], &jc_dest->jsetcfg[0], 4*
sizeof(eOmc_jointset_configuration_t));
765 std::memmove(&ajc->data.coupling4x4.joint2motor, &jc_dest->joint2motor,
sizeof(eOmc_4x4_matrix_t));
766 std::memmove(&ajc->data.coupling4x4.motor2joint, &jc_dest->motor2joint,
sizeof(eOmc_4x4_matrix_t));
768 for(uint8_t r=0; r<4; r++)
770 for(uint8_t c=0; c<4; c++)
772 ajc->data.coupling4x4.encoder2joint4x4[r][c] = jc_dest->encoder2joint[r][c];
782bool embObjMotionControl::fromConfig_Step2(yarp::os::Searchable &config)
789 if(iNeedCouplingsInfo())
815 for (i = 0; i < _njoints; i++)
817 measConvFactors.angleToEncoder[i] = 1;
838 if(eomn_serv_MC_mc4 != (eOmn_serv_type_t)serviceConfig.
ethservice.configuration.type)
840 int* useMotorSpeedFbk = 0;
841 useMotorSpeedFbk =
new int[_njoints];
844 delete[] useMotorSpeedFbk;
849 if (!verifyUseMotorSpeedFbkInJointSet(useMotorSpeedFbk))
851 delete[] useMotorSpeedFbk;
854 delete[] useMotorSpeedFbk;
856 bool deadzoneIsAvailable;
859 if(!deadzoneIsAvailable)
861 updateDeadZoneWithDefaultValues();
873 bool lowLevPidisMandatory =
false;
875 if((serviceConfig.
ethservice.configuration.type == eomn_serv_MC_foc) || (serviceConfig.
ethservice.configuration.type == eomn_serv_MC_advfoc))
877 lowLevPidisMandatory =
true;
880 if(!_mcparser->
parsePids(config, _trj_pids, _trq_pids, _cur_pids, _spd_pids, lowLevPidisMandatory))
897 updatedJointsetsCfgWithControlInfo();
900 for (i = 0; i < _njoints; i++)
902 measConvFactors.newtonsToSensor[i] = 1000000.0f;
904 measConvFactors.bemf2raw[i] = measConvFactors.newtonsToSensor[i] / measConvFactors.angleToEncoder[i];
905 if (_trq_pids->
out_PidUnits == yarp::dev::PidOutputUnitsEnum::DUTYCYCLE_PWM_PERCENT)
907 measConvFactors.ktau2raw[i] = measConvFactors.dutycycleToPWM[i] / measConvFactors.newtonsToSensor[i];
909 else if (_trq_pids->
out_PidUnits == yarp::dev::PidOutputUnitsEnum::RAW_MACHINE_UNITS)
911 measConvFactors.ktau2raw[i] = 1.0 / measConvFactors.newtonsToSensor[i];
915 yError() <<
"Invalid ktau units";
return false;
920 _measureConverter =
new ControlBoardHelper(_njoints, _axisMap, measConvFactors.angleToEncoder, NULL, measConvFactors.newtonsToSensor, measConvFactors.ampsToSensor,
nullptr, measConvFactors.dutycycleToPWM , measConvFactors.bemf2raw, measConvFactors.ktau2raw);
921 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_POSITION, _trj_pids->
fbk_PidUnits, _trj_pids->
out_PidUnits);
923 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_TORQUE, _trq_pids->
fbk_PidUnits, _trq_pids->
out_PidUnits);
924 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, _cur_pids->
fbk_PidUnits, _cur_pids->
out_PidUnits);
925 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, _spd_pids->
fbk_PidUnits, _spd_pids->
out_PidUnits);
938 initializeInterfaces(measConvFactors);
939 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_POSITION, _trj_pids->
fbk_PidUnits, _trj_pids->
out_PidUnits);
941 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_TORQUE, _trq_pids->
fbk_PidUnits, _trq_pids->
out_PidUnits);
942 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, _cur_pids->
fbk_PidUnits, _cur_pids->
out_PidUnits);
943 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, _spd_pids->
fbk_PidUnits, _spd_pids->
out_PidUnits);
947 if(!saveCouplingsData())
954 yError() <<
"embObjMC " << getBoardInfo() <<
"IMPEDANCE section: error detected in parameters syntax";
961 yError() <<
"embObjMC " << getBoardInfo() <<
"LUGRE section: error detected in parameters syntax";
966 for(j=0; j<_njoints; j++)
969 _impedance_limits[j].
min_damp= 0.001;
970 _impedance_limits[j].
max_damp= 9.888;
973 _impedance_limits[j].
param_a= 0.011;
974 _impedance_limits[j].
param_b= 0.012;
975 _impedance_limits[j].
param_c= 0.013;
996 eOmn_serv_type_t servtype =
static_cast<eOmn_serv_type_t
>(serviceConfig.
ethservice.configuration.type);
998 if((eomn_serv_MC_foc == servtype) || (eomn_serv_MC_advfoc == servtype))
1000 std::string groupName = {};
1002 if(eomn_serv_MC_foc == servtype)
1005 eObrd_type_t brd =
static_cast<eObrd_type_t
>(serviceConfig.
ethservice.configuration.data.mc.foc_based.type);
1006 groupName = (eobrd_foc == brd) ?
"2FOC" :
"AMCBLDC";
1008 else if(eomn_serv_MC_advfoc == servtype)
1012 groupName =
"ADVFOC";
1015 if(!_mcparser->
parseFocGroup(config, _foc_based_info, groupName, _temperatureSensorsVector))
1018 for (j = 0; j < _njoints; j++)
1020 if (((_temperatureSensorsVector.at(j)->getType() !=
motor_temperature_sensor_none )) && ((_temperatureLimits[j].hardwareTemperatureLimit == 0) || (_temperatureLimits[j].warningTemperatureLimit == 0)))
1022 yError() <<
"In" << getBoardInfo() <<
"joint" << j <<
": inconsistent configuration, please update it. If Temperature limits are not set then TemperatureSensorType must be NONE or not set and/or HasTempSensor must be zero. Aborting...";
1028 yInfo() <<
"embObjMC " << getBoardInfo() <<
"joint " << j <<
" has motor not provided with any available type of temperature sensor. If needed update the configurations file accordingly";
1034 for (j = 0; j < _njoints; j++)
1036 _temperatureSensorsVector.at(j) = std::make_unique<eomc::TemperatureSensorNONE>();
1052bool embObjMotionControl::verifyUseMotorSpeedFbkInJointSet(
int useMotorSpeedFbk [])
1054 for(
size_t s=0; s< _jsets.size(); s++)
1056 int numofjointsinset = _jsets[s].getNumberofJoints();
1057 if(numofjointsinset == 0 )
1059 yError() <<
"embObjMC " << getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
1063 int firstjointofset = _jsets[s].joints[0];
1064 for(
int j=1; j<numofjointsinset; j++)
1066 int joint = _jsets[s].joints[j];
1067 if(useMotorSpeedFbk[firstjointofset] != useMotorSpeedFbk[joint])
1069 yError() <<
"embObjMC " << getBoardInfo() <<
". Param useMotorSpeedFbk should have same value for joints belong same set. See joint " << firstjointofset <<
" and " << joint;
1074 _jsets[s].setUseSpeedFeedbackFromMotors(useMotorSpeedFbk[firstjointofset]);
1081bool embObjMotionControl::verifyTorquePidshasSameUnitTypes(yarp::dev::PidFeedbackUnitsEnum &fbk_pidunits, yarp::dev::PidOutputUnitsEnum& out_pidunits)
1083 fbk_pidunits = yarp::dev::PidFeedbackUnitsEnum::RAW_MACHINE_UNITS;
1084 out_pidunits = yarp::dev::PidOutputUnitsEnum::RAW_MACHINE_UNITS;
1086 int firstjoint = -1;
1087 for(
int i=0; i<_njoints; i++)
1089 if(_trq_pids[i].enabled)
1099 for(
int i=firstjoint+1; i<_njoints; i++)
1101 if(_trq_pids[i].enabled)
1103 if(_trq_pids[firstjoint].fbk_PidUnits != _trq_pids[i].fbk_PidUnits ||
1104 _trq_pids[firstjoint].out_PidUnits != _trq_pids[i].out_PidUnits)
1106 yError() <<
"embObjMC " << getBoardInfo() <<
"all joints with torque enabled should have same controlunits type. Joint " << firstjoint <<
" differs from joint " << i;
1117bool embObjMotionControl::isTorqueControlEnabled(
int joint)
1119 return (_trq_pids[joint].enabled);
1122bool embObjMotionControl::isVelocityControlEnabled(
int joint)
1125 return (_trj_pids[joint].enabled);
1129void embObjMotionControl::updateDeadZoneWithDefaultValues(
void)
1131 for(
int i=0; i<_njoints; i++)
1133 switch(_jointEncs[i].
type)
1141 case eomc_enc_aksim2:
1147 case eomc_enc_absanalog:
1150 case eomc_enc_hallmotor:
1151 case eomc_enc_spichainof2:
1152 case eomc_enc_spichainof3:
1162bool embObjMotionControl::fromConfig_readServiceCfg(yarp::os::Searchable &config)
1165 if(
false == parser->
parseService(config, serviceConfig))
1167 yError() <<
"embObjMC " << getBoardInfo() <<
"cannot parse service" ;
1171 if(eomn_serv_MC_generic == serviceConfig.
ethservice.configuration.type)
1173 yError() <<
"embObjMC " << getBoardInfo() <<
"it is no longer possible use eomn_serv_MC_generic, because firmware cannot configure itself!" ;
1181 for(
int i=0; i<_njoints; i++)
1186 if(NULL == jointEncoder_ptr)
1188 _jointEncs[i].resolution = 1;
1189 _jointEncs[i].type = eomc_enc_none;
1190 _jointEncs[i].tolerance = 0;
1194 _jointEncs[i].resolution = jointEncoder_ptr->
resolution;
1195 _jointEncs[i].type = (eOmc_encoder_t)jointEncoder_ptr->
desc.type;
1196 _jointEncs[i].tolerance = jointEncoder_ptr->
tolerance;
1200 if(NULL == motorEncoder_ptr)
1202 _motorEncs[i].resolution = 1;
1203 _motorEncs[i].type = eomc_enc_none;
1204 _motorEncs[i].tolerance = 0;
1208 _motorEncs[i].resolution = motorEncoder_ptr->
resolution;
1209 _motorEncs[i].type = (eOmc_encoder_t)motorEncoder_ptr->
desc.type;
1210 _motorEncs[i].tolerance = motorEncoder_ptr->
tolerance;
1222bool embObjMotionControl::fromConfig(yarp::os::Searchable &config)
1225 _njoints = fromConfig_NumOfJoints(config);
1229 yError() <<
"embObjMC"<< getBoardInfo() <<
"fromConfig(): detected _njoints = " << _njoints;
1234 if(!alloc(_njoints))
1236 yError() <<
"embObjMC"<< getBoardInfo() <<
"fromConfig(): alloc() failed for _njoints = " << _njoints;
1244 int currentMCversion =0;
1250 yError() <<
"embObjMC" << getBoardInfo() <<
"------ ATTENTION!!!! Wrong value of <MotioncontrolVersion> parameter !!!! ---------------------------------------------------------------------------------------";
1251 yError() <<
"embObjMC" << getBoardInfo() <<
"------ This means that the configuration files of this device are not compatible with my parser, so I cannot start. ";
1252 yError() <<
"embObjMC" << getBoardInfo() <<
"------ I need version " <<
PARSER_MOTION_CONTROL_VERSION <<
", but in configuration files have version " << currentMCversion <<
".";
1253 yError() <<
"embObjMC" << getBoardInfo() <<
"------ Please update configuration files in robots-configuration repository. (see https://icub-tech-iit.github.io/documentation/icub_robot_configuration/icub_robot_configuration_index/ for more information). ";
1254 yError() <<
"embObjMC" << getBoardInfo() <<
"------ If the problem persists contact icub-support@iit.it DO NOT DO IT BY YOURSELF.";
1255 yError() <<
"embObjMC" << getBoardInfo() <<
"----------------------------------------------------------------------------------------------------------------------------------------------------------------";
1261 yTrace() << config.toString().c_str();
1266 if(
false == fromConfig_readServiceCfg(config))
1278 if(
false == fromConfig_Step2(config))
1290bool embObjMotionControl::init()
1292 eOprotID32_t protid = 0;
1298 for(
int logico=0; logico< _njoints; logico++)
1300 int fisico = _axisMap[logico];
1301 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, fisico, eoprot_tag_mc_joint_cmmnds_controlmode);
1302 eOenum08_t controlMode = eomc_controlmode_cmd_idle;
1306 yError() <<
"embObjMotionControl::init() had an error while setting eomc_controlmode_cmd_idle in "<< getBoardInfo();
1312 SystemClock::delaySystem(0.010);
1319 vector<eOprotID32_t> id32v(0);
1320 for(
int n=0;
n<_njoints;
n++)
1322 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint,
n, eoprot_tag_mc_joint_status_core);
1323 id32v.push_back(protid);
1324 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint,
n, eoprot_tag_mc_joint_status_addinfo_multienc);
1325 id32v.push_back(protid);
1326 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor,
n, eoprot_tag_mc_motor_status);
1327 id32v.push_back(protid);
1330 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
1332 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, 0, eoprot_tag_mc_joint_status_debug);
1333 id32v.push_back(protid);
1334 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, 1, eoprot_tag_mc_joint_status_debug);
1335 id32v.push_back(protid);
1341 yError() <<
"embObjMotionControl::init() fails to add its variables to regulars in "<< getBoardInfo() <<
": cannot proceed any further";
1348 yDebug() <<
"embObjMotionControl::init() added" << id32v.size() <<
"regular rops to "<< getBoardInfo();
1350 for(
unsigned int r=0; r<id32v.size(); r++)
1352 uint32_t id32 = id32v.at(r);
1353 eoprot_ID2information(id32, nvinfo,
sizeof(nvinfo));
1354 yDebug() <<
"\t it added regular rop for" << nvinfo;
1359 SystemClock::delaySystem(0.005);
1366 for(
int logico=0; logico< _njoints; logico++)
1368 int fisico = _axisMap[logico];
1369 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, fisico, eoprot_tag_mc_joint_config);
1371 eOmc_joint_config_t jconfig = {0};
1372 memset(&jconfig, 0,
sizeof(eOmc_joint_config_t));
1374 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_POSITION,_trj_pids[logico].pid, fisico);
1378 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_TORQUE, _trq_pids[logico].pid, fisico);
1382 jconfig.impedance.damping = (eOmeas_damping_t) _measureConverter->impN2S(_impedance_params[logico].damping, fisico);
1383 jconfig.impedance.stiffness = (eOmeas_stiffness_t) _measureConverter->impN2S(_impedance_params[logico].stiffness, fisico);
1384 jconfig.impedance.offset = 0;
1386 _cacheImpedance[logico].stiffness = jconfig.impedance.stiffness;
1387 _cacheImpedance[logico].damping = jconfig.impedance.damping;
1388 _cacheImpedance[logico].offset = jconfig.impedance.offset;
1390 jconfig.userlimits.max = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posMax, fisico));
1391 jconfig.userlimits.min = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posMin, fisico));
1393 jconfig.hardwarelimits.max = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posHwMax, fisico));
1394 jconfig.hardwarelimits.min = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posHwMin, fisico));
1397 jconfig.maxvelocityofjoint =
S_32(_measureConverter->posA2E(_jointsLimits[logico].velMax, fisico));
1398 jconfig.velocitysetpointtimeout = (eOmeas_time_t)
U_16(_timeouts[logico].velocity);
1400 jconfig.jntEncoderResolution = _jointEncs[logico].resolution;
1401 jconfig.jntEncoderType = _jointEncs[logico].type;
1402 jconfig.jntEncTolerance = _jointEncs[logico].tolerance;
1404 jconfig.motor_params.bemf_value = _measureConverter->bemf_user2raw(_trq_pids[logico].kbemf, fisico);
1405 jconfig.motor_params.bemf_scale = 0;
1406 jconfig.motor_params.ktau_value = _measureConverter->ktau_user2raw(_trq_pids[logico].ktau, fisico);
1407 jconfig.motor_params.ktau_scale = 0;
1408 jconfig.motor_params.friction.viscous_pos_val = _measureConverter->viscousPos_user2raw(_trq_pids[logico].viscousPos, fisico);
1409 jconfig.motor_params.friction.viscous_neg_val = _measureConverter->viscousNeg_user2raw(_trq_pids[logico].viscousNeg, fisico);
1410 jconfig.motor_params.friction.coulomb_pos_val = _measureConverter->coulombPos_user2raw(_trq_pids[logico].coulombPos, fisico);
1411 jconfig.motor_params.friction.coulomb_neg_val = _measureConverter->coulombNeg_user2raw(_trq_pids[logico].coulombNeg, fisico);
1412 jconfig.motor_params.friction.velocityThres_val = _measureConverter->velocityThres_user2raw(_trq_pids[logico].velocityThres, fisico);
1414 jconfig.gearbox_E2J = _gearbox_E2J[logico];
1416 jconfig.deadzone = _measureConverter->posA2E(_deadzone[logico], fisico);
1418 jconfig.tcfiltertype=_trq_pids[logico].
filterType;
1420 jconfig.kalman_params.enabled = _kalman_params[logico].enabled;
1421 for(
int i=0; i<_kalman_params[logico].x0.size(); i++) jconfig.kalman_params.x0[i] = _kalman_params[logico].x0.at(i);
1422 for(
int i=0; i<_kalman_params[logico].Q.size(); i++) jconfig.kalman_params.Q[i] = _kalman_params[logico].Q.at(i);
1423 jconfig.kalman_params.R = _kalman_params[logico].R;
1424 jconfig.kalman_params.P0 = _kalman_params[logico].P0;
1428 yError() <<
"FATAL: embObjMotionControl::init() had an error while calling setcheckRemoteValue() for joint config fisico #" << fisico <<
"in "<< getBoardInfo();
1435 yDebug() <<
"embObjMotionControl::init() correctly configured joint config fisico #" << fisico <<
"in "<< getBoardInfo();
1446 for(
int logico=0; logico<_njoints; logico++)
1448 int fisico = _axisMap[logico];
1450 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, fisico, eoprot_tag_mc_motor_config);
1451 eOmc_motor_config_t motor_cfg = {0};
1452 motor_cfg.maxvelocityofmotor = 0;
1453 motor_cfg.currentLimits.nominalCurrent = _currentLimits[logico].nominalCurrent;
1454 motor_cfg.currentLimits.overloadCurrent = _currentLimits[logico].overloadCurrent;
1455 motor_cfg.currentLimits.peakCurrent = _currentLimits[logico].peakCurrent;
1456 motor_cfg.gearbox_M2J = _gearbox_M2J[logico];
1457 motor_cfg.rotorEncoderResolution = _motorEncs[logico].resolution;
1458 motor_cfg.rotEncTolerance = _motorEncs[logico].tolerance;
1459 motor_cfg.hasHallSensor = _foc_based_info[logico].
hasHallSensor;
1461 motor_cfg.hasTempSensor = _foc_based_info[logico].
hasTempSensor;
1464 motor_cfg.verbose = _foc_based_info[logico].
verbose;
1465 motor_cfg.motorPoles = _foc_based_info[logico].
motorPoles;
1467 motor_cfg.rotorEncoderType = _motorEncs[logico].type;
1468 motor_cfg.pwmLimit =_rotorsLimits[logico].pwmMax;
1469 motor_cfg.temperatureLimit = (eOmeas_temperature_t)
S_16(_temperatureSensorsVector.at(logico)->convertTempCelsiusToRaw(_temperatureLimits.at(logico).hardwareTemperatureLimit));
1470 motor_cfg.limitsofrotor.max = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_rotorsLimits[logico].posMax, fisico ));
1471 motor_cfg.limitsofrotor.min = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_rotorsLimits[logico].posMin, fisico ));
1473 motor_cfg.LuGre_params.Km = _lugre_params[logico].Km;
1474 motor_cfg.LuGre_params.Kw = _lugre_params[logico].Kw;
1475 motor_cfg.LuGre_params.S0 = _lugre_params[logico].S0;
1476 motor_cfg.LuGre_params.S1 = _lugre_params[logico].S1;
1477 motor_cfg.LuGre_params.Vth = _lugre_params[logico].Vth;
1478 motor_cfg.LuGre_params.Fc_pos = _lugre_params[logico].Fc_pos;
1479 motor_cfg.LuGre_params.Fc_neg = _lugre_params[logico].Fc_neg;
1480 motor_cfg.LuGre_params.Fs_pos = _lugre_params[logico].Fs_pos;
1481 motor_cfg.LuGre_params.Fs_neg = _lugre_params[logico].Fs_neg;
1484 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_CURRENT, _cur_pids[logico].pid, fisico);
1487 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_VELOCITY, _spd_pids[logico].pid, fisico);
1492 yError() <<
"FATAL: embObjMotionControl::init() had an error while calling setcheckRemoteValue() for motor config fisico #" << fisico <<
"in "<< getBoardInfo();
1499 yDebug() <<
"embObjMotionControl::init() correctly configured motor config fisico #" << fisico <<
"in "<< getBoardInfo();
1513 const char* tag = eoprot_TAG2string(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_addinfo_multienc);
1515 _rawValuesMetadataMap.insert({{tag,
rawValuesKeyMetadata({}, _njoints * eOmc_joint_multienc_maxnum)}});
1516 for (
auto &[k, v] : _rawValuesMetadataMap)
1518 std::string auxstring =
"";
1520 for (
int i = 0; i < _njoints; i++)
1525 v.rawValueNames.insert(v.rawValueNames.end(),
1526 {auxstring+
"_primary_encoder_raw_value",
1527 auxstring+
"_secondary_encoder_raw_value",
1528 auxstring+
"_primary_encoder_diagnostic"}
1534 yTrace() <<
"embObjMotionControl::init(): correctly instantiated for " << getBoardInfo();
1542 yTrace() <<
" embObjMotionControl::close()";
1544 ImplementControlMode::uninitialize();
1545 ImplementEncodersTimed::uninitialize();
1546 ImplementMotorEncoders::uninitialize();
1547 ImplementPositionControl::uninitialize();
1548 ImplementVelocityControl::uninitialize();
1549 ImplementPidControl::uninitialize();
1550 ImplementControlCalibration::uninitialize();
1551 ImplementAmplifierControl::uninitialize();
1552 ImplementImpedanceControl::uninitialize();
1553 ImplementControlLimits::uninitialize();
1554 ImplementTorqueControl::uninitialize();
1555 ImplementPositionDirect::uninitialize();
1556 ImplementInteractionMode::uninitialize();
1557 ImplementRemoteVariables::uninitialize();
1558 ImplementAxisInfo::uninitialize();
1559 ImplementCurrentControl::uninitialize();
1560 ImplementPWMControl::uninitialize();
1561 ImplementJointFault::uninitialize();
1563 if (_measureConverter) {
delete _measureConverter; _measureConverter=0;}
1566 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
1569 for(
size_t i=0; i<mcdiagnostics.
ports.size(); i++)
1571 mcdiagnostics.
ports[i]->close();
1572 delete mcdiagnostics.
ports[i];
1574 mcdiagnostics.
ports.clear();
1576 mcdiagnostics.
config.mode = eomn_serv_diagn_mode_NONE;
1577 mcdiagnostics.
config.par16 = 0;
1580 delete event_downsampler;
1594void embObjMotionControl::cleanup(
void)
1596 if(ethManager == NULL)
return;
1615 size_t joint = eoprot_ID2index(id32);
1616 eOprotEntity_t ent = eoprot_ID2entity(id32);
1617 eOprotTag_t tag = eoprot_ID2tag(id32);
1631 std::lock_guard<std::mutex> lck(_mutex);
1632 _encodersStamp[joint] = timestamp;
1636 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
1638 char str[128] =
"boh";
1640 eoprot_ID2information(id32, str,
sizeof(str));
1642 if((eoprot_entity_mc_joint == ent) && (eoprot_tag_mc_joint_status_debug == tag) && (joint < mcdiagnostics.
ports.size()))
1645 eOprotID32_t id32sc = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joint, eoprot_tag_mc_joint_status_core);
1646 eOmc_joint_status_core_t jcore = {};
1650 int32_t *debug32 =
reinterpret_cast<int32_t*
>(rxdata);
1653 Bottle& output = mcdiagnostics.
ports[joint]->prepare();
1656 output.addString(
"[yt, amo, reg, pos]");
1657 output.addFloat64(timestamp);
1658 output.addInt32(debug32[0]);
1659 output.addInt32(debug32[1]);
1660 output.addInt32(jcore.measures.meas_position);
1661 mcdiagnostics.
ports[joint]->write();
1665 if((eoprot_entity_mc_motor == ent) && (eoprot_tag_mc_motor_status == tag))
1670 uint8_t motor = eoprot_ID2index(id32);
1674 eOmc_motor_status_t *mc_motor_status =
reinterpret_cast<eOmc_motor_status_t*
>(rxdata);
1676 if((
double)mc_motor_status->basic.mot_temperature < 0 )
1678 if(! _temperatureSensorErrorWatchdog.at(motor).isStarted())
1680 yWarning() << getBoardInfo() <<
"At time" << (_temperatureSensorErrorWatchdog.at(motor).getAbsoluteTime() - yarp::os::Time::now()) <<
"In motor" << motor <<
"cannot read Temperature from I2C. There might be cabling problems, TDB cable might be broken or sensor unreachable";
1681 _temperatureSensorErrorWatchdog.at(motor).start();
1685 _temperatureSensorErrorWatchdog.at(motor).increment();
1686 if( _temperatureSensorErrorWatchdog.at(motor).isExpired())
1688 yWarning()<< getBoardInfo() <<
"Motor" << motor <<
"failed to read" << _temperatureSensorErrorWatchdog.at(motor).getCount() <<
"temperature readings for" << yarp::os::Time::now() - _temperatureSensorErrorWatchdog.at(motor).getStartTime() <<
"seconds";
1689 _temperatureSensorErrorWatchdog.at(motor).start();
1696 double delta_tmp = 0;
1697 double tmp = _temperatureSensorsVector.at(motor)->convertRawToTempCelsius((
double)mc_motor_status->basic.mot_temperature);
1701 if(!_temperatureSpikesFilter.at(motor).isStarted())
1703 _temperatureSpikesFilter.at(motor).start(tmp);
1708 delta_tmp = std::abs(tmp - _temperatureSpikesFilter.at(motor).getPrevTemperature());
1711 if(delta_tmp > _temperatureSpikesFilter.at(motor).getTemperatureThreshold())
1717 _temperatureSpikesFilter.at(motor).updatePrevTemperature(tmp);
1720 if(tmp > _temperatureLimits[motor].warningTemperatureLimit)
1722 if(! _temperatureExceededLimitWatchdog.at(motor).isStarted())
1724 yWarning() << getBoardInfo() <<
"Motor" << motor <<
"The temperature (" << tmp <<
"[ ℃ ] ) exceeds the warning limit (" << _temperatureLimits[motor].warningTemperatureLimit <<
"[ ℃ ] ). Processes not stopped but it is strongly recommended decreasing motor usage or reducing currents and PWMs to not risk motor damaging";
1725 _temperatureExceededLimitWatchdog.at(motor).start();
1729 if(_temperatureExceededLimitWatchdog.at(motor).isExpired())
1731 yWarning() << getBoardInfo() <<
"Motor" << motor <<
"The temperature (" << tmp <<
"[ ℃ ] ) exceeds the warning limit (" << _temperatureLimits[motor].warningTemperatureLimit <<
"[ ℃ ] ) again!. Processes not stopped but it is strongly recommended decreasing motor usage or reducing currents and PWMs to not risk motor damaging";
1732 _temperatureExceededLimitWatchdog.at(motor).start();
1734 _temperatureExceededLimitWatchdog.at(motor).increment();
1739 _temperatureExceededLimitWatchdog.at(motor).clear();
1763 encoderTypeName.clear();
1765 if ((jomoId >= 0) && (jomoId < _njoints))
1769 case eomc_pos_atjoint:
1770 encoderTypeName = eomc_encoder2string(_jointEncs[jomoId].
type, eobool_true);
1772 case eomc_pos_atmotor:
1773 encoderTypeName = eomc_encoder2string(_motorEncs[jomoId].
type, eobool_true);
1775 case eomc_pos_unknown:
1776 encoderTypeName =
"UNKNOWN";
1780 encoderTypeName =
"NONE";
1787 encoderTypeName =
"ERROR";
1797 case VOCAB_PIDTYPE_POSITION:
1798 helper_setPosPidRaw(j,pid);
1800 case VOCAB_PIDTYPE_VELOCITY:
1802 helper_setSpdPidRaw(j, pid);
1804 case VOCAB_PIDTYPE_TORQUE:
1805 helper_setTrqPidRaw(j, pid);
1807 case VOCAB_PIDTYPE_CURRENT:
1808 helper_setCurPidRaw(j,pid);
1811 yError()<<
"Invalid pidtype:"<<pidtype;
1821 case VOCAB_PIDTYPE_POSITION:
1822 helper_getPosPidRaw(axis,pid);
1824 case VOCAB_PIDTYPE_VELOCITY:
1826 helper_getSpdPidRaw(axis, pid);
1828 case VOCAB_PIDTYPE_TORQUE:
1829 helper_getTrqPidRaw(axis, pid);
1831 case VOCAB_PIDTYPE_CURRENT:
1832 helper_getCurPidRaw(axis,pid);
1835 yError()<<
"Invalid pidtype:"<<pidtype;
1841bool embObjMotionControl::helper_setPosPidRaw(
int j,
const Pid &pid)
1843 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtrajectory);
1852 yError() <<
"while setting position PIDs for " << getBoardInfo() <<
" joint " << j;
1862 for(
int j=0; j< _njoints; j++)
1877 for(
int j=0, index=0; j< _njoints; j++, index++)
1899 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
1900 eOmc_joint_status_core_t jcore = {0};
1907 case VOCAB_PIDTYPE_POSITION:
1909 if((eomc_controlmode_torque == jcore.modes.controlmodestatus) ||
1910 (eomc_controlmode_openloop == jcore.modes.controlmodestatus) ||
1911 (eomc_controlmode_current == jcore.modes.controlmodestatus))
1914 *err = (double) jcore.ofpid.generic.error1;
1925 case VOCAB_PIDTYPE_TORQUE:
1927 if ((eOmc_interactionmode_compliant == jcore.modes.interactionmodestatus) &&
1928 (eomc_controlmode_position == jcore.modes.controlmodestatus))
1930 *err = (double) jcore.ofpid.complpos.errtrq;
1933 if(eomc_controlmode_torque == jcore.modes.controlmodestatus)
1935 *err = (double) jcore.ofpid.torque.errtrq;
1939 case VOCAB_PIDTYPE_VELOCITY:
1945 case VOCAB_PIDTYPE_CURRENT:
1953 yError()<<
"Invalid pidtype:"<<pidtype;
1963 for(
int j=0; j< _njoints; j++)
1970bool embObjMotionControl::helper_getPosPidRaw(
int j, Pid *pid)
1972 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtrajectory);
1975 eOmc_PID_t eoPID = {0};
1978#ifdef NETWORK_PERFORMANCE_BENCHMARK
1979 double start = yarp::os::Time::now();
1982 bool ret = askRemoteValue(protid, &eoPID, size);
1984#ifdef NETWORK_PERFORMANCE_BENCHMARK
1985 double end = yarp::os::Time::now();
1986 m_responseTimingVerifier.tick(end-start, start);
1999bool embObjMotionControl::helper_getPosPidsRaw(Pid *pid)
2001 std::vector<eOmc_PID_t> eoPIDList(_njoints);
2002 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_config_pidtrajectory, eoPIDList);
2005 yError() <<
"failed helper_getPosPidsRaw for" << getBoardInfo();
2009 for(
int j=0; j<_njoints; j++)
2023 case VOCAB_PIDTYPE_POSITION:
2024 helper_getPosPidsRaw(pids);
2029 case VOCAB_PIDTYPE_TORQUE:
2030 helper_getTrqPidsRaw(pids);
2032 case VOCAB_PIDTYPE_CURRENT:
2033 helper_getCurPidsRaw(pids);
2035 case VOCAB_PIDTYPE_VELOCITY:
2036 helper_getSpdPidsRaw(pids);
2039 yError()<<
"Invalid pidtype:"<<pidtype;
2047 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
2048 eOmc_joint_status_core_t jcore = {0};
2055 case VOCAB_PIDTYPE_POSITION:
2057 if((eomc_controlmode_torque == jcore.modes.controlmodestatus) ||
2058 (eomc_controlmode_openloop == jcore.modes.controlmodestatus) ||
2059 (eomc_controlmode_current == jcore.modes.controlmodestatus))
2060 { *ref = 0; yError() <<
"Invalid getPidReferenceRaw() request for current control mode";
return true; }
2061 *ref = (double) jcore.ofpid.generic.reference1;
2070 case VOCAB_PIDTYPE_TORQUE:
2076 case VOCAB_PIDTYPE_CURRENT:
2082 case VOCAB_PIDTYPE_VELOCITY:
2091 yError()<<
"Invalid pidtype:"<<pidtype;
2104 for(
int j=0; j< _njoints; j++)
2149 if( (mode != VOCAB_CM_VELOCITY) &&
2150 (mode != VOCAB_CM_MIXED) &&
2151 (mode != VOCAB_CM_IMPEDANCE_VEL) &&
2152 (mode != VOCAB_CM_IDLE))
2156 yError() <<
"velocityMoveRaw: skipping command because " << getBoardInfo() <<
" joint " << j <<
" is not in VOCAB_CM_VELOCITY mode";
2161 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
2163 _ref_command_speeds[j] = sp ;
2165 eOmc_setpoint_t setpoint;
2166 setpoint.type = eomc_setpoint_velocity;
2167 setpoint.to.velocity.value = (eOmeas_velocity_t)
S_32(_ref_command_speeds[j]);
2168 setpoint.to.velocity.withacceleration = (eOmeas_acceleration_t)
S_32(_ref_accs[j]);
2173 yError() <<
"while setting velocity mode";
2182 eOmc_setpoint_t setpoint;
2184 setpoint.type = eomc_setpoint_velocity;
2186 for(
int j=0; j<_njoints; j++)
2201 yTrace() <<
"setCalibrationParametersRaw for " << getBoardInfo() <<
"joint" << j;
2203 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_calibration);
2204 eOmc_calibrator_t calib;
2205 memset(&calib, 0x00,
sizeof(calib));
2206 calib.type = params.type;
2211 case eomc_calibration_type0_hard_stops:
2212 calib.params.type0.pwmlimit = (int16_t)
S_16(params.param1);
2213 calib.params.type0.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2214 calib.params.type0.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2218 case eomc_calibration_type1_abs_sens_analog:
2219 calib.params.type1.position = (int16_t)
S_16(params.param1);
2220 calib.params.type1.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2221 calib.params.type1.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2225 case eomc_calibration_type2_hard_stops_diff:
2226 calib.params.type2.pwmlimit = (int16_t)
S_16(params.param1);
2227 calib.params.type2.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2228 calib.params.type2.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2232 case eomc_calibration_type3_abs_sens_digital:
2233 calib.params.type3.position = (int16_t)
S_16(params.param1);
2234 calib.params.type3.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2235 calib.params.type3.offset = (int32_t)
S_32(params.param3);
2236 calib.params.type3.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2240 case eomc_calibration_type4_abs_and_incremental:
2241 calib.params.type4.position = (int16_t)
S_16(params.param1);
2242 calib.params.type4.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2243 calib.params.type4.maxencoder = (int32_t)
S_32(params.param3);
2244 calib.params.type4.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2248 case eomc_calibration_type5_hard_stops:
2249 calib.params.type5.pwmlimit = (int32_t)
S_32(params.param1);
2250 calib.params.type5.final_pos = (int32_t)
S_32(params.param2);
2251 calib.params.type5.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2255 case eomc_calibration_type6_mais:
2256 calib.params.type6.position = (int32_t)
S_32(params.param1);
2257 calib.params.type6.velocity = (int32_t)
S_32(params.param2);
2258 calib.params.type6.current = (int32_t)
S_32(params.param3);
2259 calib.params.type6.vmin = (int32_t)
S_32(params.param4);
2260 calib.params.type6.vmax = (int32_t)
S_32(params.param5);
2261 calib.params.type6.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2265 case eomc_calibration_type7_hall_sensor:
2266 calib.params.type7.position = (int32_t)
S_32(params.param1);
2267 calib.params.type7.velocity = (int32_t)
S_32(params.param2);
2269 calib.params.type7.vmin = (int32_t)
S_32(params.param4);
2270 calib.params.type7.vmax = (int32_t)
S_32(params.param5);
2271 calib.params.type7.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2275 case eomc_calibration_type8_tripod_internal_hard_stop:
2276 calib.params.type8.pwmlimit = (int32_t)
S_32(params.param1);
2277 calib.params.type8.max_delta = (int32_t)
S_32(params.param2);
2278 calib.params.type8.calibrationZero = (int32_t)
S_32(params.paramZero );
2281 case eomc_calibration_type9_tripod_external_hard_stop:
2282 calib.params.type9.pwmlimit = (int32_t)
S_32(params.param1);
2283 calib.params.type9.max_delta = (int32_t)
S_32(params.param2);
2284 calib.params.type9.calibrationZero = (int32_t)
S_32(params.paramZero );
2287 case eomc_calibration_type10_abs_hard_stop:
2288 calib.params.type10.pwmlimit = (int32_t)
S_32(params.param1);
2289 calib.params.type10.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2292 case eomc_calibration_type11_cer_hands:
2293 calib.params.type11.offset0 = (int32_t)
S_32(params.param1);
2294 calib.params.type11.offset1 = (int32_t)
S_32(params.param2);
2295 calib.params.type11.offset2 = (int32_t)
S_32(params.param3);
2296 calib.params.type11.cable_range = (int32_t)
S_32(params.param4);
2297 calib.params.type11.pwm = (int32_t)
S_32(params.param5);
2301 case eomc_calibration_type12_absolute_sensor:
2302 calib.params.type12.rawValueAtZeroPos = (int32_t)
S_32(params.param1);
2303 calib.params.type12.calibrationDelta = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2306 case eomc_calibration_type13_cer_hands_2:
2307 calib.params.type13.rawValueAtZeroPos0 = (int32_t)
S_32(params.param1);
2308 calib.params.type13.rawValueAtZeroPos1 = (int32_t)
S_32(params.param2);
2309 calib.params.type13.rawValueAtZeroPos2 = (int32_t)
S_32(params.param3);
2310 calib.params.type13.rawValueAtZeroPos3 = (int32_t)
S_32(params.param4);
2313 case eomc_calibration_type14_qenc_hard_stop_and_fap:
2314 calib.params.type14.pwmlimit = (int32_t)
S_32(params.param1);
2315 calib.params.type14.final_pos = (int32_t)
S_32(params.param2);
2316 calib.params.type14.invertdirection = (uint8_t)
U_32(params.param3);
2317 calib.params.type14.rotation = (int32_t)
S_32(params.param4);
2319 if (calib.params.type14.invertdirection != 0 && calib.params.type14.invertdirection != 1)
2321 yError() <<
"Error in param3 of calibartion type 14 for joint " << j <<
"Admitted values are: 0=FALSE and 1=TRUE";
2326 if(!checkCalib14RotationParam(calib.params.type14.rotation))
2328 yError() <<
"Error in param4 of calibartion type 14 for joint " << j <<
"Admitted values are: 0, 32768, 16384, -16384 [0, 180, 90, -90] in iCubDegree";
2331 calib.params.type14.offset = (int32_t)
S_32(params.param5);
2332 calib.params.type14.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2337 yError() <<
"Calibration type unknown!! (embObjMotionControl)\n";
2344 yError() <<
"while setting velocity mode";
2348 _calibrated[j] =
true;
2353bool embObjMotionControl::checkCalib14RotationParam(int32_t calib_param4)
2355 eOmc_calib14_ROT_t urotation = eomc_int2calib14_ROT(calib_param4);
2357 if (urotation == eOmc_calib14_ROT_zero ||
2358 urotation == eOmc_calib14_ROT_plus180 ||
2359 urotation == eOmc_calib14_ROT_plus090 ||
2360 urotation == eOmc_calib14_ROT_minus090)
2370 yTrace() <<
"calibrateRaw for" << getBoardInfo() <<
"joint" << j;
2388 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_calibration);
2389 eOmc_calibrator_t calib;
2390 memset(&calib, 0x00,
sizeof(calib));
2396 case eomc_calibration_type0_hard_stops:
2397 calib.params.type0.pwmlimit = (int16_t)
S_16(p1);
2398 calib.params.type0.velocity = (eOmeas_velocity_t)
S_32(p2);
2402 case eomc_calibration_type1_abs_sens_analog:
2403 calib.params.type1.position = (int16_t)
S_16(p1);
2404 calib.params.type1.velocity = (eOmeas_velocity_t)
S_32(p2);
2408 case eomc_calibration_type2_hard_stops_diff:
2409 calib.params.type2.pwmlimit = (int16_t)
S_16(p1);
2410 calib.params.type2.velocity = (eOmeas_velocity_t)
S_32(p2);
2414 case eomc_calibration_type3_abs_sens_digital:
2415 calib.params.type3.position = (int16_t)
S_16(p1);
2416 calib.params.type3.velocity = (eOmeas_velocity_t)
S_32(p2);
2417 calib.params.type3.offset = (int32_t)
S_32(p3);
2421 case eomc_calibration_type4_abs_and_incremental:
2422 calib.params.type4.position = (int16_t)
S_16(p1);
2423 calib.params.type4.velocity = (eOmeas_velocity_t)
S_32(p2);
2424 calib.params.type4.maxencoder = (int32_t)
S_32(p3);
2428 yError () <<
"Calibration type unknown!! (embObjMotionControl)\n";
2435 yError() <<
"while setting velocity mode";
2439 _calibrated[j ] =
true;
2447 bool result =
false;
2448 eOenum08_t temp = 0;
2450 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_core_modes_controlmodestatus);
2451 if(
false == askRemoteValue(id32, &temp, size))
2453 yError () <<
"Failure of askRemoteValue() inside embObjMotionControl::doneRaw(axis=" << axis <<
") for " << getBoardInfo();
2457 eOmc_controlmode_t
type = (eOmc_controlmode_t) temp;
2461 if (eomc_controlmode_idle ==
type)
2465 else if (eomc_controlmode_calib ==
type)
2469 else if (eomc_controlmode_hwFault ==
type)
2471 yError(
"unable to complete calibration: joint %d in 'hw_fault status' inside doneRaw() function", axis);
2474 else if (eomc_controlmode_notConfigured ==
type)
2476 yError(
"unable to complete calibration: joint %d in 'not_configured' status inside doneRaw() function", axis);
2479 else if (eomc_controlmode_unknownError ==
type)
2481 yError(
"unable to complete calibration: joint %d in 'unknownError' status inside doneRaw() function", axis);
2484 else if (eomc_controlmode_configured ==
type)
2486 yError(
"unable to complete calibration: joint %d in 'configured' status inside doneRaw() function", axis);
2511 yWarning() <<
"Performance warning: You are using positionMove commands at high rate (<"<<
MAX_POSITION_MOVE_INTERVAL*1000.0 <<
" ms). Probably position control mode is not the right control mode to use.";
2513 _last_position_move_time[j] = yarp::os::Time::now();
2517 if( (mode != VOCAB_CM_POSITION) &&
2518 (mode != VOCAB_CM_MIXED) &&
2519 (mode != VOCAB_CM_IMPEDANCE_POS) &&
2520 (mode != VOCAB_CM_IDLE))
2524 yError() <<
"positionMoveRaw: skipping command because " << getBoardInfo() <<
" joint " << j <<
" is not in VOCAB_CM_POSITION mode";
2529 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
2530 _ref_command_positions[j] = ref;
2532 eOmc_setpoint_t setpoint;
2534 setpoint.type = (eOenum08_t) eomc_setpoint_position;
2535 setpoint.to.position.value = (eOmeas_position_t)
S_32(_ref_command_positions[j]);
2536 setpoint.to.position.withvelocity = (eOmeas_velocity_t)
S_32(_ref_speeds[j]);
2545 for(
int j=0, index=0; j< _njoints; j++, index++)
2565 eObool_t ismotiondone = eobool_false;
2568 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core_modes_ismotiondone);
2569 if(
false == askRemoteValue(id32, &ismotiondone, size))
2571 yError () <<
"Failure of askRemoteValue() inside embObjMotionControl::checkMotionDoneRaw(j=" << j <<
") for " << getBoardInfo();
2576 *flag = ismotiondone;
2583 std::vector <eObool_t> ismotiondoneList(_njoints);
2584 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_core_modes_ismotiondone, ismotiondoneList);
2587 yError () <<
"Failure of askRemoteValues() inside embObjMotionControl::checkMotionDoneRaw for all joints of" << getBoardInfo();
2591 for(
int j=0; j<_njoints; j++)
2593 *flag &= ismotiondoneList[j];
2603 _ref_speeds[index] = sp;
2611 for(
int j=0, index=0; j< _njoints; j++, index++)
2613 _ref_speeds[index] = spds[index];
2625 _ref_accs[j ] = 1e6;
2627 else if (
acc < -1e6)
2629 _ref_accs[j ] = -1e6;
2633 _ref_accs[j ] =
acc;
2643 for(
int j=0, index=0; j< _njoints; j++, index++)
2647 _ref_accs[index] = 1e6;
2649 else if (accs[j] < -1e6)
2651 _ref_accs[index] = -1e6;
2655 _ref_accs[index] = accs[j];
2663 if (j<0 || j>_njoints)
return false;
2664#if ASK_REFERENCE_TO_FIRMWARE
2665 *spd = _ref_speeds[j];
2668 *spd = _ref_speeds[j];
2675 memcpy(spds, _ref_speeds,
sizeof(
double) * _njoints);
2681 *
acc = _ref_accs[j];
2687 memcpy(accs, _ref_accs,
sizeof(
double) * _njoints);
2693 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_stoptrajectory);
2695 eObool_t stop = eobool_true;
2703 for(
int j=0; j< _njoints; j++)
2718 for(
int j=0; j<n_joint; j++)
2728 for(
int j=0; j<n_joint; j++)
2739 for(
int j=0; j<n_joint; j++)
2741 if(joints[j] >= _njoints)
2743 yError() << getBoardInfo() <<
":checkMotionDoneRaw required for not existing joint ( " << joints[j] <<
")";
2749 std::vector <eObool_t> ismotiondoneList(_njoints);
2750 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_core_modes_ismotiondone, ismotiondoneList);
2753 yError () << getBoardInfo() <<
"Failure of askRemoteValues() inside embObjMotionControl::checkMotionDoneRaw for a group of joint"; getBoardInfo();
2758 bool tot_val =
true;
2759 for(
int j=0; j<n_joint; j++)
2761 tot_val &= ismotiondoneList[joints[j]];
2772 for(
int j=0; j<n_joint; j++)
2782 for(
int j=0; j<n_joint; j++)
2792 for(
int j=0; j<n_joint; j++)
2802 for(
int j=0; j<n_joint; j++)
2812 for(
int j=0; j<n_joint; j++)
2814 ret = ret &&
stopRaw(joints[j]);
2825 eOmc_joint_status_core_t jcore = {0};
2826 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
2830 eOmc_controlmode_t
type = (eOmc_controlmode_t) jcore.modes.controlmodestatus;
2840 for(
int j=0; j< _njoints; j++)
2850 for(
int j=0; j< n_joint; j++)
2865 eOenum08_t controlmodecommand = 0;
2867 if((_mode == VOCAB_CM_TORQUE) && (_trq_pids[j].enabled ==
false))
2869 yError()<<
"Torque control is disabled. Check your configuration parameters";
2875 yError() <<
"SetControlMode: received unknown control mode for " << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
2879 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_controlmode);
2882 yError() <<
"setControlModeRaw failed for " << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
2887 ret = checkRemoteControlModeStatus(j, _mode);
2891 yError() <<
"In embObjMotionControl::setControlModeRaw(j=" << j <<
", mode=" << yarp::os::Vocab32::decode(_mode).c_str() <<
") for " << getBoardInfo() <<
" has failed checkRemoteControlModeStatus()";
2901 eOenum08_t controlmodecommand = 0;
2904 for(
int i=0; i<n_joint; i++)
2906 if ((modes[i] == VOCAB_CM_TORQUE) && (_trq_pids[i].enabled ==
false)) {yError()<<
"Torque control is disabled. Check your configuration parameters";
continue;}
2910 yError() <<
"SetControlModesRaw(): received unknown control mode for " << getBoardInfo() <<
" joint " << joints[i] <<
" mode " << Vocab32::decode(modes[i]);
2915 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joints[i], eoprot_tag_mc_joint_cmmnds_controlmode);
2918 yError() <<
"setControlModesRaw() could not send set<cmmnds_controlmode> for " << getBoardInfo() <<
" joint " << joints[i] <<
" mode " << Vocab32::decode(modes[i]);
2923 bool tmpresult = checkRemoteControlModeStatus(joints[i], modes[i]);
2924 if(
false == tmpresult)
2926 yError() <<
"setControlModesRaw(const int n_joint, const int *joints, int *modes) could not check with checkRemoteControlModeStatus() for " << getBoardInfo() <<
" joint " << joints[i] <<
" mode " << Vocab32::decode(modes[i]);
2929 ret = ret && tmpresult;
2939 eOenum08_t controlmodecommand = 0;
2941 for(
int i=0; i<_njoints; i++)
2944 if ((modes[i] == VOCAB_CM_TORQUE) && (_trq_pids[i].enabled ==
false))
2946 yError()<<
"Torque control is disabled. Check your configuration parameters";
2952 yError() <<
"SetControlMode: received unknown control mode for" << getBoardInfo() <<
" joint " << i <<
" mode " << Vocab32::decode(modes[i]);
2956 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, i, eoprot_tag_mc_joint_cmmnds_controlmode);
2959 yError() <<
"setControlModesRaw failed for " << getBoardInfo() <<
" joint " << i <<
" mode " << Vocab32::decode(modes[i]);
2963 bool tmpresult = checkRemoteControlModeStatus(i, modes[i]);
2964 if(
false == tmpresult)
2966 yError() <<
"setControlModesRaw(int *modes) could not check with checkRemoteControlModeStatus() for" << getBoardInfo() <<
" joint " << i <<
" mode " << Vocab32::decode(modes[i]);
2969 ret = ret && tmpresult;
3002 eOmc_joint_status_core_t core;
3003 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
3009 *value = (double) core.measures.meas_position;
3013 yError() <<
"embObjMotionControl while reading encoder";
3023 for(
int j=0; j< _njoints; j++)
3033 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
3034 eOmc_joint_status_core_t core;
3041 *sp = (double) core.measures.meas_velocity;
3048 for(
int j=0; j< _njoints; j++)
3057 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
3058 eOmc_joint_status_core_t core;
3064 *
acc = (double) core.measures.meas_acceleration;
3071 for(
int j=0; j< _njoints; j++)
3083 std::lock_guard<std::mutex> lck(_mutex);
3084 for(
int i=0; i<_njoints; i++)
3085 stamps[i] = _encodersStamp[i];
3092 std::lock_guard<std::mutex> lck(_mutex);
3093 *stamp = _encodersStamp[j];
3137 eOmc_motor_status_basic_t status;
3138 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
3143 *value = (double) status.mot_position;
3147 yError() <<
"embObjMotionControl while reading motor encoder position";
3157 for(
int j=0; j< _njoints; j++)
3167 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
3168 eOmc_motor_status_basic_t tmpMotorStatus;
3172 *sp = (double) tmpMotorStatus.mot_velocity;
3176 yError() <<
"embObjMotionControl while reading motor encoder speed";
3185 for(
int j=0; j< _njoints; j++)
3194 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
3195 eOmc_motor_status_basic_t tmpMotorStatus;
3199 *
acc = (double) tmpMotorStatus.mot_acceleration;
3203 yError() <<
"embObjMotionControl while reading motor encoder acceleration";
3212 for(
int j=0; j< _njoints; j++)
3222 std::lock_guard<std::mutex> lck(_mutex);
3223 for(
int i=0; i<_njoints; i++)
3224 stamps[i] = _encodersStamp[i];
3231 std::lock_guard<std::mutex> lck(_mutex);
3232 *stamp = _encodersStamp[m];
3251 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_status_basic);
3252 eOmc_motor_status_basic_t tmpMotorStatus;
3255 *value = (double) tmpMotorStatus.mot_current;
3262 for(
int j=0; j< _njoints; j++)
3271 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_currentlimits);
3273 eOmc_current_limits_params_t currentlimits = {0};
3275 if(!askRemoteValue(protid, ¤tlimits, size))
3277 yError() <<
"embObjMotionControl::setMaxCurrentRaw() could not read max current for " << getBoardInfo() <<
"joint " << j;
3282 currentlimits.overloadCurrent = (eOmeas_current_t)
S_16(val);
3290 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_currentlimits);
3292 eOmc_current_limits_params_t currentlimits = {0};
3295 if(!askRemoteValue(protid, ¤tlimits, size))
3297 yError() <<
"embObjMotionControl::getMaxCurrentRaw() could not read max current for " << getBoardInfo() <<
"joint " << j;
3301 *val = (double) currentlimits.overloadCurrent;
3309 (_enabledAmp[j ]) ? *st = 1 : *st = 0;
3316 for(
int j=0; j<_njoints; j++)
3318 sts[j] = _enabledAmp[j];
3324#ifdef IMPLEMENT_DEBUG_INTERFACE
3329bool embObjMotionControl::setParameterRaw(
int j,
unsigned int type,
double value) {
return NOT_YET_IMPLEMENTED(
"setParameterRaw"); }
3330bool embObjMotionControl::getParameterRaw(
int j,
unsigned int type,
double* value) {
return NOT_YET_IMPLEMENTED(
"getParameterRaw"); }
3331bool embObjMotionControl::getDebugParameterRaw(
int j,
unsigned int index,
double* value) {
return NOT_YET_IMPLEMENTED(
"getDebugParameterRaw"); }
3332bool embObjMotionControl::setDebugParameterRaw(
int j,
unsigned int index,
double value) {
return NOT_YET_IMPLEMENTED(
"setDebugParameterRaw"); }
3333bool embObjMotionControl::setDebugReferencePositionRaw(
int j,
double value) {
return NOT_YET_IMPLEMENTED(
"setDebugReferencePositionRaw"); }
3334bool embObjMotionControl::getDebugReferencePositionRaw(
int j,
double* value) {
return NOT_YET_IMPLEMENTED(
"getDebugReferencePositionRaw");}
3342 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_userlimits);
3344 eOmeas_position_limits_t limits;
3345 limits.max = (eOmeas_position_t)
S_32(max);
3346 limits.min = (eOmeas_position_t)
S_32(min);
3353 yError() <<
"while setting position limits for joint" << j <<
" \n";
3360 eOmeas_position_limits_t limits;
3361 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_userlimits);
3364 if(! askRemoteValue(protoid, &limits, size))
3367 *min = (double)limits.min + SAFETY_THRESHOLD;
3368 *max = (double)limits.max - SAFETY_THRESHOLD;
3374 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3376 eOmc_motor_config_t motor_cfg;
3377 if(! askRemoteValue(protoid, &motor_cfg, size))
3381 *gearbox = (double)motor_cfg.gearbox_M2J;
3388 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3390 eOmc_motor_config_t motor_cfg;
3391 if(! askRemoteValue(protoid, &motor_cfg, size))
3393 *rotorMax = (double)( motor_cfg.limitsofrotor.max);
3394 *rotorMin = (double)( motor_cfg.limitsofrotor.min);
3400 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3402 eOmc_joint_config_t joint_cfg;
3403 if(! askRemoteValue(protoid, &joint_cfg, size))
3407 type = (int)joint_cfg.tcfiltertype;
3413 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3415 eOmc_motor_config_t motor_cfg;
3416 if(! askRemoteValue(protoid, &motor_cfg, size))
3420 rotres = (double)motor_cfg.rotorEncoderResolution;
3427 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3429 eOmc_joint_config_t joint_cfg;
3430 if(! askRemoteValue(protoid, &joint_cfg, size))
3434 jntres = (double)joint_cfg.jntEncoderResolution;
3441 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3443 eOmc_joint_config_t joint_cfg;
3444 if(! askRemoteValue(protoid, &joint_cfg, size))
3448 type = (int)joint_cfg.jntEncoderType;
3455 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3457 eOmc_motor_config_t motor_cfg;
3458 if(! askRemoteValue(protoid, &motor_cfg, size))
3462 type = (int)motor_cfg.rotorEncoderType;
3469 yError(
"getKinematicMJRaw not yet implemented");
3495 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3497 eOmc_motor_config_t motor_cfg;
3498 if(! askRemoteValue(protoid, &motor_cfg, size))
3502 ret = (int)motor_cfg.hasTempSensor;
3509 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3511 eOmc_motor_config_t motor_cfg;
3512 if(! askRemoteValue(protoid, &motor_cfg, size))
3516 ret = (int)motor_cfg.hasHallSensor;
3523 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3525 eOmc_motor_config_t motor_cfg;
3526 if(! askRemoteValue(protoid, &motor_cfg, size))
3530 ret = (int)motor_cfg.hasRotorEncoder;
3537 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3539 eOmc_motor_config_t motor_cfg;
3540 if(! askRemoteValue(protoid, &motor_cfg, size))
3544 ret = (int)motor_cfg.hasRotorEncoderIndex;
3551 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3554 eOmc_motor_config_t motor_cfg;
3555 if(! askRemoteValue(protoid, &motor_cfg, size))
3559 poles = (int)motor_cfg.motorPoles;
3566 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3568 eOmc_motor_config_t motor_cfg;
3569 if(! askRemoteValue(protoid, &motor_cfg, size))
3573 rotorOffset = (double)motor_cfg.rotorIndexOffset;
3580 if (axis >= 0 && axis < _njoints)
3582 name = _axesInfo[axis].name;
3594 if (axis >= 0 && axis < _njoints)
3596 type = _axesInfo[axis].type;
3605bool embObjMotionControl::getJointDeadZoneRaw(
int j,
double &jntDeadZone)
3607 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3609 eOmc_joint_config_t joint_cfg;
3610 if(! askRemoteValue(protoid, &joint_cfg, size))
3614 jntDeadZone = _measureConverter->posE2A((
double)joint_cfg.deadzone, _axisMap[j]);
3623 if (key ==
"kinematic_mj")
3626 Bottle& ret = val.addList();
3628 eOmn_serv_type_t mc_serv_type = (eOmn_serv_type_t)serviceConfig.
ethservice.configuration.type;
3629 if(iNeedCouplingsInfo())
3631 for (
int r=0; r<_njoints; r++)
3633 for (
int c = 0; c < _njoints; c++)
3637 ret.addFloat64(_couplingInfo.
matrixJ2M[4 * r + c]);
3643 ret.addFloat64(0.0);
3647 else if (key ==
"encoders")
3649 Bottle& r = val.addList();
for (
int i = 0; i < _njoints; i++) { r.addFloat64(_measureConverter->posA2E(1.0, i)); }
3652 else if (key ==
"rotorEncoderResolution")
3654 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getRotorEncoderResolutionRaw(i, tmp); r.addFloat64(tmp); }
3657 else if (key ==
"jointEncoderResolution")
3659 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getJointEncoderResolutionRaw(i, tmp); r.addFloat64(tmp); }
3662 else if (key ==
"gearbox_M2J")
3664 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp=0;
getGearboxRatioRaw(i, &tmp); r.addFloat64(tmp); }
3667 else if (key ==
"gearbox_E2J")
3669 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp=0; getGerabox_E2J(i, &tmp); r.addFloat64(tmp); }
3672 else if (key ==
"hasHallSensor")
3674 Bottle& r = val.addList();
for (
int i = 0; i < _njoints; i++) {
int tmp = 0;
getHasHallSensorRaw(i, tmp); r.addInt32(tmp); }
3677 else if (key ==
"hasTempSensor")
3679 Bottle& r = val.addList();
for (
int i = 0; i < _njoints; i++) {
int tmp = 0;
getHasTempSensorsRaw(i, tmp); r.addInt32(tmp); }
3682 else if (key ==
"TemperatureSensorType")
3684 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) { std::string tmp =
"";
getTemperatureSensorTypeRaw(i, tmp); r.addString(tmp); }
3687 else if (key ==
"hasRotorEncoder")
3689 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
int tmp = 0;
getHasRotorEncoderRaw(i, tmp); r.addInt32(tmp); }
3692 else if (key ==
"hasRotorEncoderIndex")
3694 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
int tmp = 0;
getHasRotorEncoderIndexRaw(i, tmp); r.addInt32(tmp); }
3697 else if (key ==
"rotorIndexOffset")
3699 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getRotorIndexOffsetRaw(i, tmp); r.addFloat64(tmp); }
3702 else if (key ==
"motorPoles")
3704 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
int tmp = 0;
getMotorPolesRaw(i, tmp); r.addInt32(tmp); }
3707 else if (key ==
"pidCurrentKp")
3709 Bottle& r = val.addList();
for (
int i = 0; i < _njoints; i++) { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p); r.addFloat64(
p.kp); }
3712 else if (key ==
"pidCurrentKi")
3714 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p); r.addFloat64(
p.ki); }
3717 else if (key ==
"pidCurrentShift")
3719 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p); r.addFloat64(
p.scale); }
3722 else if (key ==
"pidCurrentOutput")
3724 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p); r.addFloat64(
p.max_output); }
3727 else if (key ==
"jointEncoderType")
3729 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++)
3735 yError(
"Invalid jointEncoderType");
3741 else if (key ==
"rotorEncoderType")
3743 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++)
3749 yError(
"Invalid motorEncoderType");
3755 else if (key ==
"coulombThreshold")
3757 val.addString(
"not implemented yet");
3760 else if (key ==
"torqueControlFilterType")
3765 else if (key ==
"torqueControlEnabled")
3768 Bottle& r = val.addList();
3769 for(
int i = 0; i<_njoints; i++)
3771 r.addInt32((
int)_trq_pids[i].enabled );
3775 else if (key ==
"PWMLimit")
3777 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getPWMLimitRaw(i, &tmp); r.addFloat64(tmp); }
3780 else if (key ==
"motOverloadCurr")
3782 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getMaxCurrentRaw(i, &tmp); r.addFloat64(tmp); }
3785 else if (key ==
"motNominalCurr")
3787 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getNominalCurrentRaw(i, &tmp); r.addFloat64(tmp); }
3790 else if (key ==
"motPeakCurr")
3792 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getPeakCurrentRaw(i, &tmp); r.addFloat64(tmp); }
3795 else if (key ==
"PowerSuppVoltage")
3797 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getPowerSupplyVoltageRaw(i, &tmp); r.addFloat64(tmp); }
3800 else if (key ==
"rotorMax")
3803 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getRotorLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp2); }
3806 else if (key ==
"rotorMin")
3809 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getRotorLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp1); }
3812 else if (key ==
"jointMax")
3815 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp2); }
3818 else if (key ==
"jointMin")
3821 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp1); }
3824 else if (key ==
"jointEncTolerance")
3827 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0; getJointEncTolerance(i, &tmp1); r.addFloat64(tmp1); }
3830 else if (key ==
"motorEncTolerance")
3833 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0; getMotorEncTolerance(i, &tmp1); r.addFloat64(tmp1); }
3836 else if (key ==
"jointDeadZone")
3839 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0; getJointDeadZoneRaw(i, tmp1); r.addFloat64(tmp1); }
3842 else if (key ==
"readonly_position_PIDraw")
3844 Bottle& r = val.addList();
3845 for (
int i = 0; i < _njoints; i++)
3847 getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_POSITION, i, &
p);
3849 snprintf(buff, 1000,
"J %d : kp %+3.3f ki %+3.3f kd %+3.3f maxint %+3.3f maxout %+3.3f off %+3.3f scale %+3.3f up %+3.3f dwn %+3.3f kff %+3.3f", i,
p.kp,
p.ki,
p.kd,
p.max_int,
p.max_output,
p.offset,
p.scale,
p.stiction_up_val,
p.stiction_down_val,
p.kff);
3854 else if (key ==
"readonly_velocity_PIDraw")
3856 Bottle& r = val.addList();
3857 for (
int i = 0; i < _njoints; i++)
3858 { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, i, &
p);
3860 snprintf(buff, 1000,
"J %d : kp %+3.3f ki %+3.3f kd %+3.3f maxint %+3.3f maxout %+3.3f off %+3.3f scale %+3.3f up %+3.3f dwn %+3.3f kff %+3.3f", i,
p.kp,
p.ki,
p.kd,
p.max_int,
p.max_output,
p.offset,
p.scale,
p.stiction_up_val,
p.stiction_down_val,
p.kff);
3865 else if (key ==
"readonly_torque_PIDraw")
3867 Bottle& r = val.addList();
3868 for (
int i = 0; i < _njoints; i++)
3869 { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_TORQUE, i, &
p);
3871 snprintf(buff, 1000,
"J %d : kp %+3.3f ki %+3.3f kd %+3.3f maxint %+3.3f maxout %+3.3f off %+3.3f scale %+3.3f up %+3.3f dwn %+3.3f kff %+3.3f", i,
p.kp,
p.ki,
p.kd,
p.max_int,
p.max_output,
p.offset,
p.scale,
p.stiction_up_val,
p.stiction_down_val,
p.kff);
3876 else if (key ==
"readonly_current_PIDraw")
3878 Bottle& r = val.addList();
3879 for (
int i = 0; i < _njoints; i++)
3880 { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p);
3882 snprintf(buff, 1000,
"J %d : kp %+3.3f ki %+3.3f kd %+3.3f maxint %+3.3f maxout %+3.3f off %+3.3f scale %+3.3f up %+3.3f dwn %+3.3f kff %+3.3f", i,
p.kp,
p.ki,
p.kd,
p.max_int,
p.max_output,
p.offset,
p.scale,
p.stiction_up_val,
p.stiction_down_val,
p.kff);
3887 else if (key ==
"readonly_llspeed_PIDraw")
3889 Bottle& r = val.addList();
3890 for (
int i = 0; i < _njoints; i++)
3892 Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, i, &
p);
3894 snprintf(buff, 1000,
"J %d : kp %+3.3f ki %+3.3f kd %+3.3f maxint %+3.3f maxout %+3.3f off %+3.3f scale %+3.3f up %+3.3f dwn %+3.3f kff %+3.3f", i,
p.kp,
p.ki,
p.kd,
p.max_int,
p.max_output,
p.offset,
p.scale,
p.stiction_up_val,
p.stiction_down_val,
p.kff);
3899 else if (key ==
"readonly_motor_torque_params_raw")
3901 Bottle& r = val.addList();
3902 for (
int i = 0; i < _njoints; i++)
3904 MotorTorqueParameters params;
3907 snprintf(buff, 1000,
"J %d : bemf %+3.3f bemf_scale %+3.3f ktau %+3.3f ktau_scale %+3.3f viscousPos %+3.3f viscousNeg %+3.3f coulombPos %+3.3f coulombNeg %+3.3f velocityThres %+3.3f", i, params.bemf, params.bemf_scale, params.ktau, params.ktau_scale, params.viscousPos, params.viscousNeg, params.coulombPos, params.coulombNeg, params.velocityThres);
3912 yWarning(
"getRemoteVariable(): Unknown variable %s", key.c_str());
3918 string s1 = val.toString();
3919 if (val.size() != _njoints)
3921 yWarning(
"setRemoteVariable(): Protocol error %s", s1.c_str());
3925 if (key ==
"kinematic_mj")
3927 yWarning(
"setRemoteVariable(): Impossible to set kinematic_mj parameter at runtime.");
3940 else if (key ==
"PWMLimit")
3942 for (
int i = 0; i < _njoints; i++)
setPWMLimitRaw(i, val.get(i).asFloat64());
3947 else if (key ==
"jointMax")
3950 for (
int i = 0; i < _njoints; i++)
3957 else if (key ==
"jointMin")
3960 for (
int i = 0; i < _njoints; i++)
3967 yWarning(
"setRemoteVariable(): Unknown variable %s", key.c_str());
3973 listOfKeys->clear();
3974 listOfKeys->addString(
"kinematic_mj");
3975 listOfKeys->addString(
"encoders");
3976 listOfKeys->addString(
"gearbox_M2J");
3977 listOfKeys->addString(
"gearbox_E2J");
3978 listOfKeys->addString(
"hasHallSensor");
3979 listOfKeys->addString(
"hasTempSensor");
3980 listOfKeys->addString(
"TemperatureSensorType");
3981 listOfKeys->addString(
"hasRotorEncoder");
3982 listOfKeys->addString(
"hasRotorEncoderIndex");
3983 listOfKeys->addString(
"rotorIndexOffset");
3984 listOfKeys->addString(
"rotorEncoderResolution");
3985 listOfKeys->addString(
"jointEncoderResolution");
3986 listOfKeys->addString(
"motorPoles");
3987 listOfKeys->addString(
"pidCurrentKp");
3988 listOfKeys->addString(
"pidCurrentKi");
3989 listOfKeys->addString(
"pidCurrentShift");
3990 listOfKeys->addString(
"pidCurrentOutput");
3991 listOfKeys->addString(
"coulombThreshold");
3992 listOfKeys->addString(
"torqueControlFilterType");
3993 listOfKeys->addString(
"jointEncoderType");
3994 listOfKeys->addString(
"rotorEncoderType");
3995 listOfKeys->addString(
"PWMLimit");
3996 listOfKeys->addString(
"motOverloadCurr");
3997 listOfKeys->addString(
"motNominalCurr");
3998 listOfKeys->addString(
"motPeakCurr");
3999 listOfKeys->addString(
"PowerSuppVoltage");
4000 listOfKeys->addString(
"rotorMax");
4001 listOfKeys->addString(
"rotorMin");
4002 listOfKeys->addString(
"jointMax");
4003 listOfKeys->addString(
"jointMin");
4004 listOfKeys->addString(
"jointEncTolerance");
4005 listOfKeys->addString(
"motorEncTolerance");
4006 listOfKeys->addString(
"jointDeadZone");
4007 listOfKeys->addString(
"readonly_position_PIDraw");
4008 listOfKeys->addString(
"readonly_velocity_PIDraw");
4009 listOfKeys->addString(
"readonly_current_PIDraw");
4010 listOfKeys->addString(
"readonly_torque_PIDraw");
4011 listOfKeys->addString(
"readonly_motor_torque_params_raw");
4023 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_config);
4025 eOmc_joint_config_t joint_cfg;
4026 if(! askRemoteValue(protoid, &joint_cfg, size))
4029 *max = joint_cfg.maxvelocityofjoint;
4045 return VAS_status::VAS_OK;
4057 for(
int j=0; j< _njoints; j++)
4066 int j = _axisMap[userLevel_jointNumber];
4068 eOmeas_torque_t meas_torque = 0;
4069 static double curr_time = Time::now();
4070 static int count_saturation=0;
4072 meas_torque = (eOmeas_torque_t)
S_32(_measureConverter->trqN2S(fTorque, j));
4074 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_inputs_externallymeasuredtorque);
4089 eOmc_joint_status_core_t jstatus;
4090 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
4092 *t = (double) _measureConverter->trqS2N(jstatus.measures.meas_torque, j);
4099 for(
int j=0; j<_njoints; j++)
4117 for(
int j=0; j<_njoints && ret; j++)
4124 eOmc_setpoint_t setpoint;
4125 setpoint.type = (eOenum08_t) eomc_setpoint_torque;
4126 setpoint.to.torque.value = (eOmeas_torque_t)
S_32(t);
4128 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
4135 for(
int j=0; j< n_joint; j++)
4145 for(
int j=0; j<_njoints && ret; j++)
4152 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
4153 eOmc_joint_status_core_t jcore = {0};
4159 yError() <<
"embObjMotionControl::getRefTorqueRaw() could not read pid torque reference pos for " << getBoardInfo() <<
"joint " << j;
4163 if ((eOmc_interactionmode_compliant == jcore.modes.interactionmodestatus) &&
4164 (eomc_controlmode_position == jcore.modes.controlmodestatus))
4166 *t = (double) jcore.ofpid.complpos.reftrq;
4169 if(eomc_controlmode_torque == jcore.modes.controlmodestatus)
4171 *t = (double) jcore.ofpid.torque.reftrq;
4177bool embObjMotionControl::helper_setTrqPidRaw(
int j,
const Pid &pid)
4185 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtorque);
4189bool embObjMotionControl::helper_getTrqPidRaw(
int j, Pid *pid)
4191 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtorque);
4195 if(! askRemoteValue(protoid, &eoPID, size))
4204bool embObjMotionControl::helper_getTrqPidsRaw(Pid *pid)
4206 std::vector<eOmc_PID_t> eoPIDList (_njoints);
4207 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_config_pidtorque, eoPIDList);
4210 for(
int j=0; j< _njoints; j++)
4222 eOmc_impedance_t val;
4227 *stiffness = (double) (val.stiffness);
4228 *damping = (double) (val.damping);
4236 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_impedance);
4238 if(! askRemoteValue(protoid, &imped, size))
4242 _cacheImpedance->damping = imped.damping;
4243 _cacheImpedance->stiffness = imped.stiffness;
4244 _cacheImpedance->offset = imped.offset;
4251 eOmc_impedance_t val;
4259 _cacheImpedance[j].stiffness = (eOmeas_stiffness_t) stiffness;
4260 _cacheImpedance[j].damping = (eOmeas_damping_t) damping;
4262 val.stiffness = _cacheImpedance[j].stiffness;
4263 val.damping = _cacheImpedance[j].damping;
4264 val.offset = _cacheImpedance[j].offset;
4266 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_impedance);
4276 eOmc_impedance_t val;
4282 _cacheImpedance[j].offset = (eOmeas_torque_t)
S_32(
offset);
4283 val.stiffness = _cacheImpedance[j].stiffness;
4284 val.damping = _cacheImpedance[j].damping;
4285 val.offset = _cacheImpedance[j].offset;
4287 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_impedance);
4297 eOmc_impedance_t val;
4308 *min_stiff = _impedance_limits[j].
min_stiff;
4309 *max_stiff = _impedance_limits[j].
max_stiff;
4310 *min_damp = _impedance_limits[j].
min_damp;
4311 *max_damp = _impedance_limits[j].
max_damp;
4317 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_motor_params);
4320 eOmc_motor_params_t eo_params = {0};
4321 if(! askRemoteValue(protoid, &eo_params, size))
4324 params->bemf = eo_params.bemf_value;
4325 params->bemf_scale = eo_params.bemf_scale;
4326 params->ktau = eo_params.ktau_value;
4327 params->ktau_scale = eo_params.ktau_scale;
4328 params->viscousPos = eo_params.friction.viscous_pos_val;
4329 params->viscousNeg = eo_params.friction.viscous_neg_val ;
4330 params->coulombPos = eo_params.friction.coulomb_pos_val;
4331 params->coulombNeg = eo_params.friction.coulomb_neg_val;
4332 params->velocityThres = eo_params.friction.velocityThres_val;
4341 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_motor_params);
4342 eOmc_motor_params_t eo_params = {0};
4346 eo_params.bemf_value = (float) params.bemf;
4347 eo_params.bemf_scale = (uint8_t) params.bemf_scale;
4348 eo_params.ktau_value = (float) params.ktau;
4349 eo_params.ktau_scale = (uint8_t) params.ktau_scale;
4350 eo_params.friction.viscous_pos_val =
static_cast<float32_t
>(params.viscousPos);
4351 eo_params.friction.viscous_neg_val =
static_cast<float32_t
>(params.viscousNeg);
4352 eo_params.friction.coulomb_pos_val =
static_cast<float32_t
>(params.coulombPos);
4353 eo_params.friction.coulomb_neg_val =
static_cast<float32_t
>(params.coulombNeg);
4354 eo_params.friction.velocityThres_val =
static_cast<float32_t
>(params.velocityThres);
4359 yError() <<
"embObjMotionControl::setMotorTorqueParamsRaw() could not send set message for" << getBoardInfo() <<
"joint " << j;
4371 for(
int j=0; j< n_joint; j++)
4405bool embObjMotionControl::helper_getVelPidRaw(
int j, Pid *pid)
4407 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_piddirect);
4410 if(! askRemoteValue(protoid, &eoPID, size))
4420bool embObjMotionControl::helper_getVelPidsRaw(Pid *pid)
4422 std::vector <eOmc_PID_t> eoPIDList (_njoints);
4423 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_config_piddirect, eoPIDList);
4427 for(
int j=0; j<_njoints; j++)
4442 if (mode != VOCAB_CM_POSITION_DIRECT &&
4443 mode != VOCAB_CM_IDLE)
4447 yError() <<
"setReferenceRaw: skipping command because" << getBoardInfo() <<
" joint " << j <<
" is not in VOCAB_CM_POSITION_DIRECT mode";
4452 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
4453 eOmc_setpoint_t setpoint = {0};
4455 _ref_positions[j] = ref;
4456 setpoint.type = (eOenum08_t) eomc_setpoint_positionraw;
4457 setpoint.to.position.value = (eOmeas_position_t)
S_32(ref);
4458 setpoint.to.position.withvelocity = 0;
4466 for(
int i=0; i<n_joint; i++)
4476 for (
int i = 0; i<_njoints; i++)
4486 if (axis<0 || axis>_njoints)
return false;
4487#if ASK_REFERENCE_TO_FIRMWARE
4488 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_target);
4493 eOmc_joint_status_target_t target = {0};
4494 if(!askRemoteValue(id32, &target, size))
4496 yError() <<
"embObjMotionControl::getTargetPositionRaw() could not read reference pos for " << getBoardInfo() <<
"joint " << axis;
4500 *ref = (double) target.trgt_position;
4504 *ref = _ref_command_positions[axis];
4512 for (
int i = 0; i<_njoints; i++)
4522 for (
int i = 0; i<nj; i++)
4531 if (axis<0 || axis>_njoints)
return false;
4532#if ASK_REFERENCE_TO_FIRMWARE
4533 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_target);
4538 eOmc_joint_status_target_t target = {0};
4539 if(!askRemoteValue(id32, &target, size))
4541 yError() <<
"embObjMotionControl::getRefVelocityRaw() could not read reference vel for " << getBoardInfo() <<
"joint " << axis;
4544 *ref = (double) target.trgt_velocity;
4547 *ref = _ref_command_speeds[axis];
4554 #if ASK_REFERENCE_TO_FIRMWARE
4555 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
4556 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
4559 yError() <<
"embObjMotionControl::getRefVelocitiesRaw() could not read reference vel for " << getBoardInfo() ;
4563 for(
int j=0; j<_njoints; j++)
4565 refs[j] = (double) targetList[j].trgt_velocity;
4569 for(
int j=0; j<_njoints; j++)
4571 refs[j] = _ref_command_speeds[j];
4579 std::vector <double> refsList(_njoints);
4583 for (
int i = 0; i<nj; i++)
4585 if(
jnts[i]>= _njoints)
4587 yError() << getBoardInfo() <<
"getRefVelocitiesRaw: joint " <<
jnts[i] <<
"doesn't exist";
4590 refs[i] = refsList[
jnts[i]];
4597 if (axis<0 || axis>_njoints)
return false;
4598#if ASK_REFERENCE_TO_FIRMWARE
4599 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_target);
4603 eOmc_joint_status_target_t target = {0};
4604 if(!askRemoteValue(id32, &target, size))
4606 yError() <<
"embObjMotionControl::getRefPositionRaw() could not read reference pos for " << getBoardInfo() <<
"joint " << axis;
4610 *ref = (double) target.trgt_positionraw;
4613 *ref = _ref_positions[axis];
4620 #if ASK_REFERENCE_TO_FIRMWARE
4621 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
4622 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
4625 yError() <<
"embObjMotionControl::getRefPositionRaw() could not read reference pos for " << getBoardInfo();
4629 for(
int j=0; j< _njoints; j++)
4630 refs[j] = (
double) targetList[j].trgt_positionraw;
4633 for(
int j=0; j< _njoints; j++)
4634 refs[j] = _ref_positions[j];
4642 for (
int i = 0; i<nj; i++)
4655 eOenum08_t interactionmodestatus;
4658 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core_modes_interactionmodestatus);
4662 int tmp = (int) *_mode;
4666 *_mode = (yarp::dev::InteractionModeEnum) tmp;
4685 for(
int j=0; j<_njoints; j++)
4695 eOenum08_t interactionmodecommand = 0;
4700 if (_mode == VOCAB_IM_COMPLIANT && _trq_pids[j].enabled ==
false) {yError()<<
"Torque control is disabled. Check your configuration parameters";
return false;}
4704 yError() <<
"setInteractionModeRaw: received unknown mode for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
4707 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_interactionmode);
4709 if(
false == res->
setRemoteValue(protid, &interactionmodecommand) )
4711 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
4717 eOenum08_t interactionmodestatus = 0;
4719 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_interactionmodestatus);
4720 bool ret = askRemoteValue(id32, &interactionmodestatus, size);
4722 if((
false == ret) || (interactionmodecommand != interactionmodestatus))
4724 yError() <<
"check of embObjMotionControl::setInteractionModeRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
4737 eOenum08_t interactionmodecommand = 0;
4739 for(
int j=0; j<n_joints; j++)
4741 if (modes[j] == VOCAB_IM_COMPLIANT && _trq_pids[j].enabled ==
false) {yError()<<
"Torque control is disabled. Check your configuration parameters";
continue;}
4745 yError() <<
"embObjMotionControl::setInteractionModesRaw(): received unknown interactionMode for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]) <<
" " << modes[j];
4749 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_interactionmode);
4750 if(
false == res->
setRemoteValue(protid, &interactionmodecommand) )
4752 yError() <<
"embObjMotionControl::setInteractionModesRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4758 eOenum08_t interactionmodestatus = 0;
4760 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_interactionmodestatus);
4761 bool ret = askRemoteValue(id32, &interactionmodestatus, size);
4763 if((
false == ret) || (interactionmodecommand != interactionmodestatus))
4767 yError() <<
"check of embObjMotionControl::setInteractionModesRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4773 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4774 << Vocab32::decode(modes[j]) <<
" Got " << Vocab32::decode(tmp);
4776 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4777 << Vocab32::decode(modes[j]) <<
" Got an unknown value!";
4790 eOenum08_t interactionmodecommand = 0;
4792 for(
int j=0; j<_njoints; j++)
4794 if ((modes[j] == VOCAB_IM_COMPLIANT) && (_trq_pids[j].enabled ==
false))
4796 yError()<<
"Torque control is disabled. Check your configuration parameters";
4802 yError() <<
"setInteractionModeRaw: received unknown interactionMode for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4806 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_interactionmode);
4807 if(
false == res->
setRemoteValue(protid, &interactionmodecommand) )
4809 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4815 eOenum08_t interactionmodestatus = 0;
4817 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_interactionmodestatus);
4818 bool ret = askRemoteValue(id32, &interactionmodestatus, size);
4820 if((
false == ret) || (interactionmodecommand != interactionmodestatus))
4824 yError() <<
"check of embObjMotionControl::setInteractionModesRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4830 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4831 << Vocab32::decode(modes[j]) <<
" Got " << Vocab32::decode(tmp);
4833 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4834 << Vocab32::decode(modes[j]) <<
" Got an unknown value!";
4847 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
4848 eOmc_joint_status_core_t jcore = {0};
4855 case VOCAB_PIDTYPE_POSITION:
4856 if((eomc_controlmode_torque == jcore.modes.controlmodestatus) || (eomc_controlmode_current == jcore.modes.controlmodestatus))
4859 *
out = (double) jcore.ofpid.generic.output;
4864 case VOCAB_PIDTYPE_TORQUE:
4865 if ((eomc_controlmode_torque == jcore.modes.controlmodestatus) ||
4866 ((eomc_controlmode_position == jcore.modes.controlmodestatus) && (eOmc_interactionmode_compliant == jcore.modes.interactionmodestatus)))
4867 *
out = jcore.ofpid.generic.output;
4871 case VOCAB_PIDTYPE_CURRENT:
4874 case VOCAB_PIDTYPE_VELOCITY:
4878 yError()<<
"Invalid pidtype:"<<pidtype;
4887 for(
int j=0; j< _njoints; j++)
4907 eOmc_motor_status_basic_t status;
4908 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
4918 yError() << getBoardInfo() <<
"At timestamp" << yarp::os::Time::now() <<
"In motor" << m <<
"embObjMotionControl::getTemperatureRaw failed to complete getLocalValue()";
4922 *val = _temperatureSensorsVector.at(m)->convertRawToTempCelsius((
double)status.mot_temperature);
4931 for(
int j=0; j< _njoints; j++)
4940 *temp= _temperatureLimits[m].warningTemperatureLimit;
4947 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_temperaturelimit);
4948 eOmeas_temperature_t temperatureLimit = (eOmeas_pwm_t)
S_16(temp);
4955 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
4957 eOmc_current_limits_params_t currentlimits = {0};
4959 if(!askRemoteValue(protid, ¤tlimits, size))
4961 yError() <<
"embObjMotionControl::getPeakCurrentRaw() can't read current limits for" << getBoardInfo() <<
" motor " << m;
4965 *val = (double) currentlimits.peakCurrent ;
4971 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
4974 eOmc_current_limits_params_t currentlimits = {0};
4975 if(!askRemoteValue(protid, ¤tlimits, size))
4977 yError() <<
"embObjMotionControl::setPeakCurrentRaw can't read current limits for" << getBoardInfo() <<
" motor " << m ;
4982 currentlimits.peakCurrent = (eOmeas_current_t)
S_16(val);
4988 yError() <<
"embObjMotionControl::setPeakCurrentRaw failed sending new value for" << getBoardInfo() <<
" motor " << m ;
4995 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
4997 eOmc_current_limits_params_t currentlimits = {0};
4999 if(!askRemoteValue(protid, ¤tlimits, size))
5001 yError() <<
"embObjMotionControl::getNominalCurrentRaw() can't read current limits for" << getBoardInfo() <<
" motor " << m;
5005 *val = (double) currentlimits.nominalCurrent ;
5011 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
5015 eOmc_current_limits_params_t currentlimits = {0};
5016 if(!askRemoteValue(protid, ¤tlimits, size))
5018 yError() <<
"embObjMotionControl::setNominalCurrentRaw can't read current limits for" << getBoardInfo() <<
" motor " << m ;
5023 currentlimits.nominalCurrent = (eOmeas_current_t)
S_16(val);
5029 yError() <<
"embObjMotionControl::setNominalCurrentRaw failed sending new value for" << getBoardInfo() <<
" motor " << m ;
5037 eOmc_motor_status_basic_t status;
5038 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_status_basic);
5043 *val = (double) status.mot_pwm;
5047 yError() <<
"embObjMotionControl::getPWMRaw failed for" << getBoardInfo() <<
" motor " << j ;
5056 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pwmlimit);
5058 eOmeas_pwm_t motorPwmLimit;
5060 bool ret = askRemoteValue(protid, &motorPwmLimit, size);
5063 *val = (double) motorPwmLimit;
5067 yError() <<
"embObjMotionControl::getPWMLimitRaw failed for" << getBoardInfo() <<
" motor " << j ;
5078 yError() <<
"embObjMotionControl::setPWMLimitRaw failed because pwmLimit is negative for" << getBoardInfo() <<
" motor " << j ;
5081 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pwmlimit);
5082 eOmeas_pwm_t motorPwmLimit = (eOmeas_pwm_t)
S_16(val);
5088 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_controller, 0, eoprot_tag_mc_controller_status);
5090 eOmc_controller_status_t controllerStatus;
5092 bool ret = askRemoteValue(protid, &controllerStatus, size);
5095 *val = (double) controllerStatus.supplyVoltage;
5099 yError() <<
"embObjMotionControl::getPowerSupplyVoltageRaw failed for" << getBoardInfo() <<
" motor " << j ;
5106bool embObjMotionControl::askRemoteValue(eOprotID32_t id32,
void* value, uint16_t& size)
5113bool embObjMotionControl::askRemoteValues(eOprotEndpoint_t ep, eOprotEntity_t entity, eOprotTag_t tag, std::vector<T>& values)
5115 std::vector<eOprotID32_t> idList;
5116 std::vector<void*> valueList;
5119 for(
int j=0; j<_njoints; j++)
5121 eOprotID32_t protoId = eoprot_ID_get(ep, entity, j, tag);
5122 idList.push_back(protoId);
5123 valueList.push_back((
void*)&values[j]);
5129 yError() <<
"embObjMotionControl::askRemoteValues failed for all joints of" << getBoardInfo();
5138bool embObjMotionControl::checkRemoteControlModeStatus(
int joint,
int target_mode)
5141 eOenum08_t temp = 0;
5144 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joint, eoprot_tag_mc_joint_status_core_modes_controlmodestatus);
5145 const double timeout = 0.250;
5146 const int maxretries = 25;
5147 const double delaybetweenqueries = 0.010;
5151 double timeofstart = yarp::os::Time::now();
5154 for( attempt = 0; attempt < maxretries; attempt++)
5156 ret = askRemoteValue(id32, &temp, size);
5159 yError (
"An error occurred inside embObjMotionControl::checkRemoteControlModeStatus(j=%d, targetmode=%s) for BOARD %s IP %s", joint, yarp::os::Vocab32::decode(target_mode).c_str(), res->
getProperties().
boardnameString.c_str(), res->
getProperties().
ipv4addrString.c_str());
5163 if(current_mode == target_mode)
5168 if((current_mode == VOCAB_CM_IDLE) && (target_mode == VOCAB_CM_FORCE_IDLE))
5173 if(current_mode == VOCAB_CM_HW_FAULT)
5175 if(target_mode != VOCAB_CM_FORCE_IDLE) { yError (
"embObjMotionControl::checkRemoteControlModeStatus(%d, %d) is unable to check the control mode of BOARD %s IP %s because it is now in HW_FAULT", joint, target_mode, res->
getProperties().
boardnameString.c_str(), res->
getProperties().
ipv4addrString.c_str()); }
5180 if((yarp::os::Time::now()-timeofstart) > timeout)
5183 yError (
"A %f sec timeout occured in embObjMotionControl::checkRemoteControlModeStatus(), BOARD %s IP %s, joint %d, current mode: %s, requested: %s", timeout, res->
getProperties().
boardnameString.c_str(), res->
getProperties().
ipv4addrString.c_str(), joint, yarp::os::Vocab32::decode(current_mode).c_str(), yarp::os::Vocab32::decode(target_mode).c_str());
5188 yWarning (
"embObjMotionControl::checkRemoteControlModeStatus() has done %d attempts and will retry again after a %f sec delay. (BOARD %s IP %s, joint %d) -> current mode = %s, requested = %s", attempt+1, delaybetweenqueries, res->
getProperties().
boardnameString.c_str() , res->
getProperties().
ipv4addrString.c_str(), joint, yarp::os::Vocab32::decode(current_mode).c_str(), yarp::os::Vocab32::decode(target_mode).c_str());
5190 SystemClock::delaySystem(delaybetweenqueries);
5195 yError(
"failure of embObjMotionControl::checkRemoteControlModeStatus(j=%d, targetmode=%s) for BOARD %s IP %s after %d attempts and %f seconds", joint, yarp::os::Vocab32::decode(target_mode).c_str(), res->
getProperties().
boardnameString.c_str(), res->
getProperties().
ipv4addrString.c_str(), attempt, yarp::os::Time::now()-timeofstart);
5203bool embObjMotionControl::iNeedCouplingsInfo(
void)
5205 eOmn_serv_type_t mc_serv_type = (eOmn_serv_type_t)serviceConfig.
ethservice.configuration.type;
5206 if( (mc_serv_type == eomn_serv_MC_foc) ||
5207 (mc_serv_type == eomn_serv_MC_mc4plus) ||
5208 (mc_serv_type == eomn_serv_MC_mc4plusmais) ||
5209 (mc_serv_type == eomn_serv_MC_mc2pluspsc) ||
5210 (mc_serv_type == eomn_serv_MC_mc4plusfaps) ||
5211 (mc_serv_type == eomn_serv_MC_advfoc)
5221 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
5223 eOmc_setpoint_t setpoint;
5225 setpoint.type = (eOenum08_t)eomc_setpoint_openloop;
5226 setpoint.to.openloop.value = (eOmeas_pwm_t)
S_16(v);
5234 for (
int j = 0; j<_njoints; j++)
5243 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_target);
5246 eOmc_joint_status_target_t target = { 0 };
5249 if (!askRemoteValue(protoId, &target, size))
5251 yError() <<
"embObjMotionControl::getRefDutyCycleRaw() could not read openloop reference for " << getBoardInfo() <<
"joint " << j;
5255 *v = (double)target.trgt_pwm;
5262 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
5263 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
5266 yError() <<
"embObjMotionControl::getDutyCyclesRaw failed for all joints of" << getBoardInfo();
5269 for (
int j = 0; j<_njoints; j++)
5271 v[j]= targetList[j].trgt_pwm;
5278 eOmc_motor_status_basic_t status;
5279 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_status_basic);
5284 *v = (double)status.mot_pwm;
5288 yError() <<
"embObjMotionControl::getDutyCycleRaw failed for" << getBoardInfo() <<
" motor " << j;
5298 for (
int j = 0; j< _njoints; j++)
5320 for (
int j = 0; j< _njoints; j++)
5330 for (
int j = 0; j<_njoints; j++)
5339 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
5341 eOmc_setpoint_t setpoint;
5343 setpoint.type = (eOenum08_t)eomc_setpoint_current;
5344 setpoint.to.current.value = (eOmeas_pwm_t)
S_16(t);
5352 for (
int j = 0; j<n_joint; j++)
5361 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
5362 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
5365 yError() <<
"embObjMotionControl::getDutyCyclesRaw failed for all joints of" << getBoardInfo();
5368 for (
int j = 0; j<_njoints; j++)
5370 t[j] = targetList[j].trgt_current;
5377 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_target);
5380 eOmc_joint_status_target_t target = { 0 };
5383 if (!askRemoteValue(protoId, &target, size))
5385 yError() <<
"embObjMotionControl::getRefDutyCycleRaw() could not read openloop reference for " << getBoardInfo() <<
"joint " << j;
5389 *t = (double)target.trgt_current;
5394bool embObjMotionControl::helper_setCurPidRaw(
int j,
const Pid &pid)
5396 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pidcurrent);
5400 if (!_cur_pids[j].enabled)
5402 yError() <<
"eoMc " << getBoardInfo() <<
": it is not possible set current pid for motor " << j <<
", because current pid is not enabled in xml files";
5410 yError() <<
"while setting velocity PIDs for" << getBoardInfo() <<
" joint " << j;
5419bool embObjMotionControl::helper_setSpdPidRaw(
int j,
const Pid &pid)
5421 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pidspeed);
5425 if (!_cur_pids[j].enabled)
5427 yError() <<
"eoMc " << getBoardInfo() <<
": it is not possible set speed pid for motor " << j <<
", because speed pid is not enabled in xml files";
5435 yError() <<
"while setting velocity PIDs for" << getBoardInfo() <<
" joint " << j;
5444bool embObjMotionControl::helper_getCurPidRaw(
int j, Pid *pid)
5446 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
5448 eOmc_motor_config_t motor_cfg;
5449 if(! askRemoteValue(protoid, &motor_cfg, size))
5453 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg.pidcurrent;
5459bool embObjMotionControl::helper_getSpdPidRaw(
int j, Pid *pid)
5461 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
5463 eOmc_motor_config_t motor_cfg;
5464 if (!askRemoteValue(protoid, &motor_cfg, size))
5468 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg.pidspeed;
5474bool embObjMotionControl::helper_getCurPidsRaw(Pid *pid)
5476 std::vector <eOmc_motor_config_t> motor_cfg_list(_njoints);
5477 bool ret = askRemoteValues<eOmc_motor_config_t>(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, eoprot_tag_mc_motor_config, motor_cfg_list);
5481 for(
int j=0; j<_njoints; j++)
5483 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg_list[j].pidcurrent;
5489bool embObjMotionControl::helper_getSpdPidsRaw(Pid *pid)
5491 std::vector <eOmc_motor_config_t> motor_cfg_list(_njoints);
5492 bool ret = askRemoteValues<eOmc_motor_config_t>(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, eoprot_tag_mc_motor_config, motor_cfg_list);
5496 for (
int j = 0; j<_njoints; j++)
5498 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg_list[j].pidspeed;
5504bool embObjMotionControl::getJointConfiguration(
int joint, eOmc_joint_config_t *jntCfg_ptr)
5506 uint32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joint, eoprot_tag_mc_joint_config);
5508 if(!askRemoteValue(protoid, jntCfg_ptr, size))
5516bool embObjMotionControl::getMotorConfiguration(
int axis, eOmc_motor_config_t *motCfg_ptr)
5518 uint32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, axis, eoprot_tag_mc_motor_config);
5520 if(!askRemoteValue(protoid, motCfg_ptr, size))
5529bool embObjMotionControl::getGerabox_E2J(
int joint,
double *gearbox_E2J_ptr)
5531 eOmc_joint_config_t jntCfg;
5533 if(!getJointConfiguration(joint, &jntCfg))
5538 *gearbox_E2J_ptr = jntCfg.gearbox_E2J;
5542bool embObjMotionControl::getJointEncTolerance(
int joint,
double *jEncTolerance_ptr)
5544 eOmc_joint_config_t jntCfg;
5546 if(!getJointConfiguration(joint, &jntCfg))
5551 *jEncTolerance_ptr = jntCfg.jntEncTolerance;
5555bool embObjMotionControl::getMotorEncTolerance(
int axis,
double *mEncTolerance_ptr)
5557 eOmc_motor_config_t motorCfg;
5558 if(!getMotorConfiguration(axis, &motorCfg))
5563 *mEncTolerance_ptr = motorCfg.rotEncTolerance;
5569 eOmc_motor_status_t status;
5571 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol,
5572 eoprot_entity_mc_motor, j,
5573 eoprot_tag_mc_motor_status);
5582 message =
"Could not retrieve the fault state.";
5586 if (status.mc_fault_state == EOERROR_CODE_DUMMY)
5588 fault = EOERROR_CODE_DUMMY;
5589 message =
"No fault detected.";
5594 fault = eoerror_code2value(status.mc_fault_state);
5595 message = eoerror_code2string(status.mc_fault_state);
5600bool embObjMotionControl::getRawData_core(std::string key, std::vector<std::int32_t> &
data)
5605 for(
int j=0; j< _njoints; j++)
5607 eOmc_joint_status_additionalInfo_t addinfo;
5608 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_addinfo_multienc);
5613 for (
int k = 0; k < std::size(addinfo.multienc); k++)
5615 data.push_back((int32_t)addinfo.multienc[k]);
5624 for (
auto it = _rawValuesMetadataMap.begin(); it != _rawValuesMetadataMap.end(); it++)
5626 if(!getRawData_core(it->first, _rawDataAuxVector))
5628 yError() << getBoardInfo() <<
"getRawData failed. Cannot retrieve all raw data from local memory";
5631 map.insert({it->first, _rawDataAuxVector});
5639 if(_rawValuesMetadataMap.find(key) != _rawValuesMetadataMap.end())
5641 getRawData_core(key,
data);
5645 yError() << getBoardInfo() <<
"Request key:" << key <<
"is not available. Cannot retrieve get raw data.";
5654 for (
const auto &
p : _rawValuesMetadataMap)
5656 keys.push_back(
p.first);
5664 return _rawValuesMetadataMap.size();
5669 if (_rawValuesMetadataMap.empty())
5671 yError() << getBoardInfo() <<
"embObjMotionControl Map is empty. Closing...";
5680 if(_rawValuesMetadataMap.find(key) != _rawValuesMetadataMap.end())
5682 meta = _rawValuesMetadataMap[key];
5686 yError() << getBoardInfo() <<
"Requested key" << key <<
"is not available in the map. Closing...";
bool NOT_YET_IMPLEMENTED(const char *txt)
bool DEPRECATED(const char *txt)
#define MAX_POSITION_MOVE_INTERVAL
servMC_encoder_t * getEncoderAtMotor(int index)
bool parseService(yarp::os::Searchable &config, servConfigMais_t &maisconfig)
servMC_encoder_t * getEncoderAtJoint(int index)
virtual bool setcheckRemoteValue(const eOprotID32_t id32, void *value, const unsigned int retries=10, const double waitbeforecheck=0.001, const double timeout=0.050)=0
virtual bool serviceVerifyActivate(eOmn_serv_category_t category, const eOmn_serv_parameter_t *param, double timeout=0.500)=0
virtual const Properties & getProperties()=0
virtual bool setRemoteValue(const eOprotID32_t id32, void *value)=0
virtual bool verifyEPprotocol(eOprot_endpoint_t ep)=0
virtual bool getLocalValue(const eOprotID32_t id32, void *value)=0
virtual bool serviceSetRegulars(eOmn_serv_category_t category, vector< eOprotID32_t > &id32vector, double timeout=0.500)=0
virtual bool serviceStart(eOmn_serv_category_t category, double timeout=0.500)=0
virtual bool getRemoteValue(const eOprotID32_t id32, void *value, const double timeout=0.100, const unsigned int retries=0)=0
virtual bool getRemoteValues(const std::vector< eOprotID32_t > &id32s, const std::vector< void * > &values, const double timeout=0.500)=0
int releaseResource2(eth::AbstractEthResource *ethresource, IethResource *interface)
bool verifyEthBoardInfo(yarp::os::Searchable &cfgtotal, eOipv4addr_t &boardipv4, string boardipv4string, string boardname)
static bool killYourself()
static TheEthManager * instance()
eth::AbstractEthResource * requestResource2(IethResource *interface, yarp::os::Searchable &cfgtotal)
bool start()
Instantiates the yarp::os::Timer object and starts it.
bool canprint()
Called by the object that implements the downsampler.
virtual bool getPidReferenceRaw(const PidControlTypeEnum &pidtype, int j, double *ref) override
virtual bool setVelLimitsRaw(int axis, double min, double max) override
virtual bool setMaxCurrentRaw(int j, double val) override
virtual bool getMotorEncoderRaw(int m, double *v) override
virtual bool enablePidRaw(const PidControlTypeEnum &pidtype, int j) override
virtual bool getRawData(std::string key, std::vector< std::int32_t > &data) override
virtual bool setPidErrorLimitsRaw(const PidControlTypeEnum &pidtype, const double *limits) override
virtual bool setRefSpeedsRaw(const double *spds) override
virtual bool getEncoderTypeName(uint32_t jomoId, eOmc_position_t pos, std::string &encoderTypeName) override
virtual bool getTorqueRangesRaw(double *min, double *max) override
virtual bool getControlModesRaw(int *v) override
virtual bool getRefCurrentRaw(int j, double *t) override
virtual bool setInteractionModeRaw(int j, yarp::dev::InteractionModeEnum _mode) override
virtual bool getPidOutputRaw(const PidControlTypeEnum &pidtype, int j, double *out) override
virtual bool getInteractionModesRaw(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
virtual bool setInteractionModesRaw(int n_joints, int *joints, yarp::dev::InteractionModeEnum *modes) override
bool getRotorEncoderTypeRaw(int j, int &type)
virtual bool setRefAccelerationsRaw(const double *accs) override
virtual bool disablePidRaw(const PidControlTypeEnum &pidtype, int j) override
virtual bool getImpedanceRaw(int j, double *stiffness, double *damping) override
virtual bool update(eOprotID32_t id32, double timestamp, void *rxdata)
virtual bool setPidOffsetRaw(const PidControlTypeEnum &pidtype, int j, double v) override
virtual bool getPowerSupplyVoltageRaw(int j, double *val) override
virtual bool setPidsRaw(const PidControlTypeEnum &pidtype, const Pid *pids) override
virtual bool getPidErrorLimitRaw(const PidControlTypeEnum &pidtype, int j, double *limit) override
virtual bool setPeakCurrentRaw(int m, const double val) override
virtual bool enableAmpRaw(int j) override
bool getHasRotorEncoderRaw(int j, int &ret)
virtual bool setRefTorqueRaw(int j, double t) override
virtual bool relativeMoveRaw(int j, double delta) override
virtual bool disableAmpRaw(int j) override
virtual bool getRefVelocityRaw(const int joint, double *ref) override
virtual bool getEncodersRaw(double *encs) override
virtual bool getLastJointFaultRaw(int j, int &fault, std::string &message) override
virtual bool getDutyCyclesRaw(double *v) override
virtual bool getPidReferencesRaw(const PidControlTypeEnum &pidtype, double *refs) override
virtual bool getMotorEncoderAccelerationsRaw(double *accs) override
virtual bool resetMotorEncoderRaw(int m) override
virtual bool checkMotionDoneRaw(bool *flag) override
virtual bool getPWMLimitRaw(int j, double *val) override
virtual bool getControlModeRaw(int j, int *v) override
virtual bool getPWMRaw(int j, double *val) override
bool getRotorLimitsRaw(int j, double *rotorMin, double *rotorMax)
virtual bool getTorqueRaw(int j, double *t) override
virtual bool getMotorEncodersRaw(double *encs) override
virtual bool open(yarp::os::Searchable &par)
virtual bool getEncodersTimedRaw(double *encs, double *stamps) override
bool getHasHallSensorRaw(int j, int &ret)
bool getJointEncoderResolutionRaw(int m, double &jntres)
virtual bool getRefSpeedsRaw(double *spds) override
virtual bool getInteractionModeRaw(int j, yarp::dev::InteractionModeEnum *_mode) override
virtual bool getEntityName(uint32_t entityId, std::string &entityName)
virtual eth::iethresType_t type()
bool getTemperatureSensorTypeRaw(int j, std::string &ret)
virtual bool getCurrentRangesRaw(double *min, double *max) override
virtual bool getLimitsRaw(int axis, double *min, double *max) override
virtual bool setPidReferenceRaw(const PidControlTypeEnum &pidtype, int j, double ref) override
virtual bool updateVirtualAnalogSensorMeasure(yarp::sig::Vector &fTorques) override
virtual bool setImpedanceRaw(int j, double stiffness, double damping) override
virtual bool setRemoteVariableRaw(std::string key, const yarp::os::Bottle &val) override
virtual bool getCurrentsRaw(double *vals) override
virtual bool getTorqueRangeRaw(int j, double *min, double *max) override
virtual bool getTorquesRaw(double *t) override
virtual bool getAmpStatusRaw(int *st) override
virtual yarp::dev::VAS_status getVirtualAnalogSensorStatus(int ch) override
bool getHasTempSensorsRaw(int j, int &ret)
virtual bool setRefCurrentsRaw(const double *t) override
virtual bool getTargetPositionRaw(const int joint, double *ref) override
virtual bool setMotorEncoderCountsPerRevolutionRaw(int m, const double cpr) override
virtual bool getGearboxRatioRaw(int m, double *gearbox) override
virtual bool resetEncodersRaw() override
virtual bool getTemperatureLimitRaw(int m, double *temp) override
virtual bool setCalibrationParametersRaw(int axis, const CalibrationParameters ¶ms) override
virtual bool getRawDataMap(std::map< std::string, std::vector< std::int32_t > > &map) override
virtual bool setNominalCurrentRaw(int m, const double val) override
virtual bool setMotorTorqueParamsRaw(int j, const MotorTorqueParameters params) override
virtual bool setRefCurrentRaw(int j, double t) override
virtual bool setTemperatureLimitRaw(int m, const double temp) override
virtual bool getRemoteVariableRaw(std::string key, yarp::os::Bottle &val) override
virtual bool calibrationDoneRaw(int j) override
virtual bool getEncoderTimedRaw(int j, double *encs, double *stamp) override
virtual bool getMetadataMap(rawValuesKeyMetadataMap &metamap) override
virtual bool getAxisNameRaw(int axis, std::string &name) override
virtual bool setPWMLimitRaw(int j, const double val) override
virtual bool getRefAccelerationRaw(int j, double *acc) override
virtual bool resetPidRaw(const PidControlTypeEnum &pidtype, int j) override
virtual bool getPidRaw(const PidControlTypeEnum &pidtype, int j, Pid *pid) override
virtual bool setPositionRaw(int j, double ref) override
virtual bool getRefSpeedRaw(int j, double *ref) override
virtual bool setPidErrorLimitRaw(const PidControlTypeEnum &pidtype, int j, double limit) override
virtual bool setControlModesRaw(const int n_joint, const int *joints, int *modes) override
bool getRotorEncoderResolutionRaw(int m, double &rotres)
virtual bool setRefDutyCycleRaw(int j, double v) override
virtual bool getImpedanceOffsetRaw(int j, double *offset) override
bool getWholeImpedanceRaw(int j, eOmc_impedance_t &imped)
virtual bool getEncoderSpeedsRaw(double *spds) override
virtual bool setPositionsRaw(const int n_joint, const int *joints, const double *refs) override
virtual bool resetMotorEncodersRaw() override
bool getJointEncoderTypeRaw(int j, int &type)
virtual bool getNumberOfMotorEncodersRaw(int *num) override
virtual bool getPidErrorLimitsRaw(const PidControlTypeEnum &pidtype, double *limits) override
virtual bool setMotorEncoderRaw(int m, const double val) override
virtual bool stopRaw() override
virtual bool getMotorEncoderTimedRaw(int m, double *encs, double *stamp) override
virtual bool setEncoderRaw(int j, double val) override
virtual bool resetEncoderRaw(int j) override
virtual bool setPidRaw(const PidControlTypeEnum &pidtype, int j, const Pid &pid) override
virtual bool getRefAccelerationsRaw(double *accs) override
virtual bool getPidOutputsRaw(const PidControlTypeEnum &pidtype, double *outs) override
virtual bool getRefPositionsRaw(double *refs) override
virtual bool getJointTypeRaw(int axis, yarp::dev::JointTypeEnum &type) override
virtual bool calibrateAxisWithParamsRaw(int axis, unsigned int type, double p1, double p2, double p3) override
virtual bool getNominalCurrentRaw(int m, double *val) override
virtual bool initialised()
virtual bool setRefTorquesRaw(const double *t) override
virtual bool getRefDutyCyclesRaw(double *v) override
virtual bool getCurrentRaw(int j, double *val) override
bool getMotorPolesRaw(int j, int &poles)
virtual bool getCurrentRangeRaw(int j, double *min, double *max) override
virtual bool getRefTorquesRaw(double *t) override
virtual bool setEncodersRaw(const double *vals) override
virtual bool getEncoderRaw(int j, double *v) override
virtual bool getKeys(std::vector< std::string > &keys) override
virtual bool setControlModeRaw(const int j, const int mode) override
virtual bool positionMoveRaw(int j, double ref) override
bool getKinematicMJRaw(int j, double &rotres)
virtual bool setLimitsRaw(int axis, double min, double max) override
virtual bool getEncoderAccelerationRaw(int j, double *spds) override
virtual bool getMotorTorqueParamsRaw(int j, MotorTorqueParameters *params) override
virtual bool getTemperatureRaw(int m, double *val) override
virtual int getNumberOfKeys() override
virtual bool setPidReferencesRaw(const PidControlTypeEnum &pidtype, const double *refs) override
virtual bool getCurrentImpedanceLimitRaw(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp) override
virtual bool getVelLimitsRaw(int axis, double *min, double *max) override
virtual bool getRefTorqueRaw(int j, double *t) override
virtual bool getNumberOfMotorsRaw(int *num) override
virtual bool setRefSpeedRaw(int j, double sp) override
virtual bool getMotorEncoderSpeedsRaw(double *spds) override
virtual bool getMaxCurrentRaw(int j, double *val) override
virtual bool getTemperaturesRaw(double *vals) override
virtual bool getMotorEncoderCountsPerRevolutionRaw(int m, double *v) override
virtual bool getEncoderAccelerationsRaw(double *accs) override
virtual bool getPidsRaw(const PidControlTypeEnum &pidtype, Pid *pids) override
virtual bool getRemoteVariablesListRaw(yarp::os::Bottle *listOfKeys) override
bool getTorqueControlFilterType(int j, int &type)
virtual bool getRefCurrentsRaw(double *t) override
virtual bool getPidErrorRaw(const PidControlTypeEnum &pidtype, int j, double *err) override
virtual bool setImpedanceOffsetRaw(int j, double offset) override
virtual bool getRefDutyCycleRaw(int j, double *v) override
virtual bool getMotorEncodersTimedRaw(double *encs, double *stamps) override
virtual int getVirtualAnalogSensorChannels() override
bool getRotorIndexOffsetRaw(int j, double &rotorOffset)
virtual bool setMotorEncodersRaw(const double *vals) override
virtual bool isPidEnabledRaw(const PidControlTypeEnum &pidtype, int j, bool *enabled) override
virtual bool setRefAccelerationRaw(int j, double acc) override
virtual bool getEncoderSpeedRaw(int j, double *sp) override
virtual bool getMotorEncoderSpeedRaw(int m, double *sp) override
virtual bool getMotorEncoderAccelerationRaw(int m, double *spds) override
virtual bool getAxes(int *ax) override
virtual bool getRefPositionRaw(const int joint, double *ref) override
virtual bool setRefDutyCyclesRaw(const double *v) override
virtual bool getKeyMetadata(std::string key, rawValuesKeyMetadata &meta) override
virtual bool velocityMoveRaw(int j, double sp) override
virtual bool getPeakCurrentRaw(int m, double *val) override
virtual bool getPidErrorsRaw(const PidControlTypeEnum &pidtype, double *errs) override
virtual bool getRefVelocitiesRaw(double *refs) override
virtual bool getTargetPositionsRaw(double *refs) override
bool getHasRotorEncoderIndexRaw(int j, int &ret)
virtual bool getDutyCycleRaw(int j, double *v) override
bool parseJointsetCfgGroup(yarp::os::Searchable &config, std::vector< JointsSet > &jsets, std::vector< int > &jointtoset)
bool parseJointsLimits(yarp::os::Searchable &config, std::vector< jointLimits_t > &jointsLimits)
bool parseAmpsToSensor(yarp::os::Searchable &config, double ampsToSensor[])
bool parseMechanicalsFlags(yarp::os::Searchable &config, int useMotorSpeedFbk[])
bool parseMotioncontrolVersion(yarp::os::Searchable &config, int &version)
bool parseLugreGroup(yarp::os::Searchable &config, std::vector< lugreParameters_t > &lugre)
bool parseAxisInfo(yarp::os::Searchable &config, int axisMap[], std::vector< axisInfo_t > &axisInfo)
bool parseFocGroup(yarp::os::Searchable &config, focBasedSpecificInfo_t *foc_based_info, std::string groupName, std::vector< std::unique_ptr< eomc::ITemperatureSensor > > &temperatureSensorsVector)
bool parseCouplingInfo(yarp::os::Searchable &config, couplingInfo_t &couplingInfo)
bool parsePids(yarp::os::Searchable &config, PidInfo *ppids, TrqPidInfo *tpids, PidInfo *cpids, PidInfo *spids, bool lowLevPidisMandatory)
bool parseTemperatureLimits(yarp::os::Searchable &config, std::vector< temperatureLimits_t > &temperatureLimits)
bool parseDeadzoneValue(yarp::os::Searchable &config, double deadzone[], bool *found)
bool isVerboseEnabled(yarp::os::Searchable &config)
bool parseTimeoutsGroup(yarp::os::Searchable &config, std::vector< timeouts_t > &timeouts, int defaultVelocityTimeout)
bool parseCurrentLimits(yarp::os::Searchable &config, std::vector< motorCurrentLimits_t > &currLimits)
bool parseEncoderFactor(yarp::os::Searchable &config, double encoderFactor[])
bool parsefullscalePWM(yarp::os::Searchable &config, double dutycycleToPWM[])
bool parseRotorsLimits(yarp::os::Searchable &config, std::vector< rotorLimits_t > &rotorsLimits)
bool parseImpedanceGroup(yarp::os::Searchable &config, std::vector< impedanceParameters_t > &impedance)
bool parseKalmanFilterParams(yarp::os::Searchable &config, std::vector< kalmanFilterParams_t > &kalmanFilterParams)
bool parseGearboxValues(yarp::os::Searchable &config, double gearbox_M2J[], double gearbox_E2J[])
bool parseBehaviourFalgs(yarp::os::Searchable &config, bool &useRawEncoderData, bool &pwmIsLimited)
std::string usernamePidSelected
yarp::dev::PidFeedbackUnitsEnum fbk_PidUnits
eOmc_ctrl_out_type_t out_type
yarp::dev::PidOutputUnitsEnum out_PidUnits
static uint32_t idx[BOARD_NUM]
static bool nv_not_found(void)
static bool NOT_YET_IMPLEMENTED(const char *txt)
#define PARSER_MOTION_CONTROL_VERSION
static bool DEPRECATED(const char *txt)
const double jointWithAKSIM2
const double jointWithAEA3
const double jointWithAMO
const double jointWithAEA
bool EncoderType_eo2iCub(const uint8_t *in, string *out)
int controlModeStatusConvert_embObj2yarp(eOenum08_t embObjMode)
bool interactionModeStatusConvert_embObj2yarp(eOenum08_t embObjMode, int &vocabOut)
bool controlModeCommandConvert_yarp2embObj(int vocabMode, eOenum08_t &embOut)
void copyPid_eo2iCub(eOmc_PID_t *in, Pid *out)
@ motor_temperature_sensor_pt100
@ motor_temperature_sensor_pt1000
@ motor_temperature_sensor_none
void copyPid_iCub2eo(const Pid *in, eOmc_PID_t *out)
bool interactionModeCommandConvert_yarp2embObj(int vocabMode, eOenum08_t &embOut)
std::vector< BufferedPort< Bottle > * > ports
eOmn_serv_diagn_cfg_t config
eOmn_serv_parameter_t ethservice
eOmc_encoder_descriptor_t desc
bool useRawEncoderData
its value depends on environment variable "ETH_VERBOSEWHENOK"
bool pwmIsLimited
if true than do not use calibration data
std::vector< double > matrixM2J
std::vector< double > matrixE2J
std::vector< double > matrixJ2M
bool hasRotorEncoderIndex