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 yErrorOnce() << txt <<
" is not yet implemented for embObjMotionControl";
63 yErrorOnce() << 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 _maintenanceModeCfg.enableSkipRecalibration =
false;
273 std::string tmp = yarp::conf::environment::get_string(
"ETH_VERBOSEWHENOK");
276 behFlags.verbosewhenok = (bool)yarp::conf::numeric::from_string(tmp, 0U);
280 behFlags.verbosewhenok =
false;
285#ifdef NETWORK_PERFORMANCE_BENCHMARK
289 m_responseTimingVerifier.init(0.003, 0.00025, 0.001, 0.01, 0.0005, 30);
297 yTrace() <<
"embObjMotionControl::~embObjMotionControl()";
305 if(NULL != _mcparser)
323 ImplementControlCalibration::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
324 ImplementAmplifierControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.ampsToSensor);
325 ImplementEncodersTimed::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
326 ImplementMotorEncoders::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
327 ImplementPositionControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
328 ImplementPidControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.newtonsToSensor,
f.ampsToSensor,
f.dutycycleToPWM);
329 ImplementControlMode::initialize(_njoints, _axisMap);
330 ImplementVelocityControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
331 ImplementControlLimits::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
332 ImplementImpedanceControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.newtonsToSensor);
333 ImplementTorqueControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.newtonsToSensor,
f.ampsToSensor,
f.dutycycleToPWM,
f.bemf2raw,
f.ktau2raw);
334 ImplementPositionDirect::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
335 ImplementInteractionMode::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
336 ImplementMotor::initialize(_njoints, _axisMap);
337 ImplementRemoteVariables::initialize(_njoints, _axisMap);
338 ImplementAxisInfo::initialize(_njoints, _axisMap);
339 ImplementCurrentControl::initialize(_njoints, _axisMap,
f.ampsToSensor);
340 ImplementPWMControl::initialize(_njoints, _axisMap,
f.dutycycleToPWM);
341 ImplementJointFault::initialize(_njoints, _axisMap);
352 if(NULL == ethManager)
354 yFatal() <<
"embObjMotionControl::open() fails to instantiate ethManager";
358 eOipv4addr_t ipv4addr;
359 string boardIPstring;
361 if(
false == ethManager->
verifyEthBoardInfo(config, ipv4addr, boardIPstring, boardName))
363 yError() <<
"embObjMotionControl::open(): object TheEthManager fails in parsing ETH propertiex from xml file";
370 yError() << getBoardInfo() <<
"embObjMotionControl::open(): eth::parser fails to read board configuration data from xml file";
387 yError() <<
"embObjMotionControl::open() fails because could not instantiate the ethResource for " << getBoardInfo() <<
" ... unable to continue";
391 if(!fromConfig(config))
393 yError() << getBoardInfo() <<
"Missing motion control parameters in config file";
399 yError() <<
"embObjMotionControl: failed verifyEPprotocol. Cannot continue!";
405 const eOmn_serv_parameter_t* servparam = &serviceConfig.
ethservice;
406 if(eomn_serv_MC_generic == serviceConfig.
ethservice.configuration.type)
412 mcdiagnostics.
config.mode = serviceConfig.
ethservice.configuration.diagnosticsmode;
413 mcdiagnostics.
config.par16 = serviceConfig.
ethservice.configuration.diagnosticsparam;
414 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
417 mcdiagnostics.
ports.resize(2);
418 for(
size_t i=0; i<mcdiagnostics.
ports.size(); i++)
420 mcdiagnostics.
ports[i] =
new BufferedPort<Bottle>;
431 event_downsampler->
config.
info = getBoardInfo();
432 event_downsampler->
start();
436 yError() <<
"embObjMotionControl::open() has an error in call of ethResources::serviceVerifyActivate() for" << getBoardInfo();
441 yDebug() <<
"embObjMotionControl:serviceVerifyActivate OK!";
446 yError() <<
"embObjMotionControl::open() has an error in call of embObjMotionControl::init() for" << getBoardInfo();
453 yDebug() <<
"embObjMotionControl::init() has succesfully initted" << getBoardInfo();
460 yError() <<
"embObjMotionControl::open() fails to start mc service for" << getBoardInfo() <<
": cannot continue";
468 yDebug() <<
"embObjMotionControl::open() correctly starts mc service of" << getBoardInfo();
476 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
507 SystemClock::delaySystem(0.001*mcdiagnostics.
config.par16);
514int embObjMotionControl::fromConfig_NumOfJoints(yarp::os::Searchable &config)
519 int jn = config.findGroup(
"GENERAL").check(
"Joints", Value(1),
"Number of degrees of freedom").asInt32();
526void embObjMotionControl::debugUtil_printJointsetInfo(
void)
529 yError() <<
"****** DEBUG PRINTS **********";
530 yError() <<
"joint to set:";
531 for(
int x=0;
x< _njoints;
x++)
532 yError() <<
" /t j " <<
x <<
": set " <<_joint2set[
x];
533 yError() <<
"jointmap:";
535 yError() <<
" number of sets" << _jsets.size();
536 for(
size_t x=0;
x< _jsets.size();
x++)
538 yError() <<
"set " <<
x<<
"has size " <<_jsets[
x].getNumberofJoints();
539 for(
int y=0;
y<_jsets[
x].getNumberofJoints();
y++)
540 yError() <<
"set " <<
x <<
": " << _jsets[
x].joints[
y];
542 yError() <<
"********* END ****************";
549bool embObjMotionControl::verifyUserControlLawConsistencyInJointSet(
eomc::PidInfo *pidInfo)
552 for(
size_t s=0; s<_jsets.size(); s++)
554 int numofjoints = _jsets[s].getNumberofJoints();
558 yError() <<
"embObjMC" << getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
561 int firstjoint = _jsets[s].joints[0];
563 for(
int k=1; k<numofjoints; k++)
565 int otherjoint = _jsets[s].joints[k];
567 if(pidInfo[firstjoint].usernamePidSelected != pidInfo[otherjoint].usernamePidSelected)
569 yError() <<
"embObjMC "<< getBoardInfo() <<
"Joints beloning to same set must be have same control law. Joint " << otherjoint <<
" differs from " << firstjoint <<
"Set num " << s ;
582bool embObjMotionControl::verifyUserControlLawConsistencyInJointSet(
eomc::TrqPidInfo *pidInfo)
584 for(
size_t s=0; s<_jsets.size(); s++)
586 int numofjoints = _jsets[s].getNumberofJoints();
590 yError() <<
"embObjMC "<< getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
593 int firstjoint = _jsets[s].joints[0];
595 for(
int k=1; k<numofjoints; k++)
597 int otherjoint = _jsets[s].joints[k];
599 if(pidInfo[firstjoint].usernamePidSelected != pidInfo[otherjoint].usernamePidSelected)
601 yError() <<
"embObjMC"<< getBoardInfo() <<
"Joints beloning to same set must be have same control law. Joint " << otherjoint <<
" differs from " << firstjoint <<
"Set num " << s ;
611bool embObjMotionControl::updatedJointsetsCfgWithControlInfo()
615 for(
size_t s=0; s<_jsets.size(); s++)
617 if(_jsets[s].getNumberofJoints() == 0)
619 yError() <<
"embObjMC"<< getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
623 int joint = _jsets[s].joints[0];
633 _jsets[s].cfg.pid_output_types.postrj_ctrl_out_type = _trj_pids[joint].
out_type;
634 _jsets[s].cfg.pid_output_types.veltrj_ctrl_out_type = _trj_pids[joint].
out_type;
635 _jsets[s].cfg.pid_output_types.mixtrj_ctrl_out_type = _trj_pids[joint].
out_type;
639 _jsets[s].cfg.pid_output_types.posdir_ctrl_out_type = _trj_pids[joint].
out_type;
640 _jsets[s].cfg.pid_output_types.veldir_ctrl_out_type = _trj_pids[joint].
out_type;
642 _jsets[s].cfg.pid_output_types.torque_ctrl_out_type = _trq_pids[joint].
out_type;
644 _jsets[s].cfg.pid_output_types.pwm_ctrl_out_type = eomc_ctrl_out_type_pwm;
646 if (_cur_pids[joint].enabled)
648 _jsets[s].cfg.pid_output_types.cur_ctrl_out_type = eomc_ctrl_out_type_cur;
652 _jsets[s].cfg.pid_output_types.cur_ctrl_out_type = eomc_ctrl_out_type_n_a;
661bool embObjMotionControl::saveCouplingsData(
void)
663 eOmc_4jomo_coupling_t *jc_dest;
665 static eOmc_4jomo_coupling_t dummyjomocoupling = {};
667 switch(serviceConfig.
ethservice.configuration.type)
669 case eomn_serv_MC_foc:
671 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.foc_based.jomocoupling);
674 case eomn_serv_MC_mc4plus:
676 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc4plus_based.jomocoupling);
679 case eomn_serv_MC_mc4plusmais:
681 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc4plusmais_based.jomocoupling);
685 case eomn_serv_MC_mc2pluspsc:
687 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc2pluspsc.jomocoupling);
691 case eomn_serv_MC_mc4plusfaps:
693 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc4plusfaps.jomocoupling);
697 case eomn_serv_MC_advfoc:
699 jc_dest = &dummyjomocoupling;
702 case eomn_serv_MC_mc4:
707 case eomn_serv_MC_generic:
719 memset(jc_dest, 0,
sizeof(eOmc_4jomo_coupling_t));
723 for(
int i=0; i<4; i++)
725 jc_dest->joint2set[i] = eomc_jointSetNum_none;
728 if(_joint2set.size() > 4 )
730 yError() <<
"embObjMC "<< getBoardInfo() <<
"Jointsset size is bigger than 4. I can't send jointset information to fw.";
734 for(
size_t i=0; i<_joint2set.size(); i++)
736 jc_dest->joint2set[i] = _joint2set[i];
739 for(
int i=0; i<4; i++)
741 for(
int j=0; j<4; j++)
743 jc_dest->joint2motor[i][j] = eo_common_float_to_Q17_14((
float)_couplingInfo.
matrixJ2M[4*i+j]);
744 jc_dest->motor2joint[i][j] = eo_common_float_to_Q17_14((
float)_couplingInfo.
matrixM2J[4*i+j]);
749 for(
int r=0; r<4; r++)
751 for(
int c=0; c<6; c++)
753 jc_dest->encoder2joint[r][c] = eo_common_float_to_Q17_14((
float)_couplingInfo.
matrixE2J[6*r+c]);
757 for(
size_t s=0; s< _jsets.size(); s++)
759 eOmc_jointset_configuration_t* cfg_ptr = _jsets[s].getConfiguration();
760 memcpy(&(jc_dest->jsetcfg[s]), cfg_ptr,
sizeof(eOmc_jointset_configuration_t));
764 if(eomn_serv_MC_advfoc == serviceConfig.
ethservice.configuration.type)
767 eOmc_adv4jomo_coupling_t *ajc = &serviceConfig.
ethservice.configuration.data.mc.advfoc.adv4jomocoupling;
768 ajc->type = eommccoupling_traditional4x4;
770 std::memmove(&ajc->data.coupling4x4.joint2set[0], &jc_dest->joint2set[0], 4*
sizeof(uint8_t));
771 std::memmove(&ajc->data.coupling4x4.jsetcfg[0], &jc_dest->jsetcfg[0], 4*
sizeof(eOmc_jointset_configuration_t));
772 std::memmove(&ajc->data.coupling4x4.joint2motor, &jc_dest->joint2motor,
sizeof(eOmc_4x4_matrix_t));
773 std::memmove(&ajc->data.coupling4x4.motor2joint, &jc_dest->motor2joint,
sizeof(eOmc_4x4_matrix_t));
775 for(uint8_t r=0; r<4; r++)
777 for(uint8_t c=0; c<4; c++)
779 ajc->data.coupling4x4.encoder2joint4x4[r][c] = jc_dest->encoder2joint[r][c];
789bool embObjMotionControl::fromConfig_Step2(yarp::os::Searchable &config)
796 if(iNeedCouplingsInfo())
822 for (i = 0; i < _njoints; i++)
824 measConvFactors.angleToEncoder[i] = 1;
845 if(eomn_serv_MC_mc4 != (eOmn_serv_type_t)serviceConfig.
ethservice.configuration.type)
847 int* useMotorSpeedFbk = 0;
848 useMotorSpeedFbk =
new int[_njoints];
851 delete[] useMotorSpeedFbk;
856 if (!verifyUseMotorSpeedFbkInJointSet(useMotorSpeedFbk))
858 delete[] useMotorSpeedFbk;
861 delete[] useMotorSpeedFbk;
863 bool deadzoneIsAvailable;
866 if(!deadzoneIsAvailable)
868 updateDeadZoneWithDefaultValues();
880 bool lowLevPidisMandatory =
false;
882 if((serviceConfig.
ethservice.configuration.type == eomn_serv_MC_foc) || (serviceConfig.
ethservice.configuration.type == eomn_serv_MC_advfoc))
884 lowLevPidisMandatory =
true;
887 if(!_mcparser->
parsePids(config, _trj_pids, _trq_pids, _cur_pids, _spd_pids, lowLevPidisMandatory))
904 updatedJointsetsCfgWithControlInfo();
907 for (i = 0; i < _njoints; i++)
909 measConvFactors.newtonsToSensor[i] = 1000000.0f;
911 measConvFactors.bemf2raw[i] = measConvFactors.newtonsToSensor[i] / measConvFactors.angleToEncoder[i];
912 if (_trq_pids->
out_PidUnits == yarp::dev::PidOutputUnitsEnum::DUTYCYCLE_PWM_PERCENT)
914 measConvFactors.ktau2raw[i] = measConvFactors.dutycycleToPWM[i] / measConvFactors.newtonsToSensor[i];
916 else if (_trq_pids->
out_PidUnits == yarp::dev::PidOutputUnitsEnum::RAW_MACHINE_UNITS)
918 measConvFactors.ktau2raw[i] = 1.0 / measConvFactors.newtonsToSensor[i];
922 yError() <<
"Invalid ktau units";
return false;
927 _measureConverter =
new ControlBoardHelper(_njoints, _axisMap, measConvFactors.angleToEncoder, NULL, measConvFactors.newtonsToSensor, measConvFactors.ampsToSensor,
nullptr, measConvFactors.dutycycleToPWM , measConvFactors.bemf2raw, measConvFactors.ktau2raw);
928 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_POSITION, _trj_pids->
fbk_PidUnits, _trj_pids->
out_PidUnits);
930 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_TORQUE, _trq_pids->
fbk_PidUnits, _trq_pids->
out_PidUnits);
931 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, _cur_pids->
fbk_PidUnits, _cur_pids->
out_PidUnits);
932 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, _spd_pids->
fbk_PidUnits, _spd_pids->
out_PidUnits);
945 initializeInterfaces(measConvFactors);
946 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_POSITION, _trj_pids->
fbk_PidUnits, _trj_pids->
out_PidUnits);
948 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_TORQUE, _trq_pids->
fbk_PidUnits, _trq_pids->
out_PidUnits);
949 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, _cur_pids->
fbk_PidUnits, _cur_pids->
out_PidUnits);
950 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, _spd_pids->
fbk_PidUnits, _spd_pids->
out_PidUnits);
954 if(!saveCouplingsData())
961 yError() <<
"embObjMC " << getBoardInfo() <<
"IMPEDANCE section: error detected in parameters syntax";
968 yError() <<
"embObjMC " << getBoardInfo() <<
"LUGRE section: error detected in parameters syntax";
973 for(j=0; j<_njoints; j++)
976 _impedance_limits[j].
min_damp= 0.001;
977 _impedance_limits[j].
max_damp= 9.888;
980 _impedance_limits[j].
param_a= 0.011;
981 _impedance_limits[j].
param_b= 0.012;
982 _impedance_limits[j].
param_c= 0.013;
1003 eOmn_serv_type_t servtype =
static_cast<eOmn_serv_type_t
>(serviceConfig.
ethservice.configuration.type);
1005 if((eomn_serv_MC_foc == servtype) || (eomn_serv_MC_advfoc == servtype))
1007 std::string groupName = {};
1009 if(eomn_serv_MC_foc == servtype)
1012 eObrd_type_t brd =
static_cast<eObrd_type_t
>(serviceConfig.
ethservice.configuration.data.mc.foc_based.type);
1013 groupName = (eobrd_foc == brd) ?
"2FOC" :
"AMCBLDC";
1015 else if(eomn_serv_MC_advfoc == servtype)
1019 groupName =
"ADVFOC";
1022 if(!_mcparser->
parseFocGroup(config, _foc_based_info, groupName, _temperatureSensorsVector))
1025 for (j = 0; j < _njoints; j++)
1027 if (((_temperatureSensorsVector.at(j)->getType() !=
motor_temperature_sensor_none )) && ((_temperatureLimits[j].hardwareTemperatureLimit == 0) || (_temperatureLimits[j].warningTemperatureLimit == 0)))
1029 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...";
1035 yInfo() <<
"embObjMC " << getBoardInfo() <<
"joint " << j <<
" has motor not provided with any available type of temperature sensor. If needed update the configurations file accordingly";
1041 for (j = 0; j < _njoints; j++)
1043 _temperatureSensorsVector.at(j) = std::make_unique<eomc::TemperatureSensorNONE>();
1047 int defaultTimeout = 100;
1049 if (this->serviceConfig.
ethservice.configuration.type == eomn_serv_MC_advfoc)
1053 defaultTimeout = 300;
1066bool embObjMotionControl::verifyUseMotorSpeedFbkInJointSet(
int useMotorSpeedFbk [])
1068 for(
size_t s=0; s< _jsets.size(); s++)
1070 int numofjointsinset = _jsets[s].getNumberofJoints();
1071 if(numofjointsinset == 0 )
1073 yError() <<
"embObjMC " << getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
1077 int firstjointofset = _jsets[s].joints[0];
1078 for(
int j=1; j<numofjointsinset; j++)
1080 int joint = _jsets[s].joints[j];
1081 if(useMotorSpeedFbk[firstjointofset] != useMotorSpeedFbk[joint])
1083 yError() <<
"embObjMC " << getBoardInfo() <<
". Param useMotorSpeedFbk should have same value for joints belong same set. See joint " << firstjointofset <<
" and " << joint;
1088 _jsets[s].setUseSpeedFeedbackFromMotors(useMotorSpeedFbk[firstjointofset]);
1095bool embObjMotionControl::verifyTorquePidshasSameUnitTypes(yarp::dev::PidFeedbackUnitsEnum &fbk_pidunits, yarp::dev::PidOutputUnitsEnum& out_pidunits)
1097 fbk_pidunits = yarp::dev::PidFeedbackUnitsEnum::RAW_MACHINE_UNITS;
1098 out_pidunits = yarp::dev::PidOutputUnitsEnum::RAW_MACHINE_UNITS;
1100 int firstjoint = -1;
1101 for(
int i=0; i<_njoints; i++)
1103 if(_trq_pids[i].enabled)
1113 for(
int i=firstjoint+1; i<_njoints; i++)
1115 if(_trq_pids[i].enabled)
1117 if(_trq_pids[firstjoint].fbk_PidUnits != _trq_pids[i].fbk_PidUnits ||
1118 _trq_pids[firstjoint].out_PidUnits != _trq_pids[i].out_PidUnits)
1120 yError() <<
"embObjMC " << getBoardInfo() <<
"all joints with torque enabled should have same controlunits type. Joint " << firstjoint <<
" differs from joint " << i;
1131bool embObjMotionControl::isTorqueControlEnabled(
int joint)
1133 return (_trq_pids[joint].enabled);
1136bool embObjMotionControl::isVelocityControlEnabled(
int joint)
1139 return (_trj_pids[joint].enabled);
1143void embObjMotionControl::updateDeadZoneWithDefaultValues(
void)
1145 for(
int i=0; i<_njoints; i++)
1147 switch(_jointEncs[i].
type)
1155 case eomc_enc_aksim2:
1161 case eomc_enc_absanalog:
1164 case eomc_enc_hallmotor:
1165 case eomc_enc_spichainof2:
1166 case eomc_enc_spichainof3:
1176bool embObjMotionControl::fromConfig_readServiceCfg(yarp::os::Searchable &config)
1179 if(
false == parser->
parseService(config, serviceConfig))
1181 yError() <<
"embObjMC " << getBoardInfo() <<
"cannot parse service" ;
1185 if(eomn_serv_MC_generic == serviceConfig.
ethservice.configuration.type)
1187 yError() <<
"embObjMC " << getBoardInfo() <<
"it is no longer possible use eomn_serv_MC_generic, because firmware cannot configure itself!" ;
1195 for(
int i=0; i<_njoints; i++)
1200 if(NULL == jointEncoder_ptr)
1202 _jointEncs[i].resolution = 1;
1203 _jointEncs[i].type = eomc_enc_none;
1204 _jointEncs[i].tolerance = 0;
1208 _jointEncs[i].resolution = jointEncoder_ptr->
resolution;
1209 _jointEncs[i].type = (eOmc_encoder_t)jointEncoder_ptr->
desc.type;
1210 _jointEncs[i].tolerance = jointEncoder_ptr->
tolerance;
1214 if(NULL == motorEncoder_ptr)
1216 _motorEncs[i].resolution = 1;
1217 _motorEncs[i].type = eomc_enc_none;
1218 _motorEncs[i].tolerance = 0;
1222 _motorEncs[i].resolution = motorEncoder_ptr->
resolution;
1223 _motorEncs[i].type = (eOmc_encoder_t)motorEncoder_ptr->
desc.type;
1224 _motorEncs[i].tolerance = motorEncoder_ptr->
tolerance;
1236bool embObjMotionControl::fromConfig(yarp::os::Searchable &config)
1239 _njoints = fromConfig_NumOfJoints(config);
1243 yError() <<
"embObjMC"<< getBoardInfo() <<
"fromConfig(): detected _njoints = " << _njoints;
1248 if(!alloc(_njoints))
1250 yError() <<
"embObjMC"<< getBoardInfo() <<
"fromConfig(): alloc() failed for _njoints = " << _njoints;
1258 int currentMCversion =0;
1264 yError() <<
"embObjMC" << getBoardInfo() <<
"------ ATTENTION!!!! Wrong value of <MotioncontrolVersion> parameter !!!! ---------------------------------------------------------------------------------------";
1265 yError() <<
"embObjMC" << getBoardInfo() <<
"------ This means that the configuration files of this device are not compatible with my parser, so I cannot start. ";
1266 yError() <<
"embObjMC" << getBoardInfo() <<
"------ I need version " <<
PARSER_MOTION_CONTROL_VERSION <<
", but in configuration files have version " << currentMCversion <<
".";
1267 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). ";
1268 yError() <<
"embObjMC" << getBoardInfo() <<
"------ If the problem persists contact icub-support@iit.it DO NOT DO IT BY YOURSELF.";
1269 yError() <<
"embObjMC" << getBoardInfo() <<
"----------------------------------------------------------------------------------------------------------------------------------------------------------------";
1275 yTrace() << config.toString().c_str();
1280 if(
false == fromConfig_readServiceCfg(config))
1296 if(
false == fromConfig_Step2(config))
1308bool embObjMotionControl::init()
1310 eOprotID32_t protid = 0;
1316 for(
int logico=0; logico< _njoints; logico++)
1318 int fisico = _axisMap[logico];
1319 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, fisico, eoprot_tag_mc_joint_cmmnds_controlmode);
1320 eOenum08_t controlMode = eomc_controlmode_cmd_idle;
1324 yError() <<
"embObjMotionControl::init() had an error while setting eomc_controlmode_cmd_idle in "<< getBoardInfo();
1330 SystemClock::delaySystem(0.010);
1337 vector<eOprotID32_t> id32v(0);
1338 for(
int n=0;
n<_njoints;
n++)
1340 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint,
n, eoprot_tag_mc_joint_status_core);
1341 id32v.push_back(protid);
1342 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint,
n, eoprot_tag_mc_joint_status_addinfo_multienc);
1343 id32v.push_back(protid);
1344 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor,
n, eoprot_tag_mc_motor_status);
1345 id32v.push_back(protid);
1348 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
1350 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, 0, eoprot_tag_mc_joint_status_debug);
1351 id32v.push_back(protid);
1352 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, 1, eoprot_tag_mc_joint_status_debug);
1353 id32v.push_back(protid);
1359 yError() <<
"embObjMotionControl::init() fails to add its variables to regulars in "<< getBoardInfo() <<
": cannot proceed any further";
1366 yDebug() <<
"embObjMotionControl::init() added" << id32v.size() <<
"regular rops to "<< getBoardInfo();
1368 for(
unsigned int r=0; r<id32v.size(); r++)
1370 uint32_t id32 = id32v.at(r);
1371 eoprot_ID2information(id32, nvinfo,
sizeof(nvinfo));
1372 yDebug() <<
"\t it added regular rop for" << nvinfo;
1377 SystemClock::delaySystem(0.005);
1384 for(
int logico=0; logico< _njoints; logico++)
1386 int fisico = _axisMap[logico];
1387 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, fisico, eoprot_tag_mc_joint_config);
1389 eOmc_joint_config_t jconfig = {0};
1390 memset(&jconfig, 0,
sizeof(eOmc_joint_config_t));
1392 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_POSITION,_trj_pids[logico].pid, fisico);
1396 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_TORQUE, _trq_pids[logico].pid, fisico);
1400 jconfig.impedance.damping = (eOmeas_damping_t) _measureConverter->impN2S(_impedance_params[logico].damping, fisico);
1401 jconfig.impedance.stiffness = (eOmeas_stiffness_t) _measureConverter->impN2S(_impedance_params[logico].stiffness, fisico);
1402 jconfig.impedance.offset = 0;
1404 _cacheImpedance[logico].stiffness = jconfig.impedance.stiffness;
1405 _cacheImpedance[logico].damping = jconfig.impedance.damping;
1406 _cacheImpedance[logico].offset = jconfig.impedance.offset;
1408 jconfig.userlimits.max = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posMax, fisico));
1409 jconfig.userlimits.min = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posMin, fisico));
1411 jconfig.hardwarelimits.max = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posHwMax, fisico));
1412 jconfig.hardwarelimits.min = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posHwMin, fisico));
1415 jconfig.maxvelocityofjoint =
S_32(_measureConverter->posA2E(_jointsLimits[logico].velMax, fisico));
1416 jconfig.velocitysetpointtimeout = (eOmeas_time_t)
U_16(_timeouts[logico].velocity_ref);
1417 jconfig.currentsetpointtimeout = (eOmeas_time_t)
U_16(_timeouts[logico].current_ref);
1418 jconfig.openloopsetpointtimeout = (eOmeas_time_t)
U_16(_timeouts[logico].pwm_ref);
1419 jconfig.torquesetpointtimeout = (eOmeas_time_t)
U_16(_timeouts[logico].torque_ref);
1420 jconfig.torquefeedbacktimeout = (eOmeas_time_t)
U_16(_timeouts[logico].torque_fbk);
1422 jconfig.jntEncoderResolution = _jointEncs[logico].resolution;
1423 jconfig.jntEncoderType = _jointEncs[logico].type;
1424 jconfig.jntEncTolerance = _jointEncs[logico].tolerance;
1426 jconfig.motor_params.bemf_value = _measureConverter->bemf_user2raw(_trq_pids[logico].kbemf, fisico);
1427 jconfig.motor_params.bemf_scale = 0;
1428 jconfig.motor_params.ktau_value = _measureConverter->ktau_user2raw(_trq_pids[logico].ktau, fisico);
1429 jconfig.motor_params.ktau_scale = 0;
1430 jconfig.motor_params.friction.viscous_pos_val = _measureConverter->viscousPos_user2raw(_trq_pids[logico].viscousPos, fisico);
1431 jconfig.motor_params.friction.viscous_neg_val = _measureConverter->viscousNeg_user2raw(_trq_pids[logico].viscousNeg, fisico);
1432 jconfig.motor_params.friction.coulomb_pos_val = _measureConverter->coulombPos_user2raw(_trq_pids[logico].coulombPos, fisico);
1433 jconfig.motor_params.friction.coulomb_neg_val = _measureConverter->coulombNeg_user2raw(_trq_pids[logico].coulombNeg, fisico);
1434 jconfig.motor_params.friction.velocityThres_val = _measureConverter->velocityThres_user2raw(_trq_pids[logico].velocityThres, fisico);
1436 jconfig.gearbox_E2J = _gearbox_E2J[logico];
1438 jconfig.deadzone = _measureConverter->posA2E(_deadzone[logico], fisico);
1440 jconfig.tcfiltertype=_trq_pids[logico].
filterType;
1442 jconfig.kalman_params.enabled = _kalman_params[logico].enabled;
1443 for(
int i=0; i<_kalman_params[logico].x0.size(); i++) jconfig.kalman_params.x0[i] = _kalman_params[logico].x0.at(i);
1444 for(
int i=0; i<_kalman_params[logico].Q.size(); i++) jconfig.kalman_params.Q[i] = _kalman_params[logico].Q.at(i);
1445 jconfig.kalman_params.R = _kalman_params[logico].R;
1446 jconfig.kalman_params.P0 = _kalman_params[logico].P0;
1450 yError() <<
"FATAL: embObjMotionControl::init() had an error while calling setcheckRemoteValue() for joint config fisico #" << fisico <<
"in "<< getBoardInfo();
1457 yDebug() <<
"embObjMotionControl::init() correctly configured joint config fisico #" << fisico <<
"in "<< getBoardInfo();
1468 for(
int logico=0; logico<_njoints; logico++)
1470 int fisico = _axisMap[logico];
1472 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, fisico, eoprot_tag_mc_motor_config);
1473 eOmc_motor_config_t motor_cfg = {0};
1474 motor_cfg.maxvelocityofmotor = 0;
1475 motor_cfg.currentLimits.nominalCurrent = _currentLimits[logico].nominalCurrent;
1476 motor_cfg.currentLimits.overloadCurrent = _currentLimits[logico].overloadCurrent;
1477 motor_cfg.currentLimits.peakCurrent = _currentLimits[logico].peakCurrent;
1478 motor_cfg.gearbox_M2J = _gearbox_M2J[logico];
1479 motor_cfg.rotorEncoderResolution = _motorEncs[logico].resolution;
1480 motor_cfg.rotEncTolerance = _motorEncs[logico].tolerance;
1481 motor_cfg.hasHallSensor = _foc_based_info[logico].
hasHallSensor;
1483 motor_cfg.hasTempSensor = _foc_based_info[logico].
hasTempSensor;
1486 motor_cfg.verbose = _foc_based_info[logico].
verbose;
1487 motor_cfg.motorPoles = _foc_based_info[logico].
motorPoles;
1489 motor_cfg.Kbemf = _foc_based_info[logico].
kbemf;
1490 motor_cfg.rotorEncoderType = _motorEncs[logico].type;
1491 motor_cfg.pwmLimit =_rotorsLimits[logico].pwmMax;
1492 motor_cfg.temperatureLimit = (eOmeas_temperature_t)
S_16(_temperatureSensorsVector.at(logico)->convertTempCelsiusToRaw(_temperatureLimits.at(logico).hardwareTemperatureLimit));
1493 motor_cfg.limitsofrotor.max = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_rotorsLimits[logico].posMax, fisico ));
1494 motor_cfg.limitsofrotor.min = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_rotorsLimits[logico].posMin, fisico ));
1496 motor_cfg.LuGre_params.Km = _lugre_params[logico].Km;
1497 motor_cfg.LuGre_params.Kw = _lugre_params[logico].Kw;
1498 motor_cfg.LuGre_params.S0 = _lugre_params[logico].S0;
1499 motor_cfg.LuGre_params.S1 = _lugre_params[logico].S1;
1500 motor_cfg.LuGre_params.Vth = _lugre_params[logico].Vth;
1501 motor_cfg.LuGre_params.Fc_pos = _lugre_params[logico].Fc_pos;
1502 motor_cfg.LuGre_params.Fc_neg = _lugre_params[logico].Fc_neg;
1503 motor_cfg.LuGre_params.Fs_pos = _lugre_params[logico].Fs_pos;
1504 motor_cfg.LuGre_params.Fs_neg = _lugre_params[logico].Fs_neg;
1507 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_CURRENT, _cur_pids[logico].pid, fisico);
1510 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_VELOCITY, _spd_pids[logico].pid, fisico);
1515 yError() <<
"FATAL: embObjMotionControl::init() had an error while calling setcheckRemoteValue() for motor config fisico #" << fisico <<
"in "<< getBoardInfo();
1522 yDebug() <<
"embObjMotionControl::init() correctly configured motor config fisico #" << fisico <<
"in "<< getBoardInfo();
1531 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_controller, 0, eoprot_tag_mc_controller_config);
1533 eOmc_controller_config_t controller_cfg = {0};
1534 memset(&controller_cfg, 0,
sizeof(eOmc_controller_config_t));
1535 controller_cfg.durationofctrlloop = (uint32_t)bdata.
settings.
txconfig.cycletime;
1540 yError() <<
"FATAL: embObjMotionControl::init() had an error while calling setcheckRemoteValue() for the controller " <<
"in "<< getBoardInfo();
1547 yDebug() <<
"embObjMotionControl::init() correctly configured controller config " <<
"in "<< getBoardInfo();
1554 const char* tag = eoprot_TAG2string(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_addinfo_multienc);
1556 _rawValuesMetadataMap.insert({{tag,
rawValuesKeyMetadata({}, {}, _njoints * eOmc_joint_multienc_maxnum)}});
1557 for (
auto &[k, v] : _rawValuesMetadataMap)
1559 std::string auxstring =
"";
1561 for (
int i = 0; i < _njoints; i++)
1566 v.axesNames.push_back(auxstring);
1567 v.rawValueNames.insert(v.rawValueNames.end(),
1568 {auxstring+
"_primary_encoder_raw_value",
1569 auxstring+
"_secondary_encoder_raw_value",
1570 auxstring+
"_primary_encoder_diagnostic"}
1576 yTrace() <<
"embObjMotionControl::init(): correctly instantiated for " << getBoardInfo();
1584 yTrace() <<
" embObjMotionControl::close()";
1586 ImplementControlMode::uninitialize();
1587 ImplementEncodersTimed::uninitialize();
1588 ImplementMotorEncoders::uninitialize();
1589 ImplementPositionControl::uninitialize();
1590 ImplementVelocityControl::uninitialize();
1591 ImplementPidControl::uninitialize();
1592 ImplementControlCalibration::uninitialize();
1593 ImplementAmplifierControl::uninitialize();
1594 ImplementImpedanceControl::uninitialize();
1595 ImplementControlLimits::uninitialize();
1596 ImplementTorqueControl::uninitialize();
1597 ImplementPositionDirect::uninitialize();
1598 ImplementInteractionMode::uninitialize();
1599 ImplementRemoteVariables::uninitialize();
1600 ImplementAxisInfo::uninitialize();
1601 ImplementCurrentControl::uninitialize();
1602 ImplementPWMControl::uninitialize();
1603 ImplementJointFault::uninitialize();
1605 if (_measureConverter) {
delete _measureConverter; _measureConverter=0;}
1608 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
1611 for(
size_t i=0; i<mcdiagnostics.
ports.size(); i++)
1613 mcdiagnostics.
ports[i]->close();
1614 delete mcdiagnostics.
ports[i];
1616 mcdiagnostics.
ports.clear();
1618 mcdiagnostics.
config.mode = eomn_serv_diagn_mode_NONE;
1619 mcdiagnostics.
config.par16 = 0;
1622 delete event_downsampler;
1636void embObjMotionControl::cleanup(
void)
1638 if(ethManager == NULL)
return;
1657 size_t joint = eoprot_ID2index(id32);
1658 eOprotEntity_t ent = eoprot_ID2entity(id32);
1659 eOprotTag_t tag = eoprot_ID2tag(id32);
1673 std::lock_guard<std::mutex> lck(_mutex);
1674 _encodersStamp[joint] = timestamp;
1678 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
1680 char str[128] =
"boh";
1682 eoprot_ID2information(id32, str,
sizeof(str));
1684 if((eoprot_entity_mc_joint == ent) && (eoprot_tag_mc_joint_status_debug == tag) && (joint < mcdiagnostics.
ports.size()))
1687 eOprotID32_t id32sc = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joint, eoprot_tag_mc_joint_status_core);
1688 eOmc_joint_status_core_t jcore = {};
1692 int32_t *debug32 =
reinterpret_cast<int32_t*
>(rxdata);
1695 Bottle& output = mcdiagnostics.
ports[joint]->prepare();
1698 output.addString(
"[yt, amo, reg, pos]");
1699 output.addFloat64(timestamp);
1700 output.addInt32(debug32[0]);
1701 output.addInt32(debug32[1]);
1702 output.addInt32(jcore.measures.meas_position);
1703 mcdiagnostics.
ports[joint]->write();
1707 if((eoprot_entity_mc_motor == ent) && (eoprot_tag_mc_motor_status == tag))
1712 uint8_t motor = eoprot_ID2index(id32);
1716 eOmc_motor_status_t *mc_motor_status =
reinterpret_cast<eOmc_motor_status_t*
>(rxdata);
1718 if((
double)mc_motor_status->basic.mot_temperature < 0 )
1720 if(! _temperatureSensorErrorWatchdog.at(motor).isStarted())
1722 yWarning() << getBoardInfo() <<
"At time" << (yarp::os::Time::now() - _temperatureSensorErrorWatchdog.at(motor).getAbsoluteTime()) <<
"In motor" << motor <<
"cannot read Temperature from I2C. There might be cabling problems, TDB cable might be broken or sensor unreachable";
1723 _temperatureSensorErrorWatchdog.at(motor).start();
1727 _temperatureSensorErrorWatchdog.at(motor).increment();
1728 if( _temperatureSensorErrorWatchdog.at(motor).isExpired())
1730 yWarning()<< getBoardInfo() <<
"Motor" << motor <<
"failed to read" << _temperatureSensorErrorWatchdog.at(motor).getCount() <<
"temperature readings for" << yarp::os::Time::now() - _temperatureSensorErrorWatchdog.at(motor).getStartTime() <<
"seconds";
1731 _temperatureSensorErrorWatchdog.at(motor).start();
1738 double delta_tmp = 0;
1739 double tmp = _temperatureSensorsVector.at(motor)->convertRawToTempCelsius((
double)mc_motor_status->basic.mot_temperature);
1743 if(!_temperatureSpikesFilter.at(motor).isStarted())
1745 _temperatureSpikesFilter.at(motor).start(tmp);
1750 delta_tmp = std::abs(tmp - _temperatureSpikesFilter.at(motor).getPrevTemperature());
1753 if(delta_tmp > _temperatureSpikesFilter.at(motor).getTemperatureThreshold())
1759 _temperatureSpikesFilter.at(motor).updatePrevTemperature(tmp);
1762 if(tmp > _temperatureLimits[motor].warningTemperatureLimit)
1764 if(! _temperatureExceededLimitWatchdog.at(motor).isStarted())
1766 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";
1767 _temperatureExceededLimitWatchdog.at(motor).start();
1771 if(_temperatureExceededLimitWatchdog.at(motor).isExpired())
1773 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";
1774 _temperatureExceededLimitWatchdog.at(motor).start();
1776 _temperatureExceededLimitWatchdog.at(motor).increment();
1781 _temperatureExceededLimitWatchdog.at(motor).clear();
1805 encoderTypeName.clear();
1807 if ((jomoId >= 0) && (jomoId < _njoints))
1811 case eomc_pos_atjoint:
1812 encoderTypeName = eomc_encoder2string(_jointEncs[jomoId].
type, eobool_true);
1814 case eomc_pos_atmotor:
1815 encoderTypeName = eomc_encoder2string(_motorEncs[jomoId].
type, eobool_true);
1817 case eomc_pos_unknown:
1818 encoderTypeName =
"UNKNOWN";
1822 encoderTypeName =
"NONE";
1829 encoderTypeName =
"ERROR";
1839 case VOCAB_PIDTYPE_POSITION:
1840 helper_setPosPidRaw(j,pid);
1842 case VOCAB_PIDTYPE_VELOCITY:
1844 helper_setSpdPidRaw(j, pid);
1846 case VOCAB_PIDTYPE_TORQUE:
1847 helper_setTrqPidRaw(j, pid);
1849 case VOCAB_PIDTYPE_CURRENT:
1850 helper_setCurPidRaw(j,pid);
1853 yError()<<
"Invalid pidtype:"<<pidtype;
1863 case VOCAB_PIDTYPE_POSITION:
1864 helper_getPosPidRaw(axis,pid);
1866 case VOCAB_PIDTYPE_VELOCITY:
1868 helper_getSpdPidRaw(axis, pid);
1870 case VOCAB_PIDTYPE_TORQUE:
1871 helper_getTrqPidRaw(axis, pid);
1873 case VOCAB_PIDTYPE_CURRENT:
1874 helper_getCurPidRaw(axis,pid);
1877 yError()<<
"Invalid pidtype:"<<pidtype;
1883bool embObjMotionControl::helper_setPosPidRaw(
int j,
const Pid &pid)
1885 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtrajectory);
1894 yError() <<
"while setting position PIDs for " << getBoardInfo() <<
" joint " << j;
1904 for(
int j=0; j< _njoints; j++)
1919 for(
int j=0, index=0; j< _njoints; j++, index++)
1941 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
1942 eOmc_joint_status_core_t jcore = {0};
1949 case VOCAB_PIDTYPE_POSITION:
1951 if((eomc_controlmode_torque == jcore.modes.controlmodestatus) ||
1952 (eomc_controlmode_openloop == jcore.modes.controlmodestatus) ||
1953 (eomc_controlmode_current == jcore.modes.controlmodestatus))
1956 *err = (double) jcore.ofpid.generic.error1;
1967 case VOCAB_PIDTYPE_TORQUE:
1969 if ((eOmc_interactionmode_compliant == jcore.modes.interactionmodestatus) &&
1970 (eomc_controlmode_position == jcore.modes.controlmodestatus))
1972 *err = (double) jcore.ofpid.complpos.errtrq;
1975 if(eomc_controlmode_torque == jcore.modes.controlmodestatus)
1977 *err = (double) jcore.ofpid.torque.errtrq;
1981 case VOCAB_PIDTYPE_VELOCITY:
1987 case VOCAB_PIDTYPE_CURRENT:
1995 yError()<<
"Invalid pidtype:"<<pidtype;
2005 for(
int j=0; j< _njoints; j++)
2012bool embObjMotionControl::helper_getPosPidRaw(
int j, Pid *pid)
2014 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtrajectory);
2017 eOmc_PID_t eoPID = {0};
2020#ifdef NETWORK_PERFORMANCE_BENCHMARK
2021 double start = yarp::os::Time::now();
2024 bool ret = askRemoteValue(protid, &eoPID, size);
2026#ifdef NETWORK_PERFORMANCE_BENCHMARK
2027 double end = yarp::os::Time::now();
2028 m_responseTimingVerifier.tick(end-start, start);
2041bool embObjMotionControl::helper_getPosPidsRaw(Pid *pid)
2043 std::vector<eOmc_PID_t> eoPIDList(_njoints);
2044 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_config_pidtrajectory, eoPIDList);
2047 yError() <<
"failed helper_getPosPidsRaw for" << getBoardInfo();
2051 for(
int j=0; j<_njoints; j++)
2065 case VOCAB_PIDTYPE_POSITION:
2066 helper_getPosPidsRaw(pids);
2071 case VOCAB_PIDTYPE_TORQUE:
2072 helper_getTrqPidsRaw(pids);
2074 case VOCAB_PIDTYPE_CURRENT:
2075 helper_getCurPidsRaw(pids);
2077 case VOCAB_PIDTYPE_VELOCITY:
2078 helper_getSpdPidsRaw(pids);
2081 yError()<<
"Invalid pidtype:"<<pidtype;
2089 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
2090 eOmc_joint_status_core_t jcore = {0};
2097 case VOCAB_PIDTYPE_POSITION:
2099 if((eomc_controlmode_torque == jcore.modes.controlmodestatus) ||
2100 (eomc_controlmode_openloop == jcore.modes.controlmodestatus) ||
2101 (eomc_controlmode_current == jcore.modes.controlmodestatus))
2102 { *ref = 0; yError() <<
"Invalid getPidReferenceRaw() request for current control mode";
return true; }
2103 *ref = (double) jcore.ofpid.generic.reference1;
2112 case VOCAB_PIDTYPE_TORQUE:
2118 case VOCAB_PIDTYPE_CURRENT:
2124 case VOCAB_PIDTYPE_VELOCITY:
2133 yError()<<
"Invalid pidtype:"<<pidtype;
2146 for(
int j=0; j< _njoints; j++)
2191 if( (mode != VOCAB_CM_VELOCITY) &&
2192 (mode != VOCAB_CM_MIXED) &&
2193 (mode != VOCAB_CM_IMPEDANCE_VEL) &&
2194 (mode != VOCAB_CM_IDLE))
2198 yError() <<
"velocityMoveRaw: skipping command because " << getBoardInfo() <<
" joint " << j <<
" is not in VOCAB_CM_VELOCITY mode";
2203 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
2205 _ref_command_speeds[j] = sp ;
2207 eOmc_setpoint_t setpoint;
2208 setpoint.type = eomc_setpoint_velocity;
2209 setpoint.to.velocity.value = (eOmeas_velocity_t)
S_32(_ref_command_speeds[j]);
2210 setpoint.to.velocity.withacceleration = (eOmeas_acceleration_t)
S_32(_ref_accs[j]);
2215 yError() <<
"while setting velocity mode";
2224 eOmc_setpoint_t setpoint;
2226 setpoint.type = eomc_setpoint_velocity;
2228 for(
int j=0; j<_njoints; j++)
2243 yTrace() <<
"setCalibrationParametersRaw for " << getBoardInfo() <<
"joint" << j;
2245 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_calibration);
2246 eOmc_calibrator_t calib;
2247 memset(&calib, 0x00,
sizeof(calib));
2248 calib.type = params.type;
2253 case eomc_calibration_type0_hard_stops:
2254 calib.params.type0.pwmlimit = (int16_t)
S_16(params.param1);
2255 calib.params.type0.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2256 calib.params.type0.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2260 case eomc_calibration_type1_abs_sens_analog:
2261 calib.params.type1.position = (int16_t)
S_16(params.param1);
2262 calib.params.type1.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2263 calib.params.type1.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2267 case eomc_calibration_type2_hard_stops_diff:
2268 calib.params.type2.pwmlimit = (int16_t)
S_16(params.param1);
2269 calib.params.type2.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2270 calib.params.type2.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2274 case eomc_calibration_type3_abs_sens_digital:
2275 calib.params.type3.position = (int16_t)
S_16(params.param1);
2276 calib.params.type3.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2277 calib.params.type3.offset = (int32_t)
S_32(params.param3);
2278 calib.params.type3.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2282 case eomc_calibration_type4_abs_and_incremental:
2283 calib.params.type4.position = (int16_t)
S_16(params.param1);
2284 calib.params.type4.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2285 calib.params.type4.maxencoder = (int32_t)
S_32(params.param3);
2286 calib.params.type4.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2290 case eomc_calibration_type5_hard_stops:
2291 calib.params.type5.pwmlimit = (int32_t)
S_32(params.param1);
2292 calib.params.type5.final_pos = (int32_t)
S_32(params.param2);
2293 calib.params.type5.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2297 case eomc_calibration_type6_mais:
2298 calib.params.type6.position = (int32_t)
S_32(params.param1);
2299 calib.params.type6.velocity = (int32_t)
S_32(params.param2);
2300 calib.params.type6.current = (int32_t)
S_32(params.param3);
2301 calib.params.type6.vmin = (int32_t)
S_32(params.param4);
2302 calib.params.type6.vmax = (int32_t)
S_32(params.param5);
2303 calib.params.type6.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2307 case eomc_calibration_type7_hall_sensor:
2308 calib.params.type7.position = (int32_t)
S_32(params.param1);
2309 calib.params.type7.velocity = (int32_t)
S_32(params.param2);
2311 calib.params.type7.vmin = (int32_t)
S_32(params.param4);
2312 calib.params.type7.vmax = (int32_t)
S_32(params.param5);
2313 calib.params.type7.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2317 case eomc_calibration_type8_tripod_internal_hard_stop:
2318 calib.params.type8.pwmlimit = (int32_t)
S_32(params.param1);
2319 calib.params.type8.max_delta = (int32_t)
S_32(params.param2);
2320 calib.params.type8.calibrationZero = (int32_t)
S_32(params.paramZero );
2323 case eomc_calibration_type9_tripod_external_hard_stop:
2324 calib.params.type9.pwmlimit = (int32_t)
S_32(params.param1);
2325 calib.params.type9.max_delta = (int32_t)
S_32(params.param2);
2326 calib.params.type9.calibrationZero = (int32_t)
S_32(params.paramZero );
2329 case eomc_calibration_type10_abs_hard_stop:
2330 calib.params.type10.pwmlimit = (int32_t)
S_32(params.param1);
2331 calib.params.type10.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2334 case eomc_calibration_type11_cer_hands:
2335 calib.params.type11.offset0 = (int32_t)
S_32(params.param1);
2336 calib.params.type11.offset1 = (int32_t)
S_32(params.param2);
2337 calib.params.type11.offset2 = (int32_t)
S_32(params.param3);
2338 calib.params.type11.cable_range = (int32_t)
S_32(params.param4);
2339 calib.params.type11.pwm = (int32_t)
S_32(params.param5);
2343 case eomc_calibration_type12_absolute_sensor:
2344 calib.params.type12.rawValueAtZeroPos = (int32_t)
S_32(params.param1);
2345 calib.params.type12.calibrationDelta = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2348 case eomc_calibration_type13_cer_hands_2:
2349 calib.params.type13.rawValueAtZeroPos0 = (int32_t)
S_32(params.param1);
2350 calib.params.type13.rawValueAtZeroPos1 = (int32_t)
S_32(params.param2);
2351 calib.params.type13.rawValueAtZeroPos2 = (int32_t)
S_32(params.param3);
2352 calib.params.type13.rawValueAtZeroPos3 = (int32_t)
S_32(params.param4);
2355 case eomc_calibration_type14_qenc_hard_stop_and_fap:
2356 calib.params.type14.pwmlimit = (int32_t)
S_32(params.param1);
2357 calib.params.type14.final_pos = (int32_t)
S_32(params.param2);
2358 calib.params.type14.invertdirection = (uint8_t)
U_32(params.param3);
2359 calib.params.type14.rotation = (int32_t)
S_32(params.param4);
2361 if (calib.params.type14.invertdirection != 0 && calib.params.type14.invertdirection != 1)
2363 yError() <<
"Error in param3 of calibartion type 14 for joint " << j <<
"Admitted values are: 0=FALSE and 1=TRUE";
2368 if(!checkCalib14RotationParam(calib.params.type14.rotation))
2370 yError() <<
"Error in param4 of calibartion type 14 for joint " << j <<
"Admitted values are: 0, 32768, 16384, -16384 [0, 180, 90, -90] in iCubDegree";
2373 calib.params.type14.offset = (int32_t)
S_32(params.param5);
2374 calib.params.type14.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2379 yError() <<
"Calibration type unknown!! (embObjMotionControl)\n";
2386 yError() <<
"while setting velocity mode";
2390 _calibrated[j] =
true;
2395bool embObjMotionControl::checkCalib14RotationParam(int32_t calib_param4)
2397 eOmc_calib14_ROT_t urotation = eomc_int2calib14_ROT(calib_param4);
2399 if (urotation == eOmc_calib14_ROT_zero ||
2400 urotation == eOmc_calib14_ROT_plus180 ||
2401 urotation == eOmc_calib14_ROT_plus090 ||
2402 urotation == eOmc_calib14_ROT_minus090)
2412 yTrace() <<
"calibrateRaw for" << getBoardInfo() <<
"joint" << j;
2430 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_calibration);
2431 eOmc_calibrator_t calib;
2432 memset(&calib, 0x00,
sizeof(calib));
2438 case eomc_calibration_type0_hard_stops:
2439 calib.params.type0.pwmlimit = (int16_t)
S_16(p1);
2440 calib.params.type0.velocity = (eOmeas_velocity_t)
S_32(p2);
2444 case eomc_calibration_type1_abs_sens_analog:
2445 calib.params.type1.position = (int16_t)
S_16(p1);
2446 calib.params.type1.velocity = (eOmeas_velocity_t)
S_32(p2);
2450 case eomc_calibration_type2_hard_stops_diff:
2451 calib.params.type2.pwmlimit = (int16_t)
S_16(p1);
2452 calib.params.type2.velocity = (eOmeas_velocity_t)
S_32(p2);
2456 case eomc_calibration_type3_abs_sens_digital:
2457 calib.params.type3.position = (int16_t)
S_16(p1);
2458 calib.params.type3.velocity = (eOmeas_velocity_t)
S_32(p2);
2459 calib.params.type3.offset = (int32_t)
S_32(p3);
2463 case eomc_calibration_type4_abs_and_incremental:
2464 calib.params.type4.position = (int16_t)
S_16(p1);
2465 calib.params.type4.velocity = (eOmeas_velocity_t)
S_32(p2);
2466 calib.params.type4.maxencoder = (int32_t)
S_32(p3);
2470 yError () <<
"Calibration type unknown!! (embObjMotionControl)\n";
2477 yError() <<
"while setting velocity mode";
2481 _calibrated[j ] =
true;
2489 bool result =
false;
2490 eOmc_joint_status_core_t jcore = {0};
2491 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_core);
2494 yError () <<
"Failure of getLocalValue() inside embObjMotionControl::calibrationDoneRaw(axis=" << axis <<
") for " << getBoardInfo();
2498 eOmc_controlmode_t
type = (eOmc_controlmode_t) jcore.modes.controlmodestatus;
2502 if (eomc_controlmode_idle ==
type)
2506 else if (eomc_controlmode_calib ==
type)
2510 else if (eomc_controlmode_hwFault ==
type)
2512 yError(
"unable to complete calibration: joint %d in 'hw_fault status' inside calibrationDoneRaw() function", axis);
2515 else if (eomc_controlmode_notConfigured ==
type)
2517 yError(
"unable to complete calibration: joint %d in 'not_configured' status inside calibrationDoneRaw() function", axis);
2520 else if (eomc_controlmode_unknownError ==
type)
2522 yError(
"unable to complete calibration: joint %d in 'unknownError' status inside calibrationDoneRaw() function", axis);
2525 else if (eomc_controlmode_configured ==
type)
2527 yError(
"unable to complete calibration: joint %d in 'configured' status inside calibrationDoneRaw() function", axis);
2552 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.";
2554 _last_position_move_time[j] = yarp::os::Time::now();
2558 if( (mode != VOCAB_CM_POSITION) &&
2559 (mode != VOCAB_CM_MIXED) &&
2560 (mode != VOCAB_CM_IMPEDANCE_POS) &&
2561 (mode != VOCAB_CM_IDLE))
2565 yError() <<
"positionMoveRaw: skipping command because " << getBoardInfo() <<
" joint " << j <<
" is not in VOCAB_CM_POSITION mode";
2570 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
2571 _ref_command_positions[j] = ref;
2573 eOmc_setpoint_t setpoint;
2575 setpoint.type = (eOenum08_t) eomc_setpoint_position;
2576 setpoint.to.position.value = (eOmeas_position_t)
S_32(_ref_command_positions[j]);
2577 setpoint.to.position.withvelocity = (eOmeas_velocity_t)
S_32(_ref_speeds[j]);
2586 for(
int j=0, index=0; j< _njoints; j++, index++)
2606 eObool_t ismotiondone = eobool_false;
2609 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core_modes_ismotiondone);
2610 if(
false == askRemoteValue(id32, &ismotiondone, size))
2612 yError () <<
"Failure of askRemoteValue() inside embObjMotionControl::checkMotionDoneRaw(j=" << j <<
") for " << getBoardInfo();
2617 *flag = ismotiondone;
2624 std::vector <eObool_t> ismotiondoneList(_njoints);
2625 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_core_modes_ismotiondone, ismotiondoneList);
2628 yError () <<
"Failure of askRemoteValues() inside embObjMotionControl::checkMotionDoneRaw for all joints of" << getBoardInfo();
2632 for(
int j=0; j<_njoints; j++)
2634 *flag &= ismotiondoneList[j];
2644 _ref_speeds[index] = sp;
2652 for(
int j=0, index=0; j< _njoints; j++, index++)
2654 _ref_speeds[index] = spds[index];
2666 _ref_accs[j ] = 1e6;
2668 else if (
acc < -1e6)
2670 _ref_accs[j ] = -1e6;
2674 _ref_accs[j ] =
acc;
2684 for(
int j=0, index=0; j< _njoints; j++, index++)
2688 _ref_accs[index] = 1e6;
2690 else if (accs[j] < -1e6)
2692 _ref_accs[index] = -1e6;
2696 _ref_accs[index] = accs[j];
2704 if (j<0 || j>_njoints)
return false;
2705#if ASK_REFERENCE_TO_FIRMWARE
2706 *spd = _ref_speeds[j];
2709 *spd = _ref_speeds[j];
2716 memcpy(spds, _ref_speeds,
sizeof(
double) * _njoints);
2722 *
acc = _ref_accs[j];
2728 memcpy(accs, _ref_accs,
sizeof(
double) * _njoints);
2734 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_stoptrajectory);
2736 eObool_t stop = eobool_true;
2744 for(
int j=0; j< _njoints; j++)
2759 for(
int j=0; j<n_joint; j++)
2769 for(
int j=0; j<n_joint; j++)
2780 for(
int j=0; j<n_joint; j++)
2782 if(joints[j] >= _njoints)
2784 yError() << getBoardInfo() <<
":checkMotionDoneRaw required for not existing joint ( " << joints[j] <<
")";
2790 std::vector <eObool_t> ismotiondoneList(_njoints);
2791 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_core_modes_ismotiondone, ismotiondoneList);
2794 yError () << getBoardInfo() <<
"Failure of askRemoteValues() inside embObjMotionControl::checkMotionDoneRaw for a group of joint"; getBoardInfo();
2799 bool tot_val =
true;
2800 for(
int j=0; j<n_joint; j++)
2802 tot_val &= ismotiondoneList[joints[j]];
2813 for(
int j=0; j<n_joint; j++)
2823 for(
int j=0; j<n_joint; j++)
2833 for(
int j=0; j<n_joint; j++)
2843 for(
int j=0; j<n_joint; j++)
2853 for(
int j=0; j<n_joint; j++)
2855 ret = ret &&
stopRaw(joints[j]);
2866 eOmc_joint_status_core_t jcore = {0};
2867 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
2871 eOmc_controlmode_t
type = (eOmc_controlmode_t) jcore.modes.controlmodestatus;
2881 for(
int j=0; j< _njoints; j++)
2891 for(
int j=0; j< n_joint; j++)
2906 eOenum08_t controlmodecommand = 0;
2908 if((_mode == VOCAB_CM_TORQUE) && (_trq_pids[j].enabled ==
false))
2910 yError()<<
"Torque control is disabled. Check your configuration parameters";
2916 yError() <<
"SetControlMode: received unknown control mode for " << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
2920 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_controlmode);
2923 yError() <<
"setControlModeRaw failed for " << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
2928 ret = checkRemoteControlModeStatus(j, _mode);
2932 yError() <<
"In embObjMotionControl::setControlModeRaw(j=" << j <<
", mode=" << yarp::os::Vocab32::decode(_mode).c_str() <<
") for " << getBoardInfo() <<
" has failed checkRemoteControlModeStatus()";
2942 eOenum08_t controlmodecommand = 0;
2945 for(
int i=0; i<n_joint; i++)
2947 if ((modes[i] == VOCAB_CM_TORQUE) && (_trq_pids[i].enabled ==
false)) {yError()<<
"Torque control is disabled. Check your configuration parameters";
continue;}
2951 yError() <<
"SetControlModesRaw(): received unknown control mode for " << getBoardInfo() <<
" joint " << joints[i] <<
" mode " << Vocab32::decode(modes[i]);
2956 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joints[i], eoprot_tag_mc_joint_cmmnds_controlmode);
2959 yError() <<
"setControlModesRaw() could not send set<cmmnds_controlmode> for " << getBoardInfo() <<
" joint " << joints[i] <<
" mode " << Vocab32::decode(modes[i]);
2964 bool tmpresult = checkRemoteControlModeStatus(joints[i], modes[i]);
2965 if(
false == tmpresult)
2967 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]);
2970 ret = ret && tmpresult;
2980 eOenum08_t controlmodecommand = 0;
2982 for(
int i=0; i<_njoints; i++)
2985 if ((modes[i] == VOCAB_CM_TORQUE) && (_trq_pids[i].enabled ==
false))
2987 yError()<<
"Torque control is disabled. Check your configuration parameters";
2993 yError() <<
"SetControlMode: received unknown control mode for" << getBoardInfo() <<
" joint " << i <<
" mode " << Vocab32::decode(modes[i]);
2997 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, i, eoprot_tag_mc_joint_cmmnds_controlmode);
3000 yError() <<
"setControlModesRaw failed for " << getBoardInfo() <<
" joint " << i <<
" mode " << Vocab32::decode(modes[i]);
3004 bool tmpresult = checkRemoteControlModeStatus(i, modes[i]);
3005 if(
false == tmpresult)
3007 yError() <<
"setControlModesRaw(int *modes) could not check with checkRemoteControlModeStatus() for" << getBoardInfo() <<
" joint " << i <<
" mode " << Vocab32::decode(modes[i]);
3010 ret = ret && tmpresult;
3043 eOmc_joint_status_core_t core;
3044 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
3050 *value = (double) core.measures.meas_position;
3054 yError() <<
"embObjMotionControl while reading encoder";
3064 for(
int j=0; j< _njoints; j++)
3074 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
3075 eOmc_joint_status_core_t core;
3082 *sp = (double) core.measures.meas_velocity;
3089 for(
int j=0; j< _njoints; j++)
3098 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
3099 eOmc_joint_status_core_t core;
3105 *
acc = (double) core.measures.meas_acceleration;
3112 for(
int j=0; j< _njoints; j++)
3124 std::lock_guard<std::mutex> lck(_mutex);
3125 for(
int i=0; i<_njoints; i++)
3126 stamps[i] = _encodersStamp[i];
3133 std::lock_guard<std::mutex> lck(_mutex);
3134 *stamp = _encodersStamp[j];
3178 eOmc_motor_status_basic_t status;
3179 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
3184 *value = (double) status.mot_position;
3188 yError() <<
"embObjMotionControl while reading motor encoder position";
3198 for(
int j=0; j< _njoints; j++)
3208 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
3209 eOmc_motor_status_basic_t tmpMotorStatus;
3213 *sp = (double) tmpMotorStatus.mot_velocity;
3217 yError() <<
"embObjMotionControl while reading motor encoder speed";
3226 for(
int j=0; j< _njoints; j++)
3235 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
3236 eOmc_motor_status_basic_t tmpMotorStatus;
3240 *
acc = (double) tmpMotorStatus.mot_acceleration;
3244 yError() <<
"embObjMotionControl while reading motor encoder acceleration";
3253 for(
int j=0; j< _njoints; j++)
3263 std::lock_guard<std::mutex> lck(_mutex);
3264 for(
int i=0; i<_njoints; i++)
3265 stamps[i] = _encodersStamp[i];
3272 std::lock_guard<std::mutex> lck(_mutex);
3273 *stamp = _encodersStamp[m];
3292 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_status_basic);
3293 eOmc_motor_status_basic_t tmpMotorStatus;
3296 *value = (double) tmpMotorStatus.mot_current;
3303 for(
int j=0; j< _njoints; j++)
3312 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_currentlimits);
3314 eOmc_current_limits_params_t currentlimits = {0};
3316 if(!askRemoteValue(protid, ¤tlimits, size))
3318 yError() <<
"embObjMotionControl::setMaxCurrentRaw() could not read max current for " << getBoardInfo() <<
"joint " << j;
3323 currentlimits.overloadCurrent = (eOmeas_current_t)
S_16(val);
3331 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_currentlimits);
3333 eOmc_current_limits_params_t currentlimits = {0};
3336 if(!askRemoteValue(protid, ¤tlimits, size))
3338 yError() <<
"embObjMotionControl::getMaxCurrentRaw() could not read max current for " << getBoardInfo() <<
"joint " << j;
3342 *val = (double) currentlimits.overloadCurrent;
3350 (_enabledAmp[j ]) ? *st = 1 : *st = 0;
3357 for(
int j=0; j<_njoints; j++)
3359 sts[j] = _enabledAmp[j];
3365#ifdef IMPLEMENT_DEBUG_INTERFACE
3370bool embObjMotionControl::setParameterRaw(
int j,
unsigned int type,
double value) {
return NOT_YET_IMPLEMENTED(
"setParameterRaw"); }
3371bool embObjMotionControl::getParameterRaw(
int j,
unsigned int type,
double* value) {
return NOT_YET_IMPLEMENTED(
"getParameterRaw"); }
3372bool embObjMotionControl::getDebugParameterRaw(
int j,
unsigned int index,
double* value) {
return NOT_YET_IMPLEMENTED(
"getDebugParameterRaw"); }
3373bool embObjMotionControl::setDebugParameterRaw(
int j,
unsigned int index,
double value) {
return NOT_YET_IMPLEMENTED(
"setDebugParameterRaw"); }
3374bool embObjMotionControl::setDebugReferencePositionRaw(
int j,
double value) {
return NOT_YET_IMPLEMENTED(
"setDebugReferencePositionRaw"); }
3375bool embObjMotionControl::getDebugReferencePositionRaw(
int j,
double* value) {
return NOT_YET_IMPLEMENTED(
"getDebugReferencePositionRaw");}
3383 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_userlimits);
3385 eOmeas_position_limits_t limits;
3386 limits.max = (eOmeas_position_t)
S_32(max);
3387 limits.min = (eOmeas_position_t)
S_32(min);
3394 yError() <<
"while setting position limits for joint" << j <<
" \n";
3401 eOmeas_position_limits_t limits;
3402 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_userlimits);
3405 if(! askRemoteValue(protoid, &limits, size))
3408 *min = (double)limits.min + SAFETY_THRESHOLD;
3409 *max = (double)limits.max - SAFETY_THRESHOLD;
3415 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3417 eOmc_motor_config_t motor_cfg;
3418 if(! askRemoteValue(protoid, &motor_cfg, size))
3422 *gearbox = (double)motor_cfg.gearbox_M2J;
3429 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3431 eOmc_motor_config_t motor_cfg;
3432 if(! askRemoteValue(protoid, &motor_cfg, size))
3434 *rotorMax = (double)( motor_cfg.limitsofrotor.max);
3435 *rotorMin = (double)( motor_cfg.limitsofrotor.min);
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.tcfiltertype;
3454 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3456 eOmc_motor_config_t motor_cfg;
3457 if(! askRemoteValue(protoid, &motor_cfg, size))
3461 rotres = (double)motor_cfg.rotorEncoderResolution;
3468 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3470 eOmc_joint_config_t joint_cfg;
3471 if(! askRemoteValue(protoid, &joint_cfg, size))
3475 jntres = (double)joint_cfg.jntEncoderResolution;
3482 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3484 eOmc_joint_config_t joint_cfg;
3485 if(! askRemoteValue(protoid, &joint_cfg, size))
3489 type = (int)joint_cfg.jntEncoderType;
3496 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3498 eOmc_motor_config_t motor_cfg;
3499 if(! askRemoteValue(protoid, &motor_cfg, size))
3503 type = (int)motor_cfg.rotorEncoderType;
3510 yError(
"getKinematicMJRaw not yet implemented");
3536 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3538 eOmc_motor_config_t motor_cfg;
3539 if(! askRemoteValue(protoid, &motor_cfg, size))
3543 ret = (int)motor_cfg.hasTempSensor;
3550 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3552 eOmc_motor_config_t motor_cfg;
3553 if(! askRemoteValue(protoid, &motor_cfg, size))
3557 ret = (int)motor_cfg.hasHallSensor;
3564 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3566 eOmc_motor_config_t motor_cfg;
3567 if(! askRemoteValue(protoid, &motor_cfg, size))
3571 ret = (int)motor_cfg.hasRotorEncoder;
3578 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3580 eOmc_motor_config_t motor_cfg;
3581 if(! askRemoteValue(protoid, &motor_cfg, size))
3585 ret = (int)motor_cfg.hasRotorEncoderIndex;
3592 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3595 eOmc_motor_config_t motor_cfg;
3596 if(! askRemoteValue(protoid, &motor_cfg, size))
3600 poles = (int)motor_cfg.motorPoles;
3607 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3609 eOmc_motor_config_t motor_cfg;
3610 if(! askRemoteValue(protoid, &motor_cfg, size))
3614 rotorOffset = (double)motor_cfg.rotorIndexOffset;
3621 if (axis >= 0 && axis < _njoints)
3623 name = _axesInfo[axis].name;
3635 if (axis >= 0 && axis < _njoints)
3637 type = _axesInfo[axis].type;
3646bool embObjMotionControl::getJointDeadZoneRaw(
int j,
double &jntDeadZone)
3648 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3650 eOmc_joint_config_t joint_cfg;
3651 if(! askRemoteValue(protoid, &joint_cfg, size))
3655 jntDeadZone = _measureConverter->posE2A((
double)joint_cfg.deadzone, _axisMap[j]);
3664 if (key ==
"kinematic_mj")
3667 Bottle& ret = val.addList();
3669 eOmn_serv_type_t mc_serv_type = (eOmn_serv_type_t)serviceConfig.
ethservice.configuration.type;
3670 if(iNeedCouplingsInfo())
3672 for (
int r=0; r<_njoints; r++)
3674 for (
int c = 0; c < _njoints; c++)
3678 ret.addFloat64(_couplingInfo.
matrixJ2M[4 * r + c]);
3684 ret.addFloat64(0.0);
3688 else if (key ==
"encoders")
3690 Bottle& r = val.addList();
for (
int i = 0; i < _njoints; i++) { r.addFloat64(_measureConverter->posA2E(1.0, i)); }
3693 else if (key ==
"rotorEncoderResolution")
3695 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getRotorEncoderResolutionRaw(i, tmp); r.addFloat64(tmp); }
3698 else if (key ==
"jointEncoderResolution")
3700 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getJointEncoderResolutionRaw(i, tmp); r.addFloat64(tmp); }
3703 else if (key ==
"gearbox_M2J")
3705 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp=0;
getGearboxRatioRaw(i, &tmp); r.addFloat64(tmp); }
3708 else if (key ==
"gearbox_E2J")
3710 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp=0; getGerabox_E2J(i, &tmp); r.addFloat64(tmp); }
3713 else if (key ==
"hasHallSensor")
3715 Bottle& r = val.addList();
for (
int i = 0; i < _njoints; i++) {
int tmp = 0;
getHasHallSensorRaw(i, tmp); r.addInt32(tmp); }
3718 else if (key ==
"hasTempSensor")
3720 Bottle& r = val.addList();
for (
int i = 0; i < _njoints; i++) {
int tmp = 0;
getHasTempSensorsRaw(i, tmp); r.addInt32(tmp); }
3723 else if (key ==
"TemperatureSensorType")
3725 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) { std::string tmp =
"";
getTemperatureSensorTypeRaw(i, tmp); r.addString(tmp); }
3728 else if (key ==
"hasRotorEncoder")
3730 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
int tmp = 0;
getHasRotorEncoderRaw(i, tmp); r.addInt32(tmp); }
3733 else if (key ==
"hasRotorEncoderIndex")
3735 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
int tmp = 0;
getHasRotorEncoderIndexRaw(i, tmp); r.addInt32(tmp); }
3738 else if (key ==
"rotorIndexOffset")
3740 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getRotorIndexOffsetRaw(i, tmp); r.addFloat64(tmp); }
3743 else if (key ==
"motorPoles")
3745 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
int tmp = 0;
getMotorPolesRaw(i, tmp); r.addInt32(tmp); }
3748 else if (key ==
"pidCurrentKp")
3750 Bottle& r = val.addList();
for (
int i = 0; i < _njoints; i++) { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p); r.addFloat64(
p.kp); }
3753 else if (key ==
"pidCurrentKi")
3755 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p); r.addFloat64(
p.ki); }
3758 else if (key ==
"pidCurrentShift")
3760 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p); r.addFloat64(
p.scale); }
3763 else if (key ==
"pidCurrentOutput")
3765 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); }
3768 else if (key ==
"jointEncoderType")
3770 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++)
3776 yError(
"Invalid jointEncoderType");
3782 else if (key ==
"rotorEncoderType")
3784 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++)
3790 yError(
"Invalid motorEncoderType");
3796 else if (key ==
"coulombThreshold")
3798 val.addString(
"not implemented yet");
3801 else if (key ==
"torqueControlFilterType")
3806 else if (key ==
"torqueControlEnabled")
3809 Bottle& r = val.addList();
3810 for(
int i = 0; i<_njoints; i++)
3812 r.addInt32((
int)_trq_pids[i].enabled );
3816 else if (key ==
"PWMLimit")
3818 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getPWMLimitRaw(i, &tmp); r.addFloat64(tmp); }
3821 else if (key ==
"motOverloadCurr")
3823 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getMaxCurrentRaw(i, &tmp); r.addFloat64(tmp); }
3826 else if (key ==
"motNominalCurr")
3828 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getNominalCurrentRaw(i, &tmp); r.addFloat64(tmp); }
3831 else if (key ==
"motPeakCurr")
3833 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getPeakCurrentRaw(i, &tmp); r.addFloat64(tmp); }
3836 else if (key ==
"PowerSuppVoltage")
3838 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getPowerSupplyVoltageRaw(i, &tmp); r.addFloat64(tmp); }
3841 else if (key ==
"rotorMax")
3844 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getRotorLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp2); }
3847 else if (key ==
"rotorMin")
3850 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getRotorLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp1); }
3853 else if (key ==
"jointMax")
3856 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp2); }
3859 else if (key ==
"jointMin")
3862 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp1); }
3865 else if (key ==
"jointEncTolerance")
3868 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0; getJointEncTolerance(i, &tmp1); r.addFloat64(tmp1); }
3871 else if (key ==
"motorEncTolerance")
3874 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0; getMotorEncTolerance(i, &tmp1); r.addFloat64(tmp1); }
3877 else if (key ==
"jointDeadZone")
3880 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0; getJointDeadZoneRaw(i, tmp1); r.addFloat64(tmp1); }
3883 else if (key ==
"readonly_position_PIDraw")
3885 Bottle& r = val.addList();
3886 for (
int i = 0; i < _njoints; i++)
3888 getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_POSITION, i, &
p);
3890 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);
3895 else if (key ==
"readonly_velocity_PIDraw")
3897 Bottle& r = val.addList();
3898 for (
int i = 0; i < _njoints; i++)
3899 { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, i, &
p);
3901 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);
3906 else if (key ==
"readonly_torque_PIDraw")
3908 Bottle& r = val.addList();
3909 for (
int i = 0; i < _njoints; i++)
3910 { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_TORQUE, i, &
p);
3912 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);
3917 else if (key ==
"readonly_current_PIDraw")
3919 Bottle& r = val.addList();
3920 for (
int i = 0; i < _njoints; i++)
3921 { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p);
3923 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);
3928 else if (key ==
"readonly_llspeed_PIDraw")
3930 Bottle& r = val.addList();
3931 for (
int i = 0; i < _njoints; i++)
3933 Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, i, &
p);
3935 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);
3940 else if (key ==
"readonly_motor_torque_params_raw")
3942 Bottle& r = val.addList();
3943 for (
int i = 0; i < _njoints; i++)
3945 MotorTorqueParameters params;
3948 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);
3953 yWarning(
"getRemoteVariable(): Unknown variable %s", key.c_str());
3959 string s1 = val.toString();
3960 if (val.size() != _njoints)
3962 yWarning(
"setRemoteVariable(): Protocol error %s", s1.c_str());
3966 if (key ==
"kinematic_mj")
3968 yWarning(
"setRemoteVariable(): Impossible to set kinematic_mj parameter at runtime.");
3981 else if (key ==
"PWMLimit")
3983 for (
int i = 0; i < _njoints; i++)
setPWMLimitRaw(i, val.get(i).asFloat64());
3988 else if (key ==
"jointMax")
3991 for (
int i = 0; i < _njoints; i++)
3998 else if (key ==
"jointMin")
4001 for (
int i = 0; i < _njoints; i++)
4008 yWarning(
"setRemoteVariable(): Unknown variable %s", key.c_str());
4014 listOfKeys->clear();
4015 listOfKeys->addString(
"kinematic_mj");
4016 listOfKeys->addString(
"encoders");
4017 listOfKeys->addString(
"gearbox_M2J");
4018 listOfKeys->addString(
"gearbox_E2J");
4019 listOfKeys->addString(
"hasHallSensor");
4020 listOfKeys->addString(
"hasTempSensor");
4021 listOfKeys->addString(
"TemperatureSensorType");
4022 listOfKeys->addString(
"hasRotorEncoder");
4023 listOfKeys->addString(
"hasRotorEncoderIndex");
4024 listOfKeys->addString(
"rotorIndexOffset");
4025 listOfKeys->addString(
"rotorEncoderResolution");
4026 listOfKeys->addString(
"jointEncoderResolution");
4027 listOfKeys->addString(
"motorPoles");
4028 listOfKeys->addString(
"pidCurrentKp");
4029 listOfKeys->addString(
"pidCurrentKi");
4030 listOfKeys->addString(
"pidCurrentShift");
4031 listOfKeys->addString(
"pidCurrentOutput");
4032 listOfKeys->addString(
"coulombThreshold");
4033 listOfKeys->addString(
"torqueControlFilterType");
4034 listOfKeys->addString(
"jointEncoderType");
4035 listOfKeys->addString(
"rotorEncoderType");
4036 listOfKeys->addString(
"PWMLimit");
4037 listOfKeys->addString(
"motOverloadCurr");
4038 listOfKeys->addString(
"motNominalCurr");
4039 listOfKeys->addString(
"motPeakCurr");
4040 listOfKeys->addString(
"PowerSuppVoltage");
4041 listOfKeys->addString(
"rotorMax");
4042 listOfKeys->addString(
"rotorMin");
4043 listOfKeys->addString(
"jointMax");
4044 listOfKeys->addString(
"jointMin");
4045 listOfKeys->addString(
"jointEncTolerance");
4046 listOfKeys->addString(
"motorEncTolerance");
4047 listOfKeys->addString(
"jointDeadZone");
4048 listOfKeys->addString(
"readonly_position_PIDraw");
4049 listOfKeys->addString(
"readonly_velocity_PIDraw");
4050 listOfKeys->addString(
"readonly_current_PIDraw");
4051 listOfKeys->addString(
"readonly_torque_PIDraw");
4052 listOfKeys->addString(
"readonly_motor_torque_params_raw");
4064 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_config);
4066 eOmc_joint_config_t joint_cfg;
4067 if(! askRemoteValue(protoid, &joint_cfg, size))
4070 *max = joint_cfg.maxvelocityofjoint;
4086 return VAS_status::VAS_OK;
4098 for(
int j=0; j< _njoints; j++)
4107 int j = _axisMap[userLevel_jointNumber];
4109 eOmeas_torque_t meas_torque = 0;
4110 static double curr_time = Time::now();
4111 static int count_saturation=0;
4113 meas_torque = (eOmeas_torque_t)
S_32(_measureConverter->trqN2S(fTorque, j));
4115 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_inputs_externallymeasuredtorque);
4130 eOmc_joint_status_core_t jstatus;
4131 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
4133 *t = (double) _measureConverter->trqS2N(jstatus.measures.meas_torque, j);
4140 for(
int j=0; j<_njoints; j++)
4158 for(
int j=0; j<_njoints && ret; j++)
4165 eOmc_setpoint_t setpoint;
4166 setpoint.type = (eOenum08_t) eomc_setpoint_torque;
4167 setpoint.to.torque.value = (eOmeas_torque_t)
S_32(t);
4169 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
4176 for(
int j=0; j< n_joint; j++)
4186 for(
int j=0; j<_njoints && ret; j++)
4193 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
4194 eOmc_joint_status_core_t jcore = {0};
4200 yError() <<
"embObjMotionControl::getRefTorqueRaw() could not read pid torque reference pos for " << getBoardInfo() <<
"joint " << j;
4204 if ((eOmc_interactionmode_compliant == jcore.modes.interactionmodestatus) &&
4205 (eomc_controlmode_position == jcore.modes.controlmodestatus))
4207 *t = (double) jcore.ofpid.complpos.reftrq;
4210 if(eomc_controlmode_torque == jcore.modes.controlmodestatus)
4212 *t = (double) jcore.ofpid.torque.reftrq;
4218bool embObjMotionControl::helper_setTrqPidRaw(
int j,
const Pid &pid)
4226 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtorque);
4230bool embObjMotionControl::helper_getTrqPidRaw(
int j, Pid *pid)
4232 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtorque);
4236 if(! askRemoteValue(protoid, &eoPID, size))
4245bool embObjMotionControl::helper_getTrqPidsRaw(Pid *pid)
4247 std::vector<eOmc_PID_t> eoPIDList (_njoints);
4248 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_config_pidtorque, eoPIDList);
4251 for(
int j=0; j< _njoints; j++)
4263 eOmc_impedance_t val;
4268 *stiffness = (double) (val.stiffness);
4269 *damping = (double) (val.damping);
4277 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_impedance);
4279 if(! askRemoteValue(protoid, &imped, size))
4283 _cacheImpedance->damping = imped.damping;
4284 _cacheImpedance->stiffness = imped.stiffness;
4285 _cacheImpedance->offset = imped.offset;
4292 eOmc_impedance_t val;
4300 _cacheImpedance[j].stiffness = (eOmeas_stiffness_t) stiffness;
4301 _cacheImpedance[j].damping = (eOmeas_damping_t) damping;
4303 val.stiffness = _cacheImpedance[j].stiffness;
4304 val.damping = _cacheImpedance[j].damping;
4305 val.offset = _cacheImpedance[j].offset;
4307 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_impedance);
4317 eOmc_impedance_t val;
4323 _cacheImpedance[j].offset = (eOmeas_torque_t)
S_32(
offset);
4324 val.stiffness = _cacheImpedance[j].stiffness;
4325 val.damping = _cacheImpedance[j].damping;
4326 val.offset = _cacheImpedance[j].offset;
4328 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_impedance);
4338 eOmc_impedance_t val;
4349 *min_stiff = _impedance_limits[j].
min_stiff;
4350 *max_stiff = _impedance_limits[j].
max_stiff;
4351 *min_damp = _impedance_limits[j].
min_damp;
4352 *max_damp = _impedance_limits[j].
max_damp;
4358 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_motor_params);
4361 eOmc_motor_params_t eo_params = {0};
4362 if(! askRemoteValue(protoid, &eo_params, size))
4365 params->bemf = eo_params.bemf_value;
4366 params->bemf_scale = eo_params.bemf_scale;
4367 params->ktau = eo_params.ktau_value;
4368 params->ktau_scale = eo_params.ktau_scale;
4369 params->viscousPos = eo_params.friction.viscous_pos_val;
4370 params->viscousNeg = eo_params.friction.viscous_neg_val ;
4371 params->coulombPos = eo_params.friction.coulomb_pos_val;
4372 params->coulombNeg = eo_params.friction.coulomb_neg_val;
4373 params->velocityThres = eo_params.friction.velocityThres_val;
4382 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_motor_params);
4383 eOmc_motor_params_t eo_params = {0};
4387 eo_params.bemf_value = (float) params.bemf;
4388 eo_params.bemf_scale = (uint8_t) params.bemf_scale;
4389 eo_params.ktau_value = (float) params.ktau;
4390 eo_params.ktau_scale = (uint8_t) params.ktau_scale;
4391 eo_params.friction.viscous_pos_val =
static_cast<float32_t
>(params.viscousPos);
4392 eo_params.friction.viscous_neg_val =
static_cast<float32_t
>(params.viscousNeg);
4393 eo_params.friction.coulomb_pos_val =
static_cast<float32_t
>(params.coulombPos);
4394 eo_params.friction.coulomb_neg_val =
static_cast<float32_t
>(params.coulombNeg);
4395 eo_params.friction.velocityThres_val =
static_cast<float32_t
>(params.velocityThres);
4400 yError() <<
"embObjMotionControl::setMotorTorqueParamsRaw() could not send set message for" << getBoardInfo() <<
"joint " << j;
4412 for(
int j=0; j< n_joint; j++)
4446bool embObjMotionControl::helper_getVelPidRaw(
int j, Pid *pid)
4448 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_piddirect);
4451 if(! askRemoteValue(protoid, &eoPID, size))
4461bool embObjMotionControl::helper_getVelPidsRaw(Pid *pid)
4463 std::vector <eOmc_PID_t> eoPIDList (_njoints);
4464 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_config_piddirect, eoPIDList);
4468 for(
int j=0; j<_njoints; j++)
4483 if (mode != VOCAB_CM_POSITION_DIRECT &&
4484 mode != VOCAB_CM_IDLE)
4488 yError() <<
"setReferenceRaw: skipping command because" << getBoardInfo() <<
" joint " << j <<
" is not in VOCAB_CM_POSITION_DIRECT mode";
4493 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
4494 eOmc_setpoint_t setpoint = {0};
4496 _ref_positions[j] = ref;
4497 setpoint.type = (eOenum08_t) eomc_setpoint_positionraw;
4498 setpoint.to.position.value = (eOmeas_position_t)
S_32(ref);
4499 setpoint.to.position.withvelocity = 0;
4507 for(
int i=0; i<n_joint; i++)
4517 for (
int i = 0; i<_njoints; i++)
4527 if (axis<0 || axis>_njoints)
return false;
4528#if ASK_REFERENCE_TO_FIRMWARE
4529 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_target);
4534 eOmc_joint_status_target_t target = {0};
4535 if(!askRemoteValue(id32, &target, size))
4537 yError() <<
"embObjMotionControl::getTargetPositionRaw() could not read reference pos for " << getBoardInfo() <<
"joint " << axis;
4541 *ref = (double) target.trgt_position;
4545 *ref = _ref_command_positions[axis];
4553 for (
int i = 0; i<_njoints; i++)
4563 for (
int i = 0; i<nj; i++)
4572 if (axis<0 || axis>_njoints)
return false;
4573#if ASK_REFERENCE_TO_FIRMWARE
4574 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_target);
4579 eOmc_joint_status_target_t target = {0};
4580 if(!askRemoteValue(id32, &target, size))
4582 yError() <<
"embObjMotionControl::getRefVelocityRaw() could not read reference vel for " << getBoardInfo() <<
"joint " << axis;
4585 *ref = (double) target.trgt_velocity;
4588 *ref = _ref_command_speeds[axis];
4595 #if ASK_REFERENCE_TO_FIRMWARE
4596 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
4597 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
4600 yError() <<
"embObjMotionControl::getRefVelocitiesRaw() could not read reference vel for " << getBoardInfo() ;
4604 for(
int j=0; j<_njoints; j++)
4606 refs[j] = (double) targetList[j].trgt_velocity;
4610 for(
int j=0; j<_njoints; j++)
4612 refs[j] = _ref_command_speeds[j];
4620 std::vector <double> refsList(_njoints);
4624 for (
int i = 0; i<nj; i++)
4626 if(jnts[i]>= _njoints)
4628 yError() << getBoardInfo() <<
"getRefVelocitiesRaw: joint " << jnts[i] <<
"doesn't exist";
4631 refs[i] = refsList[jnts[i]];
4638 if (axis<0 || axis>_njoints)
return false;
4639#if ASK_REFERENCE_TO_FIRMWARE
4640 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_target);
4644 eOmc_joint_status_target_t target = {0};
4645 if(!askRemoteValue(id32, &target, size))
4647 yError() <<
"embObjMotionControl::getRefPositionRaw() could not read reference pos for " << getBoardInfo() <<
"joint " << axis;
4651 *ref = (double) target.trgt_positionraw;
4654 *ref = _ref_positions[axis];
4661 #if ASK_REFERENCE_TO_FIRMWARE
4662 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
4663 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
4666 yError() <<
"embObjMotionControl::getRefPositionRaw() could not read reference pos for " << getBoardInfo();
4670 for(
int j=0; j< _njoints; j++)
4671 refs[j] = (
double) targetList[j].trgt_positionraw;
4674 for(
int j=0; j< _njoints; j++)
4675 refs[j] = _ref_positions[j];
4683 for (
int i = 0; i<nj; i++)
4696 eOenum08_t interactionmodestatus;
4699 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core_modes_interactionmodestatus);
4703 int tmp = (int) *_mode;
4707 *_mode = (yarp::dev::InteractionModeEnum) tmp;
4726 for(
int j=0; j<_njoints; j++)
4736 eOenum08_t interactionmodecommand = 0;
4741 if (_mode == VOCAB_IM_COMPLIANT && _trq_pids[j].enabled ==
false) {yError()<<
"Torque control is disabled. Check your configuration parameters";
return false;}
4745 yError() <<
"setInteractionModeRaw: received unknown mode for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
4748 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() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
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))
4765 yError() <<
"check of embObjMotionControl::setInteractionModeRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
4778 eOenum08_t interactionmodecommand = 0;
4780 for(
int j=0; j<n_joints; j++)
4782 if (modes[j] == VOCAB_IM_COMPLIANT && _trq_pids[j].enabled ==
false) {yError()<<
"Torque control is disabled. Check your configuration parameters";
continue;}
4786 yError() <<
"embObjMotionControl::setInteractionModesRaw(): received unknown interactionMode for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]) <<
" " << modes[j];
4790 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_interactionmode);
4791 if(
false == res->
setRemoteValue(protid, &interactionmodecommand) )
4793 yError() <<
"embObjMotionControl::setInteractionModesRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4799 eOenum08_t interactionmodestatus = 0;
4801 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_interactionmodestatus);
4802 bool ret = askRemoteValue(id32, &interactionmodestatus, size);
4804 if((
false == ret) || (interactionmodecommand != interactionmodestatus))
4808 yError() <<
"check of embObjMotionControl::setInteractionModesRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4814 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4815 << Vocab32::decode(modes[j]) <<
" Got " << Vocab32::decode(tmp);
4817 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4818 << Vocab32::decode(modes[j]) <<
" Got an unknown value!";
4831 eOenum08_t interactionmodecommand = 0;
4833 for(
int j=0; j<_njoints; j++)
4835 if ((modes[j] == VOCAB_IM_COMPLIANT) && (_trq_pids[j].enabled ==
false))
4837 yError()<<
"Torque control is disabled. Check your configuration parameters";
4843 yError() <<
"setInteractionModeRaw: received unknown interactionMode for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4847 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_interactionmode);
4848 if(
false == res->
setRemoteValue(protid, &interactionmodecommand) )
4850 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4856 eOenum08_t interactionmodestatus = 0;
4858 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_interactionmodestatus);
4859 bool ret = askRemoteValue(id32, &interactionmodestatus, size);
4861 if((
false == ret) || (interactionmodecommand != interactionmodestatus))
4865 yError() <<
"check of embObjMotionControl::setInteractionModesRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4871 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4872 << Vocab32::decode(modes[j]) <<
" Got " << Vocab32::decode(tmp);
4874 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4875 << Vocab32::decode(modes[j]) <<
" Got an unknown value!";
4888 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
4889 eOmc_joint_status_core_t jcore = {0};
4896 case VOCAB_PIDTYPE_POSITION:
4897 if((eomc_controlmode_torque == jcore.modes.controlmodestatus) || (eomc_controlmode_current == jcore.modes.controlmodestatus))
4900 *
out = (double) jcore.ofpid.generic.output;
4905 case VOCAB_PIDTYPE_TORQUE:
4906 if ((eomc_controlmode_torque == jcore.modes.controlmodestatus) ||
4907 ((eomc_controlmode_position == jcore.modes.controlmodestatus) && (eOmc_interactionmode_compliant == jcore.modes.interactionmodestatus)))
4908 *
out = jcore.ofpid.generic.output;
4912 case VOCAB_PIDTYPE_CURRENT:
4915 case VOCAB_PIDTYPE_VELOCITY:
4919 yError()<<
"Invalid pidtype:"<<pidtype;
4928 for(
int j=0; j< _njoints; j++)
4948 eOmc_motor_status_basic_t status;
4949 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
4959 yError() << getBoardInfo() <<
"At timestamp" << yarp::os::Time::now() <<
"In motor" << m <<
"embObjMotionControl::getTemperatureRaw failed to complete getLocalValue()";
4963 *val = _temperatureSensorsVector.at(m)->convertRawToTempCelsius((
double)status.mot_temperature);
4972 for(
int j=0; j< _njoints; j++)
4981 *temp= _temperatureLimits[m].warningTemperatureLimit;
4988 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_temperaturelimit);
4989 eOmeas_temperature_t temperatureLimit = (eOmeas_pwm_t)
S_16(temp);
4996 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
4998 eOmc_current_limits_params_t currentlimits = {0};
5000 if(!askRemoteValue(protid, ¤tlimits, size))
5002 yError() <<
"embObjMotionControl::getPeakCurrentRaw() can't read current limits for" << getBoardInfo() <<
" motor " << m;
5006 *val = (double) currentlimits.peakCurrent ;
5012 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::setPeakCurrentRaw can't read current limits for" << getBoardInfo() <<
" motor " << m ;
5023 currentlimits.peakCurrent = (eOmeas_current_t)
S_16(val);
5029 yError() <<
"embObjMotionControl::setPeakCurrentRaw failed sending new value for" << getBoardInfo() <<
" motor " << m ;
5036 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
5038 eOmc_current_limits_params_t currentlimits = {0};
5040 if(!askRemoteValue(protid, ¤tlimits, size))
5042 yError() <<
"embObjMotionControl::getNominalCurrentRaw() can't read current limits for" << getBoardInfo() <<
" motor " << m;
5046 *val = (double) currentlimits.nominalCurrent ;
5052 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
5056 eOmc_current_limits_params_t currentlimits = {0};
5057 if(!askRemoteValue(protid, ¤tlimits, size))
5059 yError() <<
"embObjMotionControl::setNominalCurrentRaw can't read current limits for" << getBoardInfo() <<
" motor " << m ;
5064 currentlimits.nominalCurrent = (eOmeas_current_t)
S_16(val);
5070 yError() <<
"embObjMotionControl::setNominalCurrentRaw failed sending new value for" << getBoardInfo() <<
" motor " << m ;
5078 eOmc_motor_status_basic_t status;
5079 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_status_basic);
5084 *val = (double) status.mot_pwm;
5088 yError() <<
"embObjMotionControl::getPWMRaw failed for" << getBoardInfo() <<
" motor " << j ;
5097 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pwmlimit);
5099 eOmeas_pwm_t motorPwmLimit;
5101 bool ret = askRemoteValue(protid, &motorPwmLimit, size);
5104 *val = (double) motorPwmLimit;
5108 yError() <<
"embObjMotionControl::getPWMLimitRaw failed for" << getBoardInfo() <<
" motor " << j ;
5119 yError() <<
"embObjMotionControl::setPWMLimitRaw failed because pwmLimit is negative for" << getBoardInfo() <<
" motor " << j ;
5122 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pwmlimit);
5123 eOmeas_pwm_t motorPwmLimit = (eOmeas_pwm_t)
S_16(val);
5129 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_controller, 0, eoprot_tag_mc_controller_status);
5131 eOmc_controller_status_t controllerStatus;
5133 bool ret = askRemoteValue(protid, &controllerStatus, size);
5136 *val = (double) controllerStatus.supplyVoltage;
5140 yError() <<
"embObjMotionControl::getPowerSupplyVoltageRaw failed for" << getBoardInfo() <<
" motor " << j ;
5147bool embObjMotionControl::askRemoteValue(eOprotID32_t id32,
void* value, uint16_t& size)
5154bool embObjMotionControl::askRemoteValues(eOprotEndpoint_t ep, eOprotEntity_t entity, eOprotTag_t tag, std::vector<T>& values)
5156 std::vector<eOprotID32_t> idList;
5157 std::vector<void*> valueList;
5160 for(
int j=0; j<_njoints; j++)
5162 eOprotID32_t protoId = eoprot_ID_get(ep, entity, j, tag);
5163 idList.push_back(protoId);
5164 valueList.push_back((
void*)&values[j]);
5170 yError() <<
"embObjMotionControl::askRemoteValues failed for all joints of" << getBoardInfo();
5179bool embObjMotionControl::checkRemoteControlModeStatus(
int joint,
int target_mode)
5182 eOenum08_t temp = 0;
5185 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joint, eoprot_tag_mc_joint_status_core_modes_controlmodestatus);
5186 const double timeout = 0.250;
5187 const int maxretries = 25;
5188 const double delaybetweenqueries = 0.010;
5192 double timeofstart = yarp::os::Time::now();
5195 for( attempt = 0; attempt < maxretries; attempt++)
5197 ret = askRemoteValue(id32, &temp, size);
5200 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());
5204 if(current_mode == target_mode)
5209 if((current_mode == VOCAB_CM_IDLE) && (target_mode == VOCAB_CM_FORCE_IDLE))
5214 if(current_mode == VOCAB_CM_HW_FAULT)
5216 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()); }
5221 if((yarp::os::Time::now()-timeofstart) > timeout)
5224 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());
5229 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());
5231 SystemClock::delaySystem(delaybetweenqueries);
5236 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);
5244bool embObjMotionControl::iNeedCouplingsInfo(
void)
5246 eOmn_serv_type_t mc_serv_type = (eOmn_serv_type_t)serviceConfig.
ethservice.configuration.type;
5247 if( (mc_serv_type == eomn_serv_MC_foc) ||
5248 (mc_serv_type == eomn_serv_MC_mc4plus) ||
5249 (mc_serv_type == eomn_serv_MC_mc4plusmais) ||
5250 (mc_serv_type == eomn_serv_MC_mc2pluspsc) ||
5251 (mc_serv_type == eomn_serv_MC_mc4plusfaps) ||
5252 (mc_serv_type == eomn_serv_MC_advfoc)
5262 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
5264 eOmc_setpoint_t setpoint;
5266 setpoint.type = (eOenum08_t)eomc_setpoint_openloop;
5267 setpoint.to.openloop.value = (eOmeas_pwm_t)
S_16(v);
5275 for (
int j = 0; j<_njoints; j++)
5284 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_target);
5287 eOmc_joint_status_target_t target = { 0 };
5290 if (!askRemoteValue(protoId, &target, size))
5292 yError() <<
"embObjMotionControl::getRefDutyCycleRaw() could not read openloop reference for " << getBoardInfo() <<
"joint " << j;
5296 *v = (double)target.trgt_pwm;
5303 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
5304 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
5307 yError() <<
"embObjMotionControl::getDutyCyclesRaw failed for all joints of" << getBoardInfo();
5310 for (
int j = 0; j<_njoints; j++)
5312 v[j]= targetList[j].trgt_pwm;
5319 eOmc_motor_status_basic_t status;
5320 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_status_basic);
5325 *v = (double)status.mot_pwm;
5329 yError() <<
"embObjMotionControl::getDutyCycleRaw failed for" << getBoardInfo() <<
" motor " << j;
5339 for (
int j = 0; j< _njoints; j++)
5361 for (
int j = 0; j< _njoints; j++)
5371 for (
int j = 0; j<_njoints; j++)
5380 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
5382 eOmc_setpoint_t setpoint;
5384 setpoint.type = (eOenum08_t)eomc_setpoint_current;
5385 setpoint.to.current.value = (eOmeas_pwm_t)
S_16(t);
5393 for (
int j = 0; j<n_joint; j++)
5402 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
5403 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
5406 yError() <<
"embObjMotionControl::getDutyCyclesRaw failed for all joints of" << getBoardInfo();
5409 for (
int j = 0; j<_njoints; j++)
5411 t[j] = targetList[j].trgt_current;
5418 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_target);
5421 eOmc_joint_status_target_t target = { 0 };
5424 if (!askRemoteValue(protoId, &target, size))
5426 yError() <<
"embObjMotionControl::getRefDutyCycleRaw() could not read openloop reference for " << getBoardInfo() <<
"joint " << j;
5430 *t = (double)target.trgt_current;
5435bool embObjMotionControl::helper_setCurPidRaw(
int j,
const Pid &pid)
5437 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pidcurrent);
5441 if (!_cur_pids[j].enabled)
5443 yError() <<
"eoMc " << getBoardInfo() <<
": it is not possible set current pid for motor " << j <<
", because current pid is not enabled in xml files";
5451 yError() <<
"while setting velocity PIDs for" << getBoardInfo() <<
" joint " << j;
5460bool embObjMotionControl::helper_setSpdPidRaw(
int j,
const Pid &pid)
5462 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pidspeed);
5466 if (!_cur_pids[j].enabled)
5468 yError() <<
"eoMc " << getBoardInfo() <<
": it is not possible set speed pid for motor " << j <<
", because speed pid is not enabled in xml files";
5476 yError() <<
"while setting velocity PIDs for" << getBoardInfo() <<
" joint " << j;
5485bool embObjMotionControl::helper_getCurPidRaw(
int j, Pid *pid)
5487 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
5489 eOmc_motor_config_t motor_cfg;
5490 if(! askRemoteValue(protoid, &motor_cfg, size))
5494 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg.pidcurrent;
5500bool embObjMotionControl::helper_getSpdPidRaw(
int j, Pid *pid)
5502 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
5504 eOmc_motor_config_t motor_cfg;
5505 if (!askRemoteValue(protoid, &motor_cfg, size))
5509 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg.pidspeed;
5515bool embObjMotionControl::helper_getCurPidsRaw(Pid *pid)
5517 std::vector <eOmc_motor_config_t> motor_cfg_list(_njoints);
5518 bool ret = askRemoteValues<eOmc_motor_config_t>(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, eoprot_tag_mc_motor_config, motor_cfg_list);
5522 for(
int j=0; j<_njoints; j++)
5524 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg_list[j].pidcurrent;
5530bool embObjMotionControl::helper_getSpdPidsRaw(Pid *pid)
5532 std::vector <eOmc_motor_config_t> motor_cfg_list(_njoints);
5533 bool ret = askRemoteValues<eOmc_motor_config_t>(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, eoprot_tag_mc_motor_config, motor_cfg_list);
5537 for (
int j = 0; j<_njoints; j++)
5539 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg_list[j].pidspeed;
5545bool embObjMotionControl::getJointConfiguration(
int joint, eOmc_joint_config_t *jntCfg_ptr)
5547 uint32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joint, eoprot_tag_mc_joint_config);
5549 if(!askRemoteValue(protoid, jntCfg_ptr, size))
5557bool embObjMotionControl::getMotorConfiguration(
int axis, eOmc_motor_config_t *motCfg_ptr)
5559 uint32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, axis, eoprot_tag_mc_motor_config);
5561 if(!askRemoteValue(protoid, motCfg_ptr, size))
5570bool embObjMotionControl::getGerabox_E2J(
int joint,
double *gearbox_E2J_ptr)
5572 eOmc_joint_config_t jntCfg;
5574 if(!getJointConfiguration(joint, &jntCfg))
5579 *gearbox_E2J_ptr = jntCfg.gearbox_E2J;
5583bool embObjMotionControl::getJointEncTolerance(
int joint,
double *jEncTolerance_ptr)
5585 eOmc_joint_config_t jntCfg;
5587 if(!getJointConfiguration(joint, &jntCfg))
5592 *jEncTolerance_ptr = jntCfg.jntEncTolerance;
5596bool embObjMotionControl::getMotorEncTolerance(
int axis,
double *mEncTolerance_ptr)
5598 eOmc_motor_config_t motorCfg;
5599 if(!getMotorConfiguration(axis, &motorCfg))
5604 *mEncTolerance_ptr = motorCfg.rotEncTolerance;
5610 eOmc_motor_status_t status;
5612 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol,
5613 eoprot_entity_mc_motor, j,
5614 eoprot_tag_mc_motor_status);
5623 message =
"Could not retrieve the fault state.";
5627 if (status.mc_fault_state == EOERROR_CODE_DUMMY)
5629 fault = EOERROR_CODE_DUMMY;
5630 message =
"No fault detected.";
5635 fault = eoerror_code2value(status.mc_fault_state);
5636 message = eoerror_code2string(status.mc_fault_state);
5641bool embObjMotionControl::getRawData_core(std::string key, std::vector<std::int32_t> &
data)
5646 for(
int j=0; j< _njoints; j++)
5648 eOmc_joint_status_additionalInfo_t addinfo;
5649 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_addinfo_multienc);
5654 for (
int k = 0; k < std::size(addinfo.multienc); k++)
5656 data.push_back((int32_t)addinfo.multienc[k]);
5665 for (
auto it = _rawValuesMetadataMap.begin(); it != _rawValuesMetadataMap.end(); it++)
5667 if(!getRawData_core(it->first, _rawDataAuxVector))
5669 yError() << getBoardInfo() <<
"getRawData failed. Cannot retrieve all raw data from local memory";
5672 map.insert({it->first, _rawDataAuxVector});
5680 if(_rawValuesMetadataMap.find(key) != _rawValuesMetadataMap.end())
5682 getRawData_core(key,
data);
5686 yError() << getBoardInfo() <<
"Request key:" << key <<
"is not available. Cannot retrieve get raw data.";
5695 for (
const auto &
p : _rawValuesMetadataMap)
5697 keys.push_back(
p.first);
5705 return _rawValuesMetadataMap.size();
5710 if (_rawValuesMetadataMap.empty())
5712 yError() << getBoardInfo() <<
"embObjMotionControl Map is empty. Closing...";
5721 if(_rawValuesMetadataMap.find(key) != _rawValuesMetadataMap.end())
5723 meta = _rawValuesMetadataMap[key];
5727 yError() << getBoardInfo() <<
"Requested key" << key <<
"is not available in the map. Closing...";
5738 if (_rawValuesMetadataMap.find(key) != _rawValuesMetadataMap.end())
5740 axesNames.assign(_rawValuesMetadataMap[key].axesNames.begin(), _rawValuesMetadataMap[key].axesNames.end());
5744 yError() << getBoardInfo() <<
"Requested key" << key <<
"is not available in the map. Exiting";
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 getAxesNames(std::string key, std::vector< std::string > &axesNames) 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 parseTimeoutsGroup(yarp::os::Searchable &config, std::vector< timeouts_t > &timeouts, int defaultTimeout)
bool parseMaintenanceModeGroup(yarp::os::Searchable &config, bool &skipRecalibrationEnabled)
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 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 read(yarp::os::Searchable &cfgtotal, pc104Data &pc104data)
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_appl_config_t txconfig
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
bool enableSkipRecalibration