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"
41 using namespace yarp::os;
42 using namespace yarp::os::impl;
50 #define ASK_REFERENCE_TO_FIRMWARE 1
52 #define PARSER_MOTION_CONTROL_VERSION 6
57 yError() << txt <<
" is not yet implemented for embObjMotionControl";
63 yError() << txt <<
" has been deprecated for embObjMotionControl";
67 #define NV_NOT_FOUND return nv_not_found();
71 yError () <<
" nv_not_found!! This may mean that this variable is not handled by this EMS\n";
77 std::string embObjMotionControl::getBoardInfo(
void)
81 return " BOARD name_unknown (IP unknown) ";
85 return (
"BOARD " + res->getProperties().boardnameString +
" (IP " + res->getProperties().ipv4addrString +
") ");
90 bool 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 _axesInfo.resize(nj);
129 _jointEncs.resize(nj);
130 _motorEncs.resize(nj);
131 _kalman_params.resize(nj);
132 _temperatureSensorsVector.resize(nj);
133 _temperatureExceededLimitWatchdog.resize(nj);
134 _temperatureSensorErrorWatchdog.resize(nj);
135 _temperatureSpikesFilter.resize(nj);
138 uint8_t txrate = res->getProperties().txROPratedivider;
139 for(
int i = 0; i < nj; ++i)
141 _temperatureExceededLimitWatchdog.at(i).setThreshold(txrate);
142 _temperatureSensorErrorWatchdog.at(i).setThreshold(txrate);
148 bool embObjMotionControl::dealloc()
150 checkAndDestroy(_axisMap);
151 checkAndDestroy(_encodersStamp);
152 checkAndDestroy(_gearbox_M2J);
153 checkAndDestroy(_gearbox_E2J);
154 checkAndDestroy(_deadzone);
155 checkAndDestroy(_impedance_limits);
156 checkAndDestroy(checking_motiondone);
157 checkAndDestroy(_ref_command_positions);
158 checkAndDestroy(_ref_positions);
159 checkAndDestroy(_ref_command_speeds);
160 checkAndDestroy(_ref_speeds);
161 checkAndDestroy(_ref_accs);
163 checkAndDestroy(_enabledAmp);
164 checkAndDestroy(_enabledPid);
165 checkAndDestroy(_calibrated);
166 checkAndDestroy(_foc_based_info);
188 ImplementControlCalibration(this),
189 ImplementAmplifierControl(this),
190 ImplementPidControl(this),
191 ImplementEncodersTimed(this),
192 ImplementPositionControl(this),
193 ImplementVelocityControl(this),
194 ImplementControlMode(this),
195 ImplementImpedanceControl(this),
196 ImplementMotorEncoders(this),
197 #ifdef IMPLEMENT_DEBUG_INTERFACE
200 ImplementTorqueControl(this),
201 ImplementControlLimits(this),
202 ImplementPositionDirect(this),
203 ImplementInteractionMode(this),
204 ImplementMotor(this),
205 ImplementRemoteVariables(this),
206 ImplementAxisInfo(this),
207 ImplementPWMControl(this),
208 ImplementCurrentControl(this),
209 ImplementJointFault(this),
210 SAFETY_THRESHOLD(2.0),
214 _temperatureLimits(0),
218 _impedance_params(0),
223 _temperatureSensorsVector(0),
224 _temperatureExceededLimitWatchdog(0),
225 _temperatureSensorErrorWatchdog(0),
226 _temperatureSpikesFilter(0),
227 _rawDataAuxVector(0),
228 _rawValuesMetadataMap({})
242 _encodersStamp = NULL;
243 _foc_based_info = NULL;
244 _cacheImpedance = NULL;
245 _impedance_limits = NULL;
247 _ref_command_speeds = NULL;
248 _ref_command_positions= NULL;
249 _ref_positions = NULL;
251 _measureConverter = NULL;
253 checking_motiondone = NULL;
264 _last_position_move_time = NULL;
266 behFlags.useRawEncoderData =
false;
267 behFlags.pwmIsLimited =
false;
269 std::string
tmp = yarp::conf::environment::get_string(
"ETH_VERBOSEWHENOK");
272 behFlags.verbosewhenok = (bool)yarp::conf::numeric::from_string(
tmp, 0U);
276 behFlags.verbosewhenok =
false;
281 #ifdef NETWORK_PERFORMANCE_BENCHMARK
285 m_responseTimingVerifier.init(0.003, 0.00025, 0.001, 0.01, 0.0005, 30);
293 yTrace() <<
"embObjMotionControl::~embObjMotionControl()";
301 if(NULL != _mcparser)
319 ImplementControlCalibration::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
320 ImplementAmplifierControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.ampsToSensor);
321 ImplementEncodersTimed::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
322 ImplementMotorEncoders::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
323 ImplementPositionControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
324 ImplementPidControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.newtonsToSensor,
f.ampsToSensor,
f.dutycycleToPWM);
325 ImplementControlMode::initialize(_njoints, _axisMap);
326 ImplementVelocityControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
327 ImplementControlLimits::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
328 ImplementImpedanceControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.newtonsToSensor);
329 ImplementTorqueControl::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL,
f.newtonsToSensor,
f.ampsToSensor,
f.dutycycleToPWM,
f.bemf2raw,
f.ktau2raw);
330 ImplementPositionDirect::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
331 ImplementInteractionMode::initialize(_njoints, _axisMap,
f.angleToEncoder, NULL);
332 ImplementMotor::initialize(_njoints, _axisMap);
333 ImplementRemoteVariables::initialize(_njoints, _axisMap);
334 ImplementAxisInfo::initialize(_njoints, _axisMap);
335 ImplementCurrentControl::initialize(_njoints, _axisMap,
f.ampsToSensor);
336 ImplementPWMControl::initialize(_njoints, _axisMap,
f.dutycycleToPWM);
337 ImplementJointFault::initialize(_njoints, _axisMap);
348 if(NULL == ethManager)
350 yFatal() <<
"embObjMotionControl::open() fails to instantiate ethManager";
354 eOipv4addr_t ipv4addr;
355 string boardIPstring;
357 if(
false == ethManager->
verifyEthBoardInfo(config, ipv4addr, boardIPstring, boardName))
359 yError() <<
"embObjMotionControl::open(): object TheEthManager fails in parsing ETH propertiex from xml file";
378 yError() <<
"embObjMotionControl::open() fails because could not instantiate the ethResource for " << getBoardInfo() <<
" ... unable to continue";
382 if(!fromConfig(config))
384 yError() << getBoardInfo() <<
"Missing motion control parameters in config file";
390 yError() <<
"embObjMotionControl: failed verifyEPprotocol. Cannot continue!";
396 const eOmn_serv_parameter_t* servparam = &serviceConfig.
ethservice;
397 if(eomn_serv_MC_generic == serviceConfig.
ethservice.configuration.type)
403 mcdiagnostics.
config.mode = serviceConfig.
ethservice.configuration.diagnosticsmode;
404 mcdiagnostics.
config.par16 = serviceConfig.
ethservice.configuration.diagnosticsparam;
405 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
408 mcdiagnostics.
ports.resize(2);
409 for(
size_t i=0; i<mcdiagnostics.
ports.size(); i++)
411 mcdiagnostics.
ports[i] =
new BufferedPort<Bottle>;
422 event_downsampler->
config.
info = getBoardInfo();
423 event_downsampler->
start();
427 yError() <<
"embObjMotionControl::open() has an error in call of ethResources::serviceVerifyActivate() for" << getBoardInfo();
432 yDebug() <<
"embObjMotionControl:serviceVerifyActivate OK!";
437 yError() <<
"embObjMotionControl::open() has an error in call of embObjMotionControl::init() for" << getBoardInfo();
444 yDebug() <<
"embObjMotionControl::init() has succesfully initted" << getBoardInfo();
451 yError() <<
"embObjMotionControl::open() fails to start mc service for" << getBoardInfo() <<
": cannot continue";
459 yDebug() <<
"embObjMotionControl::open() correctly starts mc service of" << getBoardInfo();
467 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
498 SystemClock::delaySystem(0.001*mcdiagnostics.
config.par16);
505 int embObjMotionControl::fromConfig_NumOfJoints(yarp::os::Searchable &config)
510 int jn = config.findGroup(
"GENERAL").check(
"Joints", Value(1),
"Number of degrees of freedom").asInt32();
517 void embObjMotionControl::debugUtil_printJointsetInfo(
void)
520 yError() <<
"****** DEBUG PRINTS **********";
521 yError() <<
"joint to set:";
522 for(
int x=0;
x< _njoints;
x++)
523 yError() <<
" /t j " <<
x <<
": set " <<_joint2set[
x];
524 yError() <<
"jointmap:";
526 yError() <<
" number of sets" << _jsets.size();
527 for(
size_t x=0;
x< _jsets.size();
x++)
529 yError() <<
"set " <<
x<<
"has size " <<_jsets[
x].getNumberofJoints();
530 for(
int y=0;
y<_jsets[
x].getNumberofJoints();
y++)
531 yError() <<
"set " <<
x <<
": " << _jsets[
x].joints[
y];
533 yError() <<
"********* END ****************";
540 bool embObjMotionControl::verifyUserControlLawConsistencyInJointSet(
eomc::PidInfo *pidInfo)
543 for(
size_t s=0; s<_jsets.size(); s++)
545 int numofjoints = _jsets[s].getNumberofJoints();
549 yError() <<
"embObjMC" << getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
552 int firstjoint = _jsets[s].joints[0];
554 for(
int k=1; k<numofjoints; k++)
556 int otherjoint = _jsets[s].joints[k];
558 if(pidInfo[firstjoint].usernamePidSelected != pidInfo[otherjoint].usernamePidSelected)
560 yError() <<
"embObjMC "<< getBoardInfo() <<
"Joints beloning to same set must be have same control law. Joint " << otherjoint <<
" differs from " << firstjoint <<
"Set num " << s ;
573 bool embObjMotionControl::verifyUserControlLawConsistencyInJointSet(
eomc::TrqPidInfo *pidInfo)
575 for(
size_t s=0; s<_jsets.size(); s++)
577 int numofjoints = _jsets[s].getNumberofJoints();
581 yError() <<
"embObjMC "<< getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
584 int firstjoint = _jsets[s].joints[0];
586 for(
int k=1; k<numofjoints; k++)
588 int otherjoint = _jsets[s].joints[k];
590 if(pidInfo[firstjoint].usernamePidSelected != pidInfo[otherjoint].usernamePidSelected)
592 yError() <<
"embObjMC"<< getBoardInfo() <<
"Joints beloning to same set must be have same control law. Joint " << otherjoint <<
" differs from " << firstjoint <<
"Set num " << s ;
602 bool embObjMotionControl::updatedJointsetsCfgWithControlInfo()
606 for(
size_t s=0; s<_jsets.size(); s++)
608 if(_jsets[s].getNumberofJoints() == 0)
610 yError() <<
"embObjMC"<< getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
614 int joint = _jsets[s].joints[0];
624 _jsets[s].cfg.pid_output_types.postrj_ctrl_out_type = _trj_pids[joint].
out_type;
625 _jsets[s].cfg.pid_output_types.veltrj_ctrl_out_type = _trj_pids[joint].
out_type;
626 _jsets[s].cfg.pid_output_types.mixtrj_ctrl_out_type = _trj_pids[joint].
out_type;
630 _jsets[s].cfg.pid_output_types.posdir_ctrl_out_type = _trj_pids[joint].
out_type;
631 _jsets[s].cfg.pid_output_types.veldir_ctrl_out_type = _trj_pids[joint].
out_type;
633 _jsets[s].cfg.pid_output_types.torque_ctrl_out_type = _trq_pids[joint].
out_type;
635 _jsets[s].cfg.pid_output_types.pwm_ctrl_out_type = eomc_ctrl_out_type_pwm;
637 if (_cur_pids[joint].enabled)
639 _jsets[s].cfg.pid_output_types.cur_ctrl_out_type = eomc_ctrl_out_type_cur;
643 _jsets[s].cfg.pid_output_types.cur_ctrl_out_type = eomc_ctrl_out_type_n_a;
652 bool embObjMotionControl::saveCouplingsData(
void)
654 eOmc_4jomo_coupling_t *jc_dest;
656 static eOmc_4jomo_coupling_t dummyjomocoupling = {};
658 switch(serviceConfig.
ethservice.configuration.type)
660 case eomn_serv_MC_foc:
662 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.foc_based.jomocoupling);
665 case eomn_serv_MC_mc4plus:
667 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc4plus_based.jomocoupling);
670 case eomn_serv_MC_mc4plusmais:
672 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc4plusmais_based.jomocoupling);
676 case eomn_serv_MC_mc2pluspsc:
678 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc2pluspsc.jomocoupling);
682 case eomn_serv_MC_mc4plusfaps:
684 jc_dest = &(serviceConfig.
ethservice.configuration.data.mc.mc4plusfaps.jomocoupling);
688 case eomn_serv_MC_advfoc:
690 jc_dest = &dummyjomocoupling;
693 case eomn_serv_MC_mc4:
698 case eomn_serv_MC_generic:
710 memset(jc_dest, 0,
sizeof(eOmc_4jomo_coupling_t));
714 for(
int i=0; i<4; i++)
716 jc_dest->joint2set[i] = eomc_jointSetNum_none;
719 if(_joint2set.size() > 4 )
721 yError() <<
"embObjMC "<< getBoardInfo() <<
"Jointsset size is bigger than 4. I can't send jointset information to fw.";
725 for(
size_t i=0; i<_joint2set.size(); i++)
727 jc_dest->joint2set[i] = _joint2set[i];
730 for(
int i=0; i<4; i++)
732 for(
int j=0; j<4; j++)
734 jc_dest->joint2motor[i][j] = eo_common_float_to_Q17_14((
float)_couplingInfo.
matrixJ2M[4*i+j]);
735 jc_dest->motor2joint[i][j] = eo_common_float_to_Q17_14((
float)_couplingInfo.
matrixM2J[4*i+j]);
740 for(
int r=0; r<4; r++)
742 for(
int c=0; c<6; c++)
744 jc_dest->encoder2joint[r][c] = eo_common_float_to_Q17_14((
float)_couplingInfo.
matrixE2J[6*r+c]);
748 for(
size_t s=0; s< _jsets.size(); s++)
750 eOmc_jointset_configuration_t* cfg_ptr = _jsets[s].getConfiguration();
751 memcpy(&(jc_dest->jsetcfg[s]), cfg_ptr,
sizeof(eOmc_jointset_configuration_t));
755 if(eomn_serv_MC_advfoc == serviceConfig.
ethservice.configuration.type)
758 eOmc_adv4jomo_coupling_t *ajc = &serviceConfig.
ethservice.configuration.data.mc.advfoc.adv4jomocoupling;
759 ajc->type = eommccoupling_traditional4x4;
761 std::memmove(&ajc->data.coupling4x4.joint2set[0], &jc_dest->joint2set[0], 4*
sizeof(uint8_t));
762 std::memmove(&ajc->data.coupling4x4.jsetcfg[0], &jc_dest->jsetcfg[0], 4*
sizeof(eOmc_jointset_configuration_t));
763 std::memmove(&ajc->data.coupling4x4.joint2motor, &jc_dest->joint2motor,
sizeof(eOmc_4x4_matrix_t));
764 std::memmove(&ajc->data.coupling4x4.motor2joint, &jc_dest->motor2joint,
sizeof(eOmc_4x4_matrix_t));
766 for(uint8_t r=0; r<4; r++)
768 for(uint8_t c=0; c<4; c++)
770 ajc->data.coupling4x4.encoder2joint4x4[r][c] = jc_dest->encoder2joint[r][c];
780 bool embObjMotionControl::fromConfig_Step2(yarp::os::Searchable &config)
787 if(iNeedCouplingsInfo())
813 for (i = 0; i < _njoints; i++)
815 measConvFactors.angleToEncoder[i] = 1;
836 if(eomn_serv_MC_mc4 != (eOmn_serv_type_t)serviceConfig.
ethservice.configuration.type)
838 int* useMotorSpeedFbk = 0;
839 useMotorSpeedFbk =
new int[_njoints];
842 delete[] useMotorSpeedFbk;
847 if (!verifyUseMotorSpeedFbkInJointSet(useMotorSpeedFbk))
849 delete[] useMotorSpeedFbk;
852 delete[] useMotorSpeedFbk;
854 bool deadzoneIsAvailable;
857 if(!deadzoneIsAvailable)
859 updateDeadZoneWithDefaultValues();
871 bool lowLevPidisMandatory =
false;
873 if((serviceConfig.
ethservice.configuration.type == eomn_serv_MC_foc) || (serviceConfig.
ethservice.configuration.type == eomn_serv_MC_advfoc))
875 lowLevPidisMandatory =
true;
878 if(!_mcparser->
parsePids(config, _trj_pids, _trq_pids, _cur_pids, _spd_pids, lowLevPidisMandatory))
895 updatedJointsetsCfgWithControlInfo();
898 for (i = 0; i < _njoints; i++)
900 measConvFactors.newtonsToSensor[i] = 1000000.0f;
902 measConvFactors.bemf2raw[i] = measConvFactors.newtonsToSensor[i] / measConvFactors.angleToEncoder[i];
903 if (_trq_pids->
out_PidUnits == yarp::dev::PidOutputUnitsEnum::DUTYCYCLE_PWM_PERCENT)
905 measConvFactors.ktau2raw[i] = measConvFactors.dutycycleToPWM[i] / measConvFactors.newtonsToSensor[i];
907 else if (_trq_pids->
out_PidUnits == yarp::dev::PidOutputUnitsEnum::RAW_MACHINE_UNITS)
909 measConvFactors.ktau2raw[i] = 1.0 / measConvFactors.newtonsToSensor[i];
913 yError() <<
"Invalid ktau units";
return false;
918 _measureConverter =
new ControlBoardHelper(_njoints, _axisMap, measConvFactors.angleToEncoder, NULL, measConvFactors.newtonsToSensor, measConvFactors.ampsToSensor,
nullptr, measConvFactors.dutycycleToPWM , measConvFactors.bemf2raw, measConvFactors.ktau2raw);
919 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_POSITION, _trj_pids->
fbk_PidUnits, _trj_pids->
out_PidUnits);
921 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_TORQUE, _trq_pids->
fbk_PidUnits, _trq_pids->
out_PidUnits);
922 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, _cur_pids->
fbk_PidUnits, _cur_pids->
out_PidUnits);
923 _measureConverter->set_pid_conversion_units(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, _spd_pids->
fbk_PidUnits, _spd_pids->
out_PidUnits);
936 initializeInterfaces(measConvFactors);
937 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_POSITION, _trj_pids->
fbk_PidUnits, _trj_pids->
out_PidUnits);
939 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_TORQUE, _trq_pids->
fbk_PidUnits, _trq_pids->
out_PidUnits);
940 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, _cur_pids->
fbk_PidUnits, _cur_pids->
out_PidUnits);
941 ImplementPidControl::setConversionUnits(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, _spd_pids->
fbk_PidUnits, _spd_pids->
out_PidUnits);
945 if(!saveCouplingsData())
952 yError() <<
"embObjMC " << getBoardInfo() <<
"IMPEDANCE section: error detected in parameters syntax";
958 for(j=0; j<_njoints; j++)
961 _impedance_limits[j].
min_damp= 0.001;
962 _impedance_limits[j].
max_damp= 9.888;
965 _impedance_limits[j].
param_a= 0.011;
966 _impedance_limits[j].
param_b= 0.012;
967 _impedance_limits[j].
param_c= 0.013;
988 eOmn_serv_type_t servtype =
static_cast<eOmn_serv_type_t
>(serviceConfig.
ethservice.configuration.type);
990 if((eomn_serv_MC_foc == servtype) || (eomn_serv_MC_advfoc == servtype))
992 std::string groupName = {};
994 if(eomn_serv_MC_foc == servtype)
997 eObrd_type_t brd =
static_cast<eObrd_type_t
>(serviceConfig.
ethservice.configuration.data.mc.foc_based.type);
998 groupName = (eobrd_foc == brd) ?
"2FOC" :
"AMCBLDC";
1000 else if(eomn_serv_MC_advfoc == servtype)
1004 groupName =
"ADVFOC";
1007 if(!_mcparser->
parseFocGroup(config, _foc_based_info, groupName, _temperatureSensorsVector))
1010 for (j = 0; j < _njoints; j++)
1012 if (((_temperatureSensorsVector.at(j)->getType() !=
motor_temperature_sensor_none )) && ((_temperatureLimits[j].hardwareTemperatureLimit == 0) || (_temperatureLimits[j].warningTemperatureLimit == 0)))
1014 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...";
1020 yInfo() <<
"embObjMC " << getBoardInfo() <<
"joint " << j <<
" has motor not provided with any available type of temperature sensor. If needed update the configurations file accordingly";
1026 for (j = 0; j < _njoints; j++)
1028 _temperatureSensorsVector.at(j) = std::make_unique<eomc::TemperatureSensorNONE>();
1044 bool embObjMotionControl::verifyUseMotorSpeedFbkInJointSet(
int useMotorSpeedFbk [])
1046 for(
size_t s=0; s< _jsets.size(); s++)
1048 int numofjointsinset = _jsets[s].getNumberofJoints();
1049 if(numofjointsinset == 0 )
1051 yError() <<
"embObjMC " << getBoardInfo() <<
"Jointsset " << s <<
"hasn't joints!!! I should be never stay here!!!";
1055 int firstjointofset = _jsets[s].joints[0];
1056 for(
int j=1; j<numofjointsinset; j++)
1058 int joint = _jsets[s].joints[j];
1059 if(useMotorSpeedFbk[firstjointofset] != useMotorSpeedFbk[joint])
1061 yError() <<
"embObjMC " << getBoardInfo() <<
". Param useMotorSpeedFbk should have same value for joints belong same set. See joint " << firstjointofset <<
" and " << joint;
1066 _jsets[s].setUseSpeedFeedbackFromMotors(useMotorSpeedFbk[firstjointofset]);
1073 bool embObjMotionControl::verifyTorquePidshasSameUnitTypes(yarp::dev::PidFeedbackUnitsEnum &fbk_pidunits, yarp::dev::PidOutputUnitsEnum& out_pidunits)
1075 fbk_pidunits = yarp::dev::PidFeedbackUnitsEnum::RAW_MACHINE_UNITS;
1076 out_pidunits = yarp::dev::PidOutputUnitsEnum::RAW_MACHINE_UNITS;
1078 int firstjoint = -1;
1079 for(
int i=0; i<_njoints; i++)
1081 if(_trq_pids[i].enabled)
1091 for(
int i=firstjoint+1; i<_njoints; i++)
1093 if(_trq_pids[i].enabled)
1095 if(_trq_pids[firstjoint].fbk_PidUnits != _trq_pids[i].fbk_PidUnits ||
1096 _trq_pids[firstjoint].out_PidUnits != _trq_pids[i].out_PidUnits)
1098 yError() <<
"embObjMC " << getBoardInfo() <<
"all joints with torque enabled should have same controlunits type. Joint " << firstjoint <<
" differs from joint " << i;
1109 bool embObjMotionControl::isTorqueControlEnabled(
int joint)
1111 return (_trq_pids[joint].enabled);
1114 bool embObjMotionControl::isVelocityControlEnabled(
int joint)
1117 return (_trj_pids[joint].enabled);
1121 void embObjMotionControl::updateDeadZoneWithDefaultValues(
void)
1123 for(
int i=0; i<_njoints; i++)
1125 switch(_jointEncs[i].
type)
1133 case eomc_enc_aksim2:
1139 case eomc_enc_absanalog:
1142 case eomc_enc_hallmotor:
1143 case eomc_enc_spichainof2:
1144 case eomc_enc_spichainof3:
1154 bool embObjMotionControl::fromConfig_readServiceCfg(yarp::os::Searchable &config)
1157 if(
false == parser->
parseService(config, serviceConfig))
1159 yError() <<
"embObjMC " << getBoardInfo() <<
"cannot parse service" ;
1163 if(eomn_serv_MC_generic == serviceConfig.
ethservice.configuration.type)
1165 yError() <<
"embObjMC " << getBoardInfo() <<
"it is no longer possible use eomn_serv_MC_generic, because firmware cannot configure itself!" ;
1173 for(
int i=0; i<_njoints; i++)
1178 if(NULL == jointEncoder_ptr)
1180 _jointEncs[i].resolution = 1;
1181 _jointEncs[i].type = eomc_enc_none;
1182 _jointEncs[i].tolerance = 0;
1186 _jointEncs[i].resolution = jointEncoder_ptr->
resolution;
1187 _jointEncs[i].type = (eOmc_encoder_t)jointEncoder_ptr->
desc.type;
1188 _jointEncs[i].tolerance = jointEncoder_ptr->
tolerance;
1192 if(NULL == motorEncoder_ptr)
1194 _motorEncs[i].resolution = 1;
1195 _motorEncs[i].type = eomc_enc_none;
1196 _motorEncs[i].tolerance = 0;
1200 _motorEncs[i].resolution = motorEncoder_ptr->
resolution;
1201 _motorEncs[i].type = (eOmc_encoder_t)motorEncoder_ptr->
desc.type;
1202 _motorEncs[i].tolerance = motorEncoder_ptr->
tolerance;
1214 bool embObjMotionControl::fromConfig(yarp::os::Searchable &config)
1217 _njoints = fromConfig_NumOfJoints(config);
1221 yError() <<
"embObjMC"<< getBoardInfo() <<
"fromConfig(): detected _njoints = " << _njoints;
1226 if(!alloc(_njoints))
1228 yError() <<
"embObjMC"<< getBoardInfo() <<
"fromConfig(): alloc() failed for _njoints = " << _njoints;
1236 int currentMCversion =0;
1242 yError() <<
"embObjMC" << getBoardInfo() <<
"------ ATTENTION!!!! Wrong value of <MotioncontrolVersion> parameter !!!! ---------------------------------------------------------------------------------------";
1243 yError() <<
"embObjMC" << getBoardInfo() <<
"------ This means that the configuration files of this device are not compatible with my parser, so I cannot start. ";
1244 yError() <<
"embObjMC" << getBoardInfo() <<
"------ I need version " <<
PARSER_MOTION_CONTROL_VERSION <<
", but in configuration files have version " << currentMCversion <<
".";
1245 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). ";
1246 yError() <<
"embObjMC" << getBoardInfo() <<
"------ If the problem persists contact icub-support@iit.it DO NOT DO IT BY YOURSELF.";
1247 yError() <<
"embObjMC" << getBoardInfo() <<
"----------------------------------------------------------------------------------------------------------------------------------------------------------------";
1253 yTrace() << config.toString().c_str();
1258 if(
false == fromConfig_readServiceCfg(config))
1270 if(
false == fromConfig_Step2(config))
1282 bool embObjMotionControl::init()
1284 eOprotID32_t protid = 0;
1290 for(
int logico=0; logico< _njoints; logico++)
1292 int fisico = _axisMap[logico];
1293 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, fisico, eoprot_tag_mc_joint_cmmnds_controlmode);
1294 eOenum08_t controlMode = eomc_controlmode_cmd_idle;
1298 yError() <<
"embObjMotionControl::init() had an error while setting eomc_controlmode_cmd_idle in "<< getBoardInfo();
1304 SystemClock::delaySystem(0.010);
1311 vector<eOprotID32_t> id32v(0);
1312 for(
int n=0;
n<_njoints;
n++)
1314 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint,
n, eoprot_tag_mc_joint_status_core);
1315 id32v.push_back(protid);
1316 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint,
n, eoprot_tag_mc_joint_status_addinfo_multienc);
1317 id32v.push_back(protid);
1318 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor,
n, eoprot_tag_mc_motor_status);
1319 id32v.push_back(protid);
1322 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
1324 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, 0, eoprot_tag_mc_joint_status_debug);
1325 id32v.push_back(protid);
1326 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, 1, eoprot_tag_mc_joint_status_debug);
1327 id32v.push_back(protid);
1333 yError() <<
"embObjMotionControl::init() fails to add its variables to regulars in "<< getBoardInfo() <<
": cannot proceed any further";
1340 yDebug() <<
"embObjMotionControl::init() added" << id32v.size() <<
"regular rops to "<< getBoardInfo();
1342 for(
unsigned int r=0; r<id32v.size(); r++)
1344 uint32_t id32 = id32v.at(r);
1345 eoprot_ID2information(id32, nvinfo,
sizeof(nvinfo));
1346 yDebug() <<
"\t it added regular rop for" << nvinfo;
1351 SystemClock::delaySystem(0.005);
1358 for(
int logico=0; logico< _njoints; logico++)
1360 int fisico = _axisMap[logico];
1361 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, fisico, eoprot_tag_mc_joint_config);
1363 eOmc_joint_config_t jconfig = {0};
1364 memset(&jconfig, 0,
sizeof(eOmc_joint_config_t));
1366 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_POSITION,_trj_pids[logico].pid, fisico);
1370 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_TORQUE, _trq_pids[logico].pid, fisico);
1374 jconfig.impedance.damping = (eOmeas_damping_t) _measureConverter->impN2S(_impedance_params[logico].damping, fisico);
1375 jconfig.impedance.stiffness = (eOmeas_stiffness_t) _measureConverter->impN2S(_impedance_params[logico].stiffness, fisico);
1376 jconfig.impedance.offset = 0;
1378 _cacheImpedance[logico].stiffness = jconfig.impedance.stiffness;
1379 _cacheImpedance[logico].damping = jconfig.impedance.damping;
1380 _cacheImpedance[logico].offset = jconfig.impedance.offset;
1382 jconfig.userlimits.max = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posMax, fisico));
1383 jconfig.userlimits.min = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posMin, fisico));
1385 jconfig.hardwarelimits.max = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posHwMax, fisico));
1386 jconfig.hardwarelimits.min = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_jointsLimits[logico].posHwMin, fisico));
1389 jconfig.maxvelocityofjoint =
S_32(_measureConverter->posA2E(_jointsLimits[logico].velMax, fisico));
1390 jconfig.velocitysetpointtimeout = (eOmeas_time_t)
U_16(_timeouts[logico].velocity);
1392 jconfig.jntEncoderResolution = _jointEncs[logico].resolution;
1393 jconfig.jntEncoderType = _jointEncs[logico].type;
1394 jconfig.jntEncTolerance = _jointEncs[logico].tolerance;
1396 jconfig.motor_params.bemf_value = _measureConverter->bemf_user2raw(_trq_pids[logico].kbemf, fisico);
1397 jconfig.motor_params.bemf_scale = 0;
1398 jconfig.motor_params.ktau_value = _measureConverter->ktau_user2raw(_trq_pids[logico].ktau, fisico);
1399 jconfig.motor_params.ktau_scale = 0;
1400 jconfig.motor_params.friction.viscous_pos_val = _measureConverter->viscousPos_user2raw(_trq_pids[logico].viscousPos, fisico);
1401 jconfig.motor_params.friction.viscous_neg_val = _measureConverter->viscousNeg_user2raw(_trq_pids[logico].viscousNeg, fisico);
1402 jconfig.motor_params.friction.coulomb_pos_val = _measureConverter->coulombPos_user2raw(_trq_pids[logico].coulombPos, fisico);
1403 jconfig.motor_params.friction.coulomb_neg_val = _measureConverter->coulombNeg_user2raw(_trq_pids[logico].coulombNeg, fisico);
1404 jconfig.motor_params.friction.velocityThres_val = _measureConverter->velocityThres_user2raw(_trq_pids[logico].velocityThres, fisico);
1406 jconfig.gearbox_E2J = _gearbox_E2J[logico];
1408 jconfig.deadzone = _measureConverter->posA2E(_deadzone[logico], fisico);
1410 jconfig.tcfiltertype=_trq_pids[logico].
filterType;
1412 jconfig.kalman_params.enabled = _kalman_params[logico].enabled;
1413 for(
int i=0; i<_kalman_params[logico].x0.size(); i++) jconfig.kalman_params.x0[i] = _kalman_params[logico].x0.at(i);
1414 for(
int i=0; i<_kalman_params[logico].Q.size(); i++) jconfig.kalman_params.Q[i] = _kalman_params[logico].Q.at(i);
1415 jconfig.kalman_params.R = _kalman_params[logico].R;
1416 jconfig.kalman_params.P0 = _kalman_params[logico].P0;
1420 yError() <<
"FATAL: embObjMotionControl::init() had an error while calling setcheckRemoteValue() for joint config fisico #" << fisico <<
"in "<< getBoardInfo();
1427 yDebug() <<
"embObjMotionControl::init() correctly configured joint config fisico #" << fisico <<
"in "<< getBoardInfo();
1438 for(
int logico=0; logico<_njoints; logico++)
1440 int fisico = _axisMap[logico];
1442 protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, fisico, eoprot_tag_mc_motor_config);
1443 eOmc_motor_config_t motor_cfg = {0};
1444 motor_cfg.maxvelocityofmotor = 0;
1445 motor_cfg.currentLimits.nominalCurrent = _currentLimits[logico].nominalCurrent;
1446 motor_cfg.currentLimits.overloadCurrent = _currentLimits[logico].overloadCurrent;
1447 motor_cfg.currentLimits.peakCurrent = _currentLimits[logico].peakCurrent;
1448 motor_cfg.gearbox_M2J = _gearbox_M2J[logico];
1449 motor_cfg.rotorEncoderResolution = _motorEncs[logico].resolution;
1450 motor_cfg.rotEncTolerance = _motorEncs[logico].tolerance;
1451 motor_cfg.hasHallSensor = _foc_based_info[logico].
hasHallSensor;
1453 motor_cfg.hasTempSensor = _foc_based_info[logico].
hasTempSensor;
1456 motor_cfg.verbose = _foc_based_info[logico].
verbose;
1457 motor_cfg.motorPoles = _foc_based_info[logico].
motorPoles;
1459 motor_cfg.rotorEncoderType = _motorEncs[logico].type;
1460 motor_cfg.pwmLimit =_rotorsLimits[logico].pwmMax;
1461 motor_cfg.temperatureLimit = (eOmeas_temperature_t)
S_16(_temperatureSensorsVector.at(logico)->convertTempCelsiusToRaw(_temperatureLimits.at(logico).hardwareTemperatureLimit));
1462 motor_cfg.limitsofrotor.max = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_rotorsLimits[logico].posMax, fisico ));
1463 motor_cfg.limitsofrotor.min = (eOmeas_position_t)
S_32(_measureConverter->posA2E(_rotorsLimits[logico].posMin, fisico ));
1466 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_CURRENT, _cur_pids[logico].pid, fisico);
1469 tmp = _measureConverter->convert_pid_to_machine(yarp::dev::VOCAB_PIDTYPE_VELOCITY, _spd_pids[logico].pid, fisico);
1474 yError() <<
"FATAL: embObjMotionControl::init() had an error while calling setcheckRemoteValue() for motor config fisico #" << fisico <<
"in "<< getBoardInfo();
1481 yDebug() <<
"embObjMotionControl::init() correctly configured motor config fisico #" << fisico <<
"in "<< getBoardInfo();
1495 const char* tag = eoprot_TAG2string(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_addinfo_multienc);
1497 _rawValuesMetadataMap.insert({{tag,
rawValuesKeyMetadata({}, _njoints * eOmc_joint_multienc_maxnum)}});
1498 for (
auto &[k, v] : _rawValuesMetadataMap)
1500 std::string auxstring =
"";
1502 for (
int i = 0; i < _njoints; i++)
1507 v.rawValueNames.insert(v.rawValueNames.end(),
1508 {auxstring+
"_primary_encoder_raw_value",
1509 auxstring+
"_secondary_encoder_raw_value",
1510 auxstring+
"_primary_encoder_diagnostic"}
1516 yTrace() <<
"embObjMotionControl::init(): correctly instantiated for " << getBoardInfo();
1524 yTrace() <<
" embObjMotionControl::close()";
1526 ImplementControlMode::uninitialize();
1527 ImplementEncodersTimed::uninitialize();
1528 ImplementMotorEncoders::uninitialize();
1529 ImplementPositionControl::uninitialize();
1530 ImplementVelocityControl::uninitialize();
1531 ImplementPidControl::uninitialize();
1532 ImplementControlCalibration::uninitialize();
1533 ImplementAmplifierControl::uninitialize();
1534 ImplementImpedanceControl::uninitialize();
1535 ImplementControlLimits::uninitialize();
1536 ImplementTorqueControl::uninitialize();
1537 ImplementPositionDirect::uninitialize();
1538 ImplementInteractionMode::uninitialize();
1539 ImplementRemoteVariables::uninitialize();
1540 ImplementAxisInfo::uninitialize();
1541 ImplementCurrentControl::uninitialize();
1542 ImplementPWMControl::uninitialize();
1543 ImplementJointFault::uninitialize();
1545 if (_measureConverter) {
delete _measureConverter; _measureConverter=0;}
1548 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
1551 for(
size_t i=0; i<mcdiagnostics.
ports.size(); i++)
1553 mcdiagnostics.
ports[i]->close();
1554 delete mcdiagnostics.
ports[i];
1556 mcdiagnostics.
ports.clear();
1558 mcdiagnostics.
config.mode = eomn_serv_diagn_mode_NONE;
1559 mcdiagnostics.
config.par16 = 0;
1562 delete event_downsampler;
1576 void embObjMotionControl::cleanup(
void)
1578 if(ethManager == NULL)
return;
1597 size_t joint = eoprot_ID2index(id32);
1598 eOprotEntity_t ent = eoprot_ID2entity(id32);
1599 eOprotTag_t tag = eoprot_ID2tag(id32);
1613 std::lock_guard<std::mutex> lck(_mutex);
1614 _encodersStamp[joint] = timestamp;
1618 if(eomn_serv_diagn_mode_MC_AMOyarp == mcdiagnostics.
config.mode)
1620 char str[128] =
"boh";
1622 eoprot_ID2information(id32, str,
sizeof(str));
1624 if((eoprot_entity_mc_joint == ent) && (eoprot_tag_mc_joint_status_debug == tag) && (joint < mcdiagnostics.
ports.size()))
1627 eOprotID32_t id32sc = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joint, eoprot_tag_mc_joint_status_core);
1628 eOmc_joint_status_core_t jcore = {};
1632 int32_t *debug32 =
reinterpret_cast<int32_t*
>(rxdata);
1635 Bottle& output = mcdiagnostics.
ports[joint]->prepare();
1638 output.addString(
"[yt, amo, reg, pos]");
1639 output.addFloat64(timestamp);
1640 output.addInt32(debug32[0]);
1641 output.addInt32(debug32[1]);
1642 output.addInt32(jcore.measures.meas_position);
1643 mcdiagnostics.
ports[joint]->write();
1647 if((eoprot_entity_mc_motor == ent) && (eoprot_tag_mc_motor_status == tag))
1652 uint8_t motor = eoprot_ID2index(id32);
1656 eOmc_motor_status_t *mc_motor_status =
reinterpret_cast<eOmc_motor_status_t*
>(rxdata);
1658 if((
double)mc_motor_status->basic.mot_temperature < 0 )
1660 if(! _temperatureSensorErrorWatchdog.at(motor).isStarted())
1662 yError() << getBoardInfo() <<
"At timestamp" << yarp::os::Time::now() <<
"In motor" << motor <<
"cannot read Temperature from I2C. There might be cabling problems, TDB cable might be broken or sensor unreachable";
1663 _temperatureSensorErrorWatchdog.at(motor).start();
1667 _temperatureSensorErrorWatchdog.at(motor).increment();
1668 if( _temperatureSensorErrorWatchdog.at(motor).isExpired())
1670 yError()<< getBoardInfo() <<
"Motor" << motor <<
"failed to read" << _temperatureSensorErrorWatchdog.at(motor).getCount() <<
"temperature readings for" << yarp::os::Time::now() - _temperatureSensorErrorWatchdog.at(motor).getStartTime() <<
"seconds";
1671 _temperatureSensorErrorWatchdog.at(motor).start();
1678 double delta_tmp = 0;
1679 double tmp = _temperatureSensorsVector.at(motor)->convertRawToTempCelsius((
double)mc_motor_status->basic.mot_temperature);
1683 if(!_temperatureSpikesFilter.at(motor).isStarted())
1685 _temperatureSpikesFilter.at(motor).start(
tmp);
1690 delta_tmp = std::abs(
tmp - _temperatureSpikesFilter.at(motor).getPrevTemperature());
1693 if(delta_tmp > _temperatureSpikesFilter.at(motor).getTemperatureThreshold())
1699 _temperatureSpikesFilter.at(motor).updatePrevTemperature(
tmp);
1702 if(
tmp > _temperatureLimits[motor].warningTemperatureLimit)
1704 if(! _temperatureExceededLimitWatchdog.at(motor).isStarted())
1706 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";
1707 _temperatureExceededLimitWatchdog.at(motor).start();
1711 if(_temperatureExceededLimitWatchdog.at(motor).isExpired())
1713 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";
1714 _temperatureExceededLimitWatchdog.at(motor).start();
1716 _temperatureExceededLimitWatchdog.at(motor).increment();
1721 _temperatureExceededLimitWatchdog.at(motor).clear();
1748 case VOCAB_PIDTYPE_POSITION:
1749 helper_setPosPidRaw(j,pid);
1751 case VOCAB_PIDTYPE_VELOCITY:
1753 helper_setSpdPidRaw(j, pid);
1755 case VOCAB_PIDTYPE_TORQUE:
1756 helper_setTrqPidRaw(j, pid);
1758 case VOCAB_PIDTYPE_CURRENT:
1759 helper_setCurPidRaw(j,pid);
1762 yError()<<
"Invalid pidtype:"<<pidtype;
1772 case VOCAB_PIDTYPE_POSITION:
1773 helper_getPosPidRaw(axis,pid);
1775 case VOCAB_PIDTYPE_VELOCITY:
1777 helper_getSpdPidRaw(axis, pid);
1779 case VOCAB_PIDTYPE_TORQUE:
1780 helper_getTrqPidRaw(axis, pid);
1782 case VOCAB_PIDTYPE_CURRENT:
1783 helper_getCurPidRaw(axis,pid);
1786 yError()<<
"Invalid pidtype:"<<pidtype;
1792 bool embObjMotionControl::helper_setPosPidRaw(
int j,
const Pid &pid)
1794 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtrajectory);
1803 yError() <<
"while setting position PIDs for " << getBoardInfo() <<
" joint " << j;
1813 for(
int j=0; j< _njoints; j++)
1828 for(
int j=0, index=0; j< _njoints; j++, index++)
1850 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
1851 eOmc_joint_status_core_t jcore = {0};
1858 case VOCAB_PIDTYPE_POSITION:
1860 if((eomc_controlmode_torque == jcore.modes.controlmodestatus) ||
1861 (eomc_controlmode_openloop == jcore.modes.controlmodestatus) ||
1862 (eomc_controlmode_current == jcore.modes.controlmodestatus))
1865 *err = (double) jcore.ofpid.generic.error1;
1876 case VOCAB_PIDTYPE_TORQUE:
1878 if ((eOmc_interactionmode_compliant == jcore.modes.interactionmodestatus) &&
1879 (eomc_controlmode_position == jcore.modes.controlmodestatus))
1881 *err = (double) jcore.ofpid.complpos.errtrq;
1884 if(eomc_controlmode_torque == jcore.modes.controlmodestatus)
1886 *err = (double) jcore.ofpid.torque.errtrq;
1890 case VOCAB_PIDTYPE_VELOCITY:
1896 case VOCAB_PIDTYPE_CURRENT:
1904 yError()<<
"Invalid pidtype:"<<pidtype;
1914 for(
int j=0; j< _njoints; j++)
1921 bool embObjMotionControl::helper_getPosPidRaw(
int j, Pid *pid)
1923 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtrajectory);
1926 eOmc_PID_t eoPID = {0};
1929 #ifdef NETWORK_PERFORMANCE_BENCHMARK
1930 double start = yarp::os::Time::now();
1933 bool ret = askRemoteValue(protid, &eoPID, size);
1935 #ifdef NETWORK_PERFORMANCE_BENCHMARK
1936 double end = yarp::os::Time::now();
1937 m_responseTimingVerifier.tick(end-start, start);
1950 bool embObjMotionControl::helper_getPosPidsRaw(Pid *pid)
1952 std::vector<eOmc_PID_t> eoPIDList(_njoints);
1953 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_config_pidtrajectory, eoPIDList);
1956 yError() <<
"failed helper_getPosPidsRaw for" << getBoardInfo();
1960 for(
int j=0; j<_njoints; j++)
1974 case VOCAB_PIDTYPE_POSITION:
1975 helper_getPosPidsRaw(pids);
1980 case VOCAB_PIDTYPE_TORQUE:
1981 helper_getTrqPidsRaw(pids);
1983 case VOCAB_PIDTYPE_CURRENT:
1984 helper_getCurPidsRaw(pids);
1986 case VOCAB_PIDTYPE_VELOCITY:
1987 helper_getSpdPidsRaw(pids);
1990 yError()<<
"Invalid pidtype:"<<pidtype;
1998 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
1999 eOmc_joint_status_core_t jcore = {0};
2006 case VOCAB_PIDTYPE_POSITION:
2008 if((eomc_controlmode_torque == jcore.modes.controlmodestatus) ||
2009 (eomc_controlmode_openloop == jcore.modes.controlmodestatus) ||
2010 (eomc_controlmode_current == jcore.modes.controlmodestatus))
2011 { *ref = 0; yError() <<
"Invalid getPidReferenceRaw() request for current control mode";
return true; }
2012 *ref = (double) jcore.ofpid.generic.reference1;
2021 case VOCAB_PIDTYPE_TORQUE:
2027 case VOCAB_PIDTYPE_CURRENT:
2033 case VOCAB_PIDTYPE_VELOCITY:
2042 yError()<<
"Invalid pidtype:"<<pidtype;
2055 for(
int j=0; j< _njoints; j++)
2100 if( (mode != VOCAB_CM_VELOCITY) &&
2101 (mode != VOCAB_CM_MIXED) &&
2102 (mode != VOCAB_CM_IMPEDANCE_VEL) &&
2103 (mode != VOCAB_CM_IDLE))
2107 yError() <<
"velocityMoveRaw: skipping command because " << getBoardInfo() <<
" joint " << j <<
" is not in VOCAB_CM_VELOCITY mode";
2112 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
2114 _ref_command_speeds[j] = sp ;
2116 eOmc_setpoint_t setpoint;
2117 setpoint.type = eomc_setpoint_velocity;
2118 setpoint.to.velocity.value = (eOmeas_velocity_t)
S_32(_ref_command_speeds[j]);
2119 setpoint.to.velocity.withacceleration = (eOmeas_acceleration_t)
S_32(_ref_accs[j]);
2124 yError() <<
"while setting velocity mode";
2133 eOmc_setpoint_t setpoint;
2135 setpoint.type = eomc_setpoint_velocity;
2137 for(
int j=0; j<_njoints; j++)
2152 yTrace() <<
"setCalibrationParametersRaw for " << getBoardInfo() <<
"joint" << j;
2154 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_calibration);
2155 eOmc_calibrator_t calib;
2156 memset(&calib, 0x00,
sizeof(calib));
2157 calib.type = params.type;
2162 case eomc_calibration_type0_hard_stops:
2163 calib.params.type0.pwmlimit = (int16_t)
S_16(params.param1);
2164 calib.params.type0.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2165 calib.params.type0.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2169 case eomc_calibration_type1_abs_sens_analog:
2170 calib.params.type1.position = (int16_t)
S_16(params.param1);
2171 calib.params.type1.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2172 calib.params.type1.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2176 case eomc_calibration_type2_hard_stops_diff:
2177 calib.params.type2.pwmlimit = (int16_t)
S_16(params.param1);
2178 calib.params.type2.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2179 calib.params.type2.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2183 case eomc_calibration_type3_abs_sens_digital:
2184 calib.params.type3.position = (int16_t)
S_16(params.param1);
2185 calib.params.type3.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2186 calib.params.type3.offset = (int32_t)
S_32(params.param3);
2187 calib.params.type3.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2191 case eomc_calibration_type4_abs_and_incremental:
2192 calib.params.type4.position = (int16_t)
S_16(params.param1);
2193 calib.params.type4.velocity = (eOmeas_velocity_t)
S_32(params.param2);
2194 calib.params.type4.maxencoder = (int32_t)
S_32(params.param3);
2195 calib.params.type4.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2199 case eomc_calibration_type5_hard_stops:
2200 calib.params.type5.pwmlimit = (int32_t)
S_32(params.param1);
2201 calib.params.type5.final_pos = (int32_t)
S_32(params.param2);
2202 calib.params.type5.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2206 case eomc_calibration_type6_mais:
2207 calib.params.type6.position = (int32_t)
S_32(params.param1);
2208 calib.params.type6.velocity = (int32_t)
S_32(params.param2);
2209 calib.params.type6.current = (int32_t)
S_32(params.param3);
2210 calib.params.type6.vmin = (int32_t)
S_32(params.param4);
2211 calib.params.type6.vmax = (int32_t)
S_32(params.param5);
2212 calib.params.type6.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2216 case eomc_calibration_type7_hall_sensor:
2217 calib.params.type7.position = (int32_t)
S_32(params.param1);
2218 calib.params.type7.velocity = (int32_t)
S_32(params.param2);
2220 calib.params.type7.vmin = (int32_t)
S_32(params.param4);
2221 calib.params.type7.vmax = (int32_t)
S_32(params.param5);
2222 calib.params.type7.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2226 case eomc_calibration_type8_tripod_internal_hard_stop:
2227 calib.params.type8.pwmlimit = (int32_t)
S_32(params.param1);
2228 calib.params.type8.max_delta = (int32_t)
S_32(params.param2);
2229 calib.params.type8.calibrationZero = (int32_t)
S_32(params.paramZero );
2232 case eomc_calibration_type9_tripod_external_hard_stop:
2233 calib.params.type9.pwmlimit = (int32_t)
S_32(params.param1);
2234 calib.params.type9.max_delta = (int32_t)
S_32(params.param2);
2235 calib.params.type9.calibrationZero = (int32_t)
S_32(params.paramZero );
2238 case eomc_calibration_type10_abs_hard_stop:
2239 calib.params.type10.pwmlimit = (int32_t)
S_32(params.param1);
2240 calib.params.type10.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2243 case eomc_calibration_type11_cer_hands:
2244 calib.params.type11.offset0 = (int32_t)
S_32(params.param1);
2245 calib.params.type11.offset1 = (int32_t)
S_32(params.param2);
2246 calib.params.type11.offset2 = (int32_t)
S_32(params.param3);
2247 calib.params.type11.cable_range = (int32_t)
S_32(params.param4);
2248 calib.params.type11.pwm = (int32_t)
S_32(params.param5);
2252 case eomc_calibration_type12_absolute_sensor:
2253 calib.params.type12.rawValueAtZeroPos = (int32_t)
S_32(params.param1);
2254 calib.params.type12.calibrationDelta = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2257 case eomc_calibration_type13_cer_hands_2:
2258 calib.params.type13.rawValueAtZeroPos0 = (int32_t)
S_32(params.param1);
2259 calib.params.type13.rawValueAtZeroPos1 = (int32_t)
S_32(params.param2);
2260 calib.params.type13.rawValueAtZeroPos2 = (int32_t)
S_32(params.param3);
2261 calib.params.type13.rawValueAtZeroPos3 = (int32_t)
S_32(params.param4);
2264 case eomc_calibration_type14_qenc_hard_stop_and_fap:
2265 calib.params.type14.pwmlimit = (int32_t)
S_32(params.param1);
2266 calib.params.type14.final_pos = (int32_t)
S_32(params.param2);
2267 calib.params.type14.invertdirection = (uint8_t)
U_32(params.param3);
2268 calib.params.type14.rotation = (int32_t)
S_32(params.param4);
2270 if (calib.params.type14.invertdirection != 0 && calib.params.type14.invertdirection != 1)
2272 yError() <<
"Error in param3 of calibartion type 14 for joint " << j <<
"Admitted values are: 0=FALSE and 1=TRUE";
2277 if(!checkCalib14RotationParam(calib.params.type14.rotation))
2279 yError() <<
"Error in param4 of calibartion type 14 for joint " << j <<
"Admitted values are: 0, 32768, 16384, -16384 [0, 180, 90, -90] in iCubDegree";
2282 calib.params.type14.offset = (int32_t)
S_32(params.param5);
2283 calib.params.type14.calibrationZero = (int32_t)
S_32(_measureConverter->posA2E(params.paramZero, j));
2285 yDebug() <<
"***** calib.params.type14.pwmlimit = " <<calib.params.type14.pwmlimit;
2286 yDebug() <<
"***** calib.params.type14.final_pos = " <<calib.params.type14.final_pos;
2287 yDebug() <<
"***** calib.params.type14.invertdirection = " <<calib.params.type14.invertdirection;
2288 yDebug() <<
"***** calib.params.type14.rotation = " <<calib.params.type14.rotation;
2289 yDebug() <<
"***** calib.params.type14.offset = " <<calib.params.type14.offset;
2290 yDebug() <<
"***** calib.params.type14.calibrationZero = " <<calib.params.type14.calibrationZero;
2294 yError() <<
"Calibration type unknown!! (embObjMotionControl)\n";
2301 yError() <<
"while setting velocity mode";
2305 _calibrated[j] =
true;
2310 bool embObjMotionControl::checkCalib14RotationParam(int32_t calib_param4)
2312 eOmc_calib14_ROT_t urotation = eomc_int2calib14_ROT(calib_param4);
2314 if (urotation == eOmc_calib14_ROT_zero ||
2315 urotation == eOmc_calib14_ROT_plus180 ||
2316 urotation == eOmc_calib14_ROT_plus090 ||
2317 urotation == eOmc_calib14_ROT_minus090)
2327 yTrace() <<
"calibrateRaw for" << getBoardInfo() <<
"joint" << j;
2345 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_calibration);
2346 eOmc_calibrator_t calib;
2347 memset(&calib, 0x00,
sizeof(calib));
2353 case eomc_calibration_type0_hard_stops:
2354 calib.params.type0.pwmlimit = (int16_t)
S_16(p1);
2355 calib.params.type0.velocity = (eOmeas_velocity_t)
S_32(p2);
2359 case eomc_calibration_type1_abs_sens_analog:
2360 calib.params.type1.position = (int16_t)
S_16(p1);
2361 calib.params.type1.velocity = (eOmeas_velocity_t)
S_32(p2);
2365 case eomc_calibration_type2_hard_stops_diff:
2366 calib.params.type2.pwmlimit = (int16_t)
S_16(p1);
2367 calib.params.type2.velocity = (eOmeas_velocity_t)
S_32(p2);
2371 case eomc_calibration_type3_abs_sens_digital:
2372 calib.params.type3.position = (int16_t)
S_16(p1);
2373 calib.params.type3.velocity = (eOmeas_velocity_t)
S_32(p2);
2374 calib.params.type3.offset = (int32_t)
S_32(p3);
2378 case eomc_calibration_type4_abs_and_incremental:
2379 calib.params.type4.position = (int16_t)
S_16(p1);
2380 calib.params.type4.velocity = (eOmeas_velocity_t)
S_32(p2);
2381 calib.params.type4.maxencoder = (int32_t)
S_32(p3);
2385 yError () <<
"Calibration type unknown!! (embObjMotionControl)\n";
2392 yError() <<
"while setting velocity mode";
2396 _calibrated[j ] =
true;
2404 bool result =
false;
2405 eOenum08_t temp = 0;
2407 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_core_modes_controlmodestatus);
2408 if(
false == askRemoteValue(id32, &temp, size))
2410 yError () <<
"Failure of askRemoteValue() inside embObjMotionControl::doneRaw(axis=" << axis <<
") for " << getBoardInfo();
2414 eOmc_controlmode_t
type = (eOmc_controlmode_t) temp;
2418 if (eomc_controlmode_idle ==
type)
2422 else if (eomc_controlmode_calib ==
type)
2426 else if (eomc_controlmode_hwFault ==
type)
2428 yError(
"unable to complete calibration: joint %d in 'hw_fault status' inside doneRaw() function", axis);
2431 else if (eomc_controlmode_notConfigured ==
type)
2433 yError(
"unable to complete calibration: joint %d in 'not_configured' status inside doneRaw() function", axis);
2436 else if (eomc_controlmode_unknownError ==
type)
2438 yError(
"unable to complete calibration: joint %d in 'unknownError' status inside doneRaw() function", axis);
2441 else if (eomc_controlmode_configured ==
type)
2443 yError(
"unable to complete calibration: joint %d in 'configured' status inside doneRaw() function", axis);
2468 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.";
2470 _last_position_move_time[j] = yarp::os::Time::now();
2474 if( (mode != VOCAB_CM_POSITION) &&
2475 (mode != VOCAB_CM_MIXED) &&
2476 (mode != VOCAB_CM_IMPEDANCE_POS) &&
2477 (mode != VOCAB_CM_IDLE))
2481 yError() <<
"positionMoveRaw: skipping command because " << getBoardInfo() <<
" joint " << j <<
" is not in VOCAB_CM_POSITION mode";
2486 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
2487 _ref_command_positions[j] = ref;
2489 eOmc_setpoint_t setpoint;
2491 setpoint.type = (eOenum08_t) eomc_setpoint_position;
2492 setpoint.to.position.value = (eOmeas_position_t)
S_32(_ref_command_positions[j]);
2493 setpoint.to.position.withvelocity = (eOmeas_velocity_t)
S_32(_ref_speeds[j]);
2502 for(
int j=0, index=0; j< _njoints; j++, index++)
2522 eObool_t ismotiondone = eobool_false;
2525 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core_modes_ismotiondone);
2526 if(
false == askRemoteValue(id32, &ismotiondone, size))
2528 yError () <<
"Failure of askRemoteValue() inside embObjMotionControl::checkMotionDoneRaw(j=" << j <<
") for " << getBoardInfo();
2533 *flag = ismotiondone;
2540 std::vector <eObool_t> ismotiondoneList(_njoints);
2541 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_core_modes_ismotiondone, ismotiondoneList);
2544 yError () <<
"Failure of askRemoteValues() inside embObjMotionControl::checkMotionDoneRaw for all joints of" << getBoardInfo();
2548 for(
int j=0; j<_njoints; j++)
2550 *flag &= ismotiondoneList[j];
2560 _ref_speeds[index] = sp;
2568 for(
int j=0, index=0; j< _njoints; j++, index++)
2570 _ref_speeds[index] = spds[index];
2582 _ref_accs[j ] = 1e6;
2584 else if (
acc < -1e6)
2586 _ref_accs[j ] = -1e6;
2590 _ref_accs[j ] =
acc;
2600 for(
int j=0, index=0; j< _njoints; j++, index++)
2604 _ref_accs[index] = 1e6;
2606 else if (accs[j] < -1e6)
2608 _ref_accs[index] = -1e6;
2612 _ref_accs[index] = accs[j];
2620 if (j<0 || j>_njoints)
return false;
2621 #if ASK_REFERENCE_TO_FIRMWARE
2622 *spd = _ref_speeds[j];
2625 *spd = _ref_speeds[j];
2632 memcpy(spds, _ref_speeds,
sizeof(
double) * _njoints);
2638 *
acc = _ref_accs[j];
2644 memcpy(accs, _ref_accs,
sizeof(
double) * _njoints);
2650 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_stoptrajectory);
2652 eObool_t stop = eobool_true;
2660 for(
int j=0; j< _njoints; j++)
2675 for(
int j=0; j<n_joint; j++)
2685 for(
int j=0; j<n_joint; j++)
2696 for(
int j=0; j<n_joint; j++)
2698 if(joints[j] >= _njoints)
2700 yError() << getBoardInfo() <<
":checkMotionDoneRaw required for not existing joint ( " << joints[j] <<
")";
2706 std::vector <eObool_t> ismotiondoneList(_njoints);
2707 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_core_modes_ismotiondone, ismotiondoneList);
2710 yError () << getBoardInfo() <<
"Failure of askRemoteValues() inside embObjMotionControl::checkMotionDoneRaw for a group of joint"; getBoardInfo();
2715 bool tot_val =
true;
2716 for(
int j=0; j<n_joint; j++)
2718 tot_val &= ismotiondoneList[joints[j]];
2729 for(
int j=0; j<n_joint; j++)
2739 for(
int j=0; j<n_joint; j++)
2749 for(
int j=0; j<n_joint; j++)
2759 for(
int j=0; j<n_joint; j++)
2769 for(
int j=0; j<n_joint; j++)
2771 ret = ret &&
stopRaw(joints[j]);
2782 eOmc_joint_status_core_t jcore = {0};
2783 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
2787 eOmc_controlmode_t
type = (eOmc_controlmode_t) jcore.modes.controlmodestatus;
2797 for(
int j=0; j< _njoints; j++)
2807 for(
int j=0; j< n_joint; j++)
2822 eOenum08_t controlmodecommand = 0;
2824 if((_mode == VOCAB_CM_TORQUE) && (_trq_pids[j].enabled ==
false))
2826 yError()<<
"Torque control is disabled. Check your configuration parameters";
2832 yError() <<
"SetControlMode: received unknown control mode for " << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
2836 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_controlmode);
2839 yError() <<
"setControlModeRaw failed for " << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
2844 ret = checkRemoteControlModeStatus(j, _mode);
2848 yError() <<
"In embObjMotionControl::setControlModeRaw(j=" << j <<
", mode=" << yarp::os::Vocab32::decode(_mode).c_str() <<
") for " << getBoardInfo() <<
" has failed checkRemoteControlModeStatus()";
2858 eOenum08_t controlmodecommand = 0;
2861 for(
int i=0; i<n_joint; i++)
2863 if ((modes[i] == VOCAB_CM_TORQUE) && (_trq_pids[i].enabled ==
false)) {yError()<<
"Torque control is disabled. Check your configuration parameters";
continue;}
2867 yError() <<
"SetControlModesRaw(): received unknown control mode for " << getBoardInfo() <<
" joint " << joints[i] <<
" mode " << Vocab32::decode(modes[i]);
2872 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joints[i], eoprot_tag_mc_joint_cmmnds_controlmode);
2875 yError() <<
"setControlModesRaw() could not send set<cmmnds_controlmode> for " << getBoardInfo() <<
" joint " << joints[i] <<
" mode " << Vocab32::decode(modes[i]);
2880 bool tmpresult = checkRemoteControlModeStatus(joints[i], modes[i]);
2881 if(
false == tmpresult)
2883 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]);
2886 ret = ret && tmpresult;
2896 eOenum08_t controlmodecommand = 0;
2898 for(
int i=0; i<_njoints; i++)
2901 if ((modes[i] == VOCAB_CM_TORQUE) && (_trq_pids[i].enabled ==
false))
2903 yError()<<
"Torque control is disabled. Check your configuration parameters";
2909 yError() <<
"SetControlMode: received unknown control mode for" << getBoardInfo() <<
" joint " << i <<
" mode " << Vocab32::decode(modes[i]);
2913 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, i, eoprot_tag_mc_joint_cmmnds_controlmode);
2916 yError() <<
"setControlModesRaw failed for " << getBoardInfo() <<
" joint " << i <<
" mode " << Vocab32::decode(modes[i]);
2920 bool tmpresult = checkRemoteControlModeStatus(i, modes[i]);
2921 if(
false == tmpresult)
2923 yError() <<
"setControlModesRaw(int *modes) could not check with checkRemoteControlModeStatus() for" << getBoardInfo() <<
" joint " << i <<
" mode " << Vocab32::decode(modes[i]);
2926 ret = ret && tmpresult;
2959 eOmc_joint_status_core_t core;
2960 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
2966 *value = (double) core.measures.meas_position;
2970 yError() <<
"embObjMotionControl while reading encoder";
2980 for(
int j=0; j< _njoints; j++)
2990 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
2991 eOmc_joint_status_core_t core;
2998 *sp = (double) core.measures.meas_velocity;
3005 for(
int j=0; j< _njoints; j++)
3014 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
3015 eOmc_joint_status_core_t core;
3021 *
acc = (double) core.measures.meas_acceleration;
3028 for(
int j=0; j< _njoints; j++)
3040 std::lock_guard<std::mutex> lck(_mutex);
3041 for(
int i=0; i<_njoints; i++)
3042 stamps[i] = _encodersStamp[i];
3049 std::lock_guard<std::mutex> lck(_mutex);
3050 *stamp = _encodersStamp[j];
3094 eOmc_motor_status_basic_t status;
3095 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
3100 *value = (double) status.mot_position;
3104 yError() <<
"embObjMotionControl while reading motor encoder position";
3114 for(
int j=0; j< _njoints; j++)
3124 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
3125 eOmc_motor_status_basic_t tmpMotorStatus;
3129 *sp = (double) tmpMotorStatus.mot_velocity;
3133 yError() <<
"embObjMotionControl while reading motor encoder speed";
3142 for(
int j=0; j< _njoints; j++)
3151 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
3152 eOmc_motor_status_basic_t tmpMotorStatus;
3156 *
acc = (double) tmpMotorStatus.mot_acceleration;
3160 yError() <<
"embObjMotionControl while reading motor encoder acceleration";
3169 for(
int j=0; j< _njoints; j++)
3179 std::lock_guard<std::mutex> lck(_mutex);
3180 for(
int i=0; i<_njoints; i++)
3181 stamps[i] = _encodersStamp[i];
3188 std::lock_guard<std::mutex> lck(_mutex);
3189 *stamp = _encodersStamp[m];
3208 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_status_basic);
3209 eOmc_motor_status_basic_t tmpMotorStatus;
3212 *value = (double) tmpMotorStatus.mot_current;
3219 for(
int j=0; j< _njoints; j++)
3228 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_currentlimits);
3230 eOmc_current_limits_params_t currentlimits = {0};
3232 if(!askRemoteValue(protid, ¤tlimits, size))
3234 yError() <<
"embObjMotionControl::setMaxCurrentRaw() could not read max current for " << getBoardInfo() <<
"joint " << j;
3239 currentlimits.overloadCurrent = (eOmeas_current_t)
S_16(val);
3247 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_currentlimits);
3249 eOmc_current_limits_params_t currentlimits = {0};
3252 if(!askRemoteValue(protid, ¤tlimits, size))
3254 yError() <<
"embObjMotionControl::getMaxCurrentRaw() could not read max current for " << getBoardInfo() <<
"joint " << j;
3258 *val = (double) currentlimits.overloadCurrent;
3266 (_enabledAmp[j ]) ? *st = 1 : *st = 0;
3273 for(
int j=0; j<_njoints; j++)
3275 sts[j] = _enabledAmp[j];
3281 #ifdef IMPLEMENT_DEBUG_INTERFACE
3286 bool embObjMotionControl::setParameterRaw(
int j,
unsigned int type,
double value) {
return NOT_YET_IMPLEMENTED(
"setParameterRaw"); }
3287 bool embObjMotionControl::getParameterRaw(
int j,
unsigned int type,
double* value) {
return NOT_YET_IMPLEMENTED(
"getParameterRaw"); }
3288 bool embObjMotionControl::getDebugParameterRaw(
int j,
unsigned int index,
double* value) {
return NOT_YET_IMPLEMENTED(
"getDebugParameterRaw"); }
3289 bool embObjMotionControl::setDebugParameterRaw(
int j,
unsigned int index,
double value) {
return NOT_YET_IMPLEMENTED(
"setDebugParameterRaw"); }
3290 bool embObjMotionControl::setDebugReferencePositionRaw(
int j,
double value) {
return NOT_YET_IMPLEMENTED(
"setDebugReferencePositionRaw"); }
3291 bool embObjMotionControl::getDebugReferencePositionRaw(
int j,
double* value) {
return NOT_YET_IMPLEMENTED(
"getDebugReferencePositionRaw");}
3299 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_userlimits);
3301 eOmeas_position_limits_t limits;
3302 limits.max = (eOmeas_position_t)
S_32(
max);
3303 limits.min = (eOmeas_position_t)
S_32(
min);
3310 yError() <<
"while setting position limits for joint" << j <<
" \n";
3317 eOmeas_position_limits_t limits;
3318 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_userlimits);
3321 if(! askRemoteValue(protoid, &limits, size))
3324 *
min = (double)limits.min + SAFETY_THRESHOLD;
3325 *
max = (
double)limits.max - SAFETY_THRESHOLD;
3331 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3333 eOmc_motor_config_t motor_cfg;
3334 if(! askRemoteValue(protoid, &motor_cfg, size))
3338 *gearbox = (double)motor_cfg.gearbox_M2J;
3345 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3347 eOmc_motor_config_t motor_cfg;
3348 if(! askRemoteValue(protoid, &motor_cfg, size))
3350 *rotorMax = (double)( motor_cfg.limitsofrotor.max);
3351 *rotorMin = (double)( motor_cfg.limitsofrotor.min);
3357 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3359 eOmc_joint_config_t joint_cfg;
3360 if(! askRemoteValue(protoid, &joint_cfg, size))
3364 type = (int)joint_cfg.tcfiltertype;
3370 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3372 eOmc_motor_config_t motor_cfg;
3373 if(! askRemoteValue(protoid, &motor_cfg, size))
3377 rotres = (double)motor_cfg.rotorEncoderResolution;
3384 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3386 eOmc_joint_config_t joint_cfg;
3387 if(! askRemoteValue(protoid, &joint_cfg, size))
3391 jntres = (double)joint_cfg.jntEncoderResolution;
3398 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3400 eOmc_joint_config_t joint_cfg;
3401 if(! askRemoteValue(protoid, &joint_cfg, size))
3405 type = (int)joint_cfg.jntEncoderType;
3412 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3414 eOmc_motor_config_t motor_cfg;
3415 if(! askRemoteValue(protoid, &motor_cfg, size))
3419 type = (int)motor_cfg.rotorEncoderType;
3426 yError(
"getKinematicMJRaw not yet implemented");
3452 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3454 eOmc_motor_config_t motor_cfg;
3455 if(! askRemoteValue(protoid, &motor_cfg, size))
3459 ret = (int)motor_cfg.hasTempSensor;
3466 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3468 eOmc_motor_config_t motor_cfg;
3469 if(! askRemoteValue(protoid, &motor_cfg, size))
3473 ret = (int)motor_cfg.hasHallSensor;
3480 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3482 eOmc_motor_config_t motor_cfg;
3483 if(! askRemoteValue(protoid, &motor_cfg, size))
3487 ret = (int)motor_cfg.hasRotorEncoder;
3494 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3496 eOmc_motor_config_t motor_cfg;
3497 if(! askRemoteValue(protoid, &motor_cfg, size))
3501 ret = (int)motor_cfg.hasRotorEncoderIndex;
3508 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3511 eOmc_motor_config_t motor_cfg;
3512 if(! askRemoteValue(protoid, &motor_cfg, size))
3516 poles = (int)motor_cfg.motorPoles;
3523 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
3525 eOmc_motor_config_t motor_cfg;
3526 if(! askRemoteValue(protoid, &motor_cfg, size))
3530 rotorOffset = (double)motor_cfg.rotorIndexOffset;
3537 if (axis >= 0 && axis < _njoints)
3539 name = _axesInfo[axis].name;
3551 if (axis >= 0 && axis < _njoints)
3553 type = _axesInfo[axis].type;
3562 bool embObjMotionControl::getJointDeadZoneRaw(
int j,
double &jntDeadZone)
3564 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config);
3566 eOmc_joint_config_t joint_cfg;
3567 if(! askRemoteValue(protoid, &joint_cfg, size))
3571 jntDeadZone = _measureConverter->posE2A((
double)joint_cfg.deadzone, _axisMap[j]);
3580 if (key ==
"kinematic_mj")
3583 Bottle& ret = val.addList();
3585 eOmn_serv_type_t mc_serv_type = (eOmn_serv_type_t)serviceConfig.
ethservice.configuration.type;
3586 if(iNeedCouplingsInfo())
3588 for (
int r=0; r<_njoints; r++)
3590 for (
int c = 0; c < _njoints; c++)
3594 ret.addFloat64(_couplingInfo.
matrixJ2M[4 * r + c]);
3600 ret.addFloat64(0.0);
3604 else if (key ==
"encoders")
3606 Bottle& r = val.addList();
for (
int i = 0; i < _njoints; i++) { r.addFloat64(_measureConverter->posA2E(1.0, i)); }
3609 else if (key ==
"rotorEncoderResolution")
3614 else if (key ==
"jointEncoderResolution")
3619 else if (key ==
"gearbox_M2J")
3624 else if (key ==
"gearbox_E2J")
3626 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp=0; getGerabox_E2J(i, &
tmp); r.addFloat64(
tmp); }
3629 else if (key ==
"hasHallSensor")
3634 else if (key ==
"hasTempSensor")
3639 else if (key ==
"TemperatureSensorType")
3644 else if (key ==
"hasRotorEncoder")
3649 else if (key ==
"hasRotorEncoderIndex")
3654 else if (key ==
"rotorIndexOffset")
3659 else if (key ==
"motorPoles")
3664 else if (key ==
"pidCurrentKp")
3666 Bottle& r = val.addList();
for (
int i = 0; i < _njoints; i++) { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p); r.addFloat64(
p.kp); }
3669 else if (key ==
"pidCurrentKi")
3671 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p); r.addFloat64(
p.ki); }
3674 else if (key ==
"pidCurrentShift")
3676 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p); r.addFloat64(
p.scale); }
3679 else if (key ==
"pidCurrentOutput")
3681 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); }
3684 else if (key ==
"jointEncoderType")
3686 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++)
3692 yError(
"Invalid jointEncoderType");
3698 else if (key ==
"rotorEncoderType")
3700 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++)
3706 yError(
"Invalid motorEncoderType");
3712 else if (key ==
"coulombThreshold")
3714 val.addString(
"not implemented yet");
3717 else if (key ==
"torqueControlFilterType")
3722 else if (key ==
"torqueControlEnabled")
3725 Bottle& r = val.addList();
3726 for(
int i = 0; i<_njoints; i++)
3728 r.addInt32((
int)_trq_pids[i].enabled );
3732 else if (key ==
"PWMLimit")
3734 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getPWMLimitRaw(i, &
tmp); r.addFloat64(
tmp); }
3737 else if (key ==
"motOverloadCurr")
3739 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getMaxCurrentRaw(i, &
tmp); r.addFloat64(
tmp); }
3742 else if (key ==
"motNominalCurr")
3747 else if (key ==
"motPeakCurr")
3749 Bottle& r = val.addList();
for (
int i = 0; i< _njoints; i++) {
double tmp = 0;
getPeakCurrentRaw(i, &
tmp); r.addFloat64(
tmp); }
3752 else if (key ==
"PowerSuppVoltage")
3757 else if (key ==
"rotorMax")
3760 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getRotorLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp2); }
3763 else if (key ==
"rotorMin")
3766 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getRotorLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp1); }
3769 else if (key ==
"jointMax")
3772 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp2); }
3775 else if (key ==
"jointMin")
3778 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0;
getLimitsRaw(i, &tmp1, &tmp2); r.addFloat64(tmp1); }
3781 else if (key ==
"jointEncTolerance")
3784 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0; getJointEncTolerance(i, &tmp1); r.addFloat64(tmp1); }
3787 else if (key ==
"motorEncTolerance")
3790 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0; getMotorEncTolerance(i, &tmp1); r.addFloat64(tmp1); }
3793 else if (key ==
"jointDeadZone")
3796 Bottle& r = val.addList();
for (
int i = 0; i<_njoints; i++) {
double tmp = 0; getJointDeadZoneRaw(i, tmp1); r.addFloat64(tmp1); }
3799 else if (key ==
"readonly_position_PIDraw")
3801 Bottle& r = val.addList();
3802 for (
int i = 0; i < _njoints; i++)
3804 getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_POSITION, i, &
p);
3806 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);
3811 else if (key ==
"readonly_velocity_PIDraw")
3813 Bottle& r = val.addList();
3814 for (
int i = 0; i < _njoints; i++)
3815 { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, i, &
p);
3817 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);
3822 else if (key ==
"readonly_torque_PIDraw")
3824 Bottle& r = val.addList();
3825 for (
int i = 0; i < _njoints; i++)
3826 { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_TORQUE, i, &
p);
3828 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);
3833 else if (key ==
"readonly_current_PIDraw")
3835 Bottle& r = val.addList();
3836 for (
int i = 0; i < _njoints; i++)
3837 { Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_CURRENT, i, &
p);
3839 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);
3844 else if (key ==
"readonly_llspeed_PIDraw")
3846 Bottle& r = val.addList();
3847 for (
int i = 0; i < _njoints; i++)
3849 Pid
p;
getPidRaw(PidControlTypeEnum::VOCAB_PIDTYPE_VELOCITY, i, &
p);
3851 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);
3856 else if (key ==
"readonly_motor_torque_params_raw")
3858 Bottle& r = val.addList();
3859 for (
int i = 0; i < _njoints; i++)
3861 MotorTorqueParameters params;
3864 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);
3869 yWarning(
"getRemoteVariable(): Unknown variable %s", key.c_str());
3875 string s1 = val.toString();
3876 if (val.size() != _njoints)
3878 yWarning(
"setRemoteVariable(): Protocol error %s", s1.c_str());
3882 if (key ==
"kinematic_mj")
3884 yWarning(
"setRemoteVariable(): Impossible to set kinematic_mj parameter at runtime.");
3897 else if (key ==
"PWMLimit")
3899 for (
int i = 0; i < _njoints; i++)
setPWMLimitRaw(i, val.get(i).asFloat64());
3904 else if (key ==
"jointMax")
3907 for (
int i = 0; i < _njoints; i++)
3914 else if (key ==
"jointMin")
3917 for (
int i = 0; i < _njoints; i++)
3924 yWarning(
"setRemoteVariable(): Unknown variable %s", key.c_str());
3930 listOfKeys->clear();
3931 listOfKeys->addString(
"kinematic_mj");
3932 listOfKeys->addString(
"encoders");
3933 listOfKeys->addString(
"gearbox_M2J");
3934 listOfKeys->addString(
"gearbox_E2J");
3935 listOfKeys->addString(
"hasHallSensor");
3936 listOfKeys->addString(
"hasTempSensor");
3937 listOfKeys->addString(
"TemperatureSensorType");
3938 listOfKeys->addString(
"hasRotorEncoder");
3939 listOfKeys->addString(
"hasRotorEncoderIndex");
3940 listOfKeys->addString(
"rotorIndexOffset");
3941 listOfKeys->addString(
"rotorEncoderResolution");
3942 listOfKeys->addString(
"jointEncoderResolution");
3943 listOfKeys->addString(
"motorPoles");
3944 listOfKeys->addString(
"pidCurrentKp");
3945 listOfKeys->addString(
"pidCurrentKi");
3946 listOfKeys->addString(
"pidCurrentShift");
3947 listOfKeys->addString(
"pidCurrentOutput");
3948 listOfKeys->addString(
"coulombThreshold");
3949 listOfKeys->addString(
"torqueControlFilterType");
3950 listOfKeys->addString(
"jointEncoderType");
3951 listOfKeys->addString(
"rotorEncoderType");
3952 listOfKeys->addString(
"PWMLimit");
3953 listOfKeys->addString(
"motOverloadCurr");
3954 listOfKeys->addString(
"motNominalCurr");
3955 listOfKeys->addString(
"motPeakCurr");
3956 listOfKeys->addString(
"PowerSuppVoltage");
3957 listOfKeys->addString(
"rotorMax");
3958 listOfKeys->addString(
"rotorMin");
3959 listOfKeys->addString(
"jointMax");
3960 listOfKeys->addString(
"jointMin");
3961 listOfKeys->addString(
"jointEncTolerance");
3962 listOfKeys->addString(
"motorEncTolerance");
3963 listOfKeys->addString(
"jointDeadZone");
3964 listOfKeys->addString(
"readonly_position_PIDraw");
3965 listOfKeys->addString(
"readonly_velocity_PIDraw");
3966 listOfKeys->addString(
"readonly_current_PIDraw");
3967 listOfKeys->addString(
"readonly_torque_PIDraw");
3968 listOfKeys->addString(
"readonly_motor_torque_params_raw");
3980 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_config);
3982 eOmc_joint_config_t joint_cfg;
3983 if(! askRemoteValue(protoid, &joint_cfg, size))
3986 *
max = joint_cfg.maxvelocityofjoint;
4002 return VAS_status::VAS_OK;
4014 for(
int j=0; j< _njoints; j++)
4023 int j = _axisMap[userLevel_jointNumber];
4025 eOmeas_torque_t meas_torque = 0;
4026 static double curr_time = Time::now();
4027 static int count_saturation=0;
4029 meas_torque = (eOmeas_torque_t)
S_32(_measureConverter->trqN2S(fTorque, j));
4031 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_inputs_externallymeasuredtorque);
4046 eOmc_joint_status_core_t jstatus;
4047 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
4049 *t = (double) _measureConverter->trqS2N(jstatus.measures.meas_torque, j);
4056 for(
int j=0; j<_njoints; j++)
4074 for(
int j=0; j<_njoints && ret; j++)
4081 eOmc_setpoint_t setpoint;
4082 setpoint.type = (eOenum08_t) eomc_setpoint_torque;
4083 setpoint.to.torque.value = (eOmeas_torque_t)
S_32(t);
4085 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
4092 for(
int j=0; j< n_joint; j++)
4102 for(
int j=0; j<_njoints && ret; j++)
4109 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
4110 eOmc_joint_status_core_t jcore = {0};
4116 yError() <<
"embObjMotionControl::getRefTorqueRaw() could not read pid torque reference pos for " << getBoardInfo() <<
"joint " << j;
4120 if ((eOmc_interactionmode_compliant == jcore.modes.interactionmodestatus) &&
4121 (eomc_controlmode_position == jcore.modes.controlmodestatus))
4123 *t = (double) jcore.ofpid.complpos.reftrq;
4126 if(eomc_controlmode_torque == jcore.modes.controlmodestatus)
4128 *t = (double) jcore.ofpid.torque.reftrq;
4134 bool embObjMotionControl::helper_setTrqPidRaw(
int j,
const Pid &pid)
4142 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtorque);
4146 bool embObjMotionControl::helper_getTrqPidRaw(
int j, Pid *pid)
4148 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_pidtorque);
4152 if(! askRemoteValue(protoid, &eoPID, size))
4161 bool embObjMotionControl::helper_getTrqPidsRaw(Pid *pid)
4163 std::vector<eOmc_PID_t> eoPIDList (_njoints);
4164 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_config_pidtorque, eoPIDList);
4167 for(
int j=0; j< _njoints; j++)
4179 eOmc_impedance_t val;
4184 *stiffness = (double) (val.stiffness);
4185 *damping = (double) (val.damping);
4193 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_impedance);
4195 if(! askRemoteValue(protoid, &imped, size))
4199 _cacheImpedance->damping = imped.damping;
4200 _cacheImpedance->stiffness = imped.stiffness;
4201 _cacheImpedance->offset = imped.offset;
4208 eOmc_impedance_t val;
4216 _cacheImpedance[j].stiffness = (eOmeas_stiffness_t) stiffness;
4217 _cacheImpedance[j].damping = (eOmeas_damping_t) damping;
4219 val.stiffness = _cacheImpedance[j].stiffness;
4220 val.damping = _cacheImpedance[j].damping;
4221 val.offset = _cacheImpedance[j].offset;
4223 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_impedance);
4233 eOmc_impedance_t val;
4239 _cacheImpedance[j].offset = (eOmeas_torque_t)
S_32(
offset);
4240 val.stiffness = _cacheImpedance[j].stiffness;
4241 val.damping = _cacheImpedance[j].damping;
4242 val.offset = _cacheImpedance[j].offset;
4244 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_impedance);
4254 eOmc_impedance_t val;
4265 *min_stiff = _impedance_limits[j].
min_stiff;
4266 *max_stiff = _impedance_limits[j].
max_stiff;
4267 *min_damp = _impedance_limits[j].
min_damp;
4268 *max_damp = _impedance_limits[j].
max_damp;
4274 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_motor_params);
4277 eOmc_motor_params_t eo_params = {0};
4278 if(! askRemoteValue(protoid, &eo_params, size))
4281 params->bemf = eo_params.bemf_value;
4282 params->bemf_scale = eo_params.bemf_scale;
4283 params->ktau = eo_params.ktau_value;
4284 params->ktau_scale = eo_params.ktau_scale;
4285 params->viscousPos = eo_params.friction.viscous_pos_val;
4286 params->viscousNeg = eo_params.friction.viscous_neg_val ;
4287 params->coulombPos = eo_params.friction.coulomb_pos_val;
4288 params->coulombNeg = eo_params.friction.coulomb_neg_val;
4289 params->velocityThres = eo_params.friction.velocityThres_val;
4298 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_motor_params);
4299 eOmc_motor_params_t eo_params = {0};
4303 eo_params.bemf_value = (float) params.bemf;
4304 eo_params.bemf_scale = (uint8_t) params.bemf_scale;
4305 eo_params.ktau_value = (float) params.ktau;
4306 eo_params.ktau_scale = (uint8_t) params.ktau_scale;
4307 eo_params.friction.viscous_pos_val =
static_cast<float32_t
>(params.viscousPos);
4308 eo_params.friction.viscous_neg_val =
static_cast<float32_t
>(params.viscousNeg);
4309 eo_params.friction.coulomb_pos_val =
static_cast<float32_t
>(params.coulombPos);
4310 eo_params.friction.coulomb_neg_val =
static_cast<float32_t
>(params.coulombNeg);
4311 eo_params.friction.velocityThres_val =
static_cast<float32_t
>(params.velocityThres);
4316 yError() <<
"embObjMotionControl::setMotorTorqueParamsRaw() could not send set message for" << getBoardInfo() <<
"joint " << j;
4328 for(
int j=0; j< n_joint; j++)
4362 bool embObjMotionControl::helper_getVelPidRaw(
int j, Pid *pid)
4364 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_config_piddirect);
4367 if(! askRemoteValue(protoid, &eoPID, size))
4377 bool embObjMotionControl::helper_getVelPidsRaw(Pid *pid)
4379 std::vector <eOmc_PID_t> eoPIDList (_njoints);
4380 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_config_piddirect, eoPIDList);
4384 for(
int j=0; j<_njoints; j++)
4399 if (mode != VOCAB_CM_POSITION_DIRECT &&
4400 mode != VOCAB_CM_IDLE)
4404 yError() <<
"setReferenceRaw: skipping command because" << getBoardInfo() <<
" joint " << j <<
" is not in VOCAB_CM_POSITION_DIRECT mode";
4409 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
4410 eOmc_setpoint_t setpoint = {0};
4412 _ref_positions[j] = ref;
4413 setpoint.type = (eOenum08_t) eomc_setpoint_positionraw;
4414 setpoint.to.position.value = (eOmeas_position_t)
S_32(ref);
4415 setpoint.to.position.withvelocity = 0;
4423 for(
int i=0; i<n_joint; i++)
4433 for (
int i = 0; i<_njoints; i++)
4443 if (axis<0 || axis>_njoints)
return false;
4444 #if ASK_REFERENCE_TO_FIRMWARE
4445 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_target);
4450 eOmc_joint_status_target_t target = {0};
4451 if(!askRemoteValue(id32, &target, size))
4453 yError() <<
"embObjMotionControl::getTargetPositionRaw() could not read reference pos for " << getBoardInfo() <<
"joint " << axis;
4457 *ref = (double) target.trgt_position;
4461 *ref = _ref_command_positions[axis];
4469 for (
int i = 0; i<_njoints; i++)
4479 for (
int i = 0; i<nj; i++)
4488 if (axis<0 || axis>_njoints)
return false;
4489 #if ASK_REFERENCE_TO_FIRMWARE
4490 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_target);
4495 eOmc_joint_status_target_t target = {0};
4496 if(!askRemoteValue(id32, &target, size))
4498 yError() <<
"embObjMotionControl::getRefVelocityRaw() could not read reference vel for " << getBoardInfo() <<
"joint " << axis;
4501 *ref = (double) target.trgt_velocity;
4504 *ref = _ref_command_speeds[axis];
4511 #if ASK_REFERENCE_TO_FIRMWARE
4512 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
4513 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
4516 yError() <<
"embObjMotionControl::getRefVelocitiesRaw() could not read reference vel for " << getBoardInfo() ;
4520 for(
int j=0; j<_njoints; j++)
4522 refs[j] = (double) targetList[j].trgt_velocity;
4526 for(
int j=0; j<_njoints; j++)
4528 refs[j] = _ref_command_speeds[j];
4536 std::vector <double> refsList(_njoints);
4540 for (
int i = 0; i<nj; i++)
4542 if(
jnts[i]>= _njoints)
4544 yError() << getBoardInfo() <<
"getRefVelocitiesRaw: joint " <<
jnts[i] <<
"doesn't exist";
4547 refs[i] = refsList[
jnts[i]];
4554 if (axis<0 || axis>_njoints)
return false;
4555 #if ASK_REFERENCE_TO_FIRMWARE
4556 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, axis, eoprot_tag_mc_joint_status_target);
4560 eOmc_joint_status_target_t target = {0};
4561 if(!askRemoteValue(id32, &target, size))
4563 yError() <<
"embObjMotionControl::getRefPositionRaw() could not read reference pos for " << getBoardInfo() <<
"joint " << axis;
4567 *ref = (double) target.trgt_positionraw;
4570 *ref = _ref_positions[axis];
4577 #if ASK_REFERENCE_TO_FIRMWARE
4578 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
4579 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
4582 yError() <<
"embObjMotionControl::getRefPositionRaw() could not read reference pos for " << getBoardInfo();
4586 for(
int j=0; j< _njoints; j++)
4587 refs[j] = (
double) targetList[j].trgt_positionraw;
4590 for(
int j=0; j< _njoints; j++)
4591 refs[j] = _ref_positions[j];
4599 for (
int i = 0; i<nj; i++)
4612 eOenum08_t interactionmodestatus;
4615 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core_modes_interactionmodestatus);
4619 int tmp = (int) *_mode;
4623 *_mode = (yarp::dev::InteractionModeEnum)
tmp;
4642 for(
int j=0; j<_njoints; j++)
4652 eOenum08_t interactionmodecommand = 0;
4657 if (_mode == VOCAB_IM_COMPLIANT && _trq_pids[j].enabled ==
false) {yError()<<
"Torque control is disabled. Check your configuration parameters";
return false;}
4661 yError() <<
"setInteractionModeRaw: received unknown mode for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
4664 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_interactionmode);
4666 if(
false == res->
setRemoteValue(protid, &interactionmodecommand) )
4668 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
4674 eOenum08_t interactionmodestatus = 0;
4676 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_interactionmodestatus);
4677 bool ret = askRemoteValue(id32, &interactionmodestatus, size);
4679 if((
false == ret) || (interactionmodecommand != interactionmodestatus))
4681 yError() <<
"check of embObjMotionControl::setInteractionModeRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(_mode);
4694 eOenum08_t interactionmodecommand = 0;
4696 for(
int j=0; j<n_joints; j++)
4698 if (modes[j] == VOCAB_IM_COMPLIANT && _trq_pids[j].enabled ==
false) {yError()<<
"Torque control is disabled. Check your configuration parameters";
continue;}
4702 yError() <<
"embObjMotionControl::setInteractionModesRaw(): received unknown interactionMode for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]) <<
" " << modes[j];
4706 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_interactionmode);
4707 if(
false == res->
setRemoteValue(protid, &interactionmodecommand) )
4709 yError() <<
"embObjMotionControl::setInteractionModesRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4715 eOenum08_t interactionmodestatus = 0;
4717 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_interactionmodestatus);
4718 bool ret = askRemoteValue(id32, &interactionmodestatus, size);
4720 if((
false == ret) || (interactionmodecommand != interactionmodestatus))
4724 yError() <<
"check of embObjMotionControl::setInteractionModesRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4730 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4731 << Vocab32::decode(modes[j]) <<
" Got " << Vocab32::decode(
tmp);
4733 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4734 << Vocab32::decode(modes[j]) <<
" Got an unknown value!";
4747 eOenum08_t interactionmodecommand = 0;
4749 for(
int j=0; j<_njoints; j++)
4751 if ((modes[j] == VOCAB_IM_COMPLIANT) && (_trq_pids[j].enabled ==
false))
4753 yError()<<
"Torque control is disabled. Check your configuration parameters";
4759 yError() <<
"setInteractionModeRaw: received unknown interactionMode for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4763 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_interactionmode);
4764 if(
false == res->
setRemoteValue(protid, &interactionmodecommand) )
4766 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4772 eOenum08_t interactionmodestatus = 0;
4774 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_interactionmodestatus);
4775 bool ret = askRemoteValue(id32, &interactionmodestatus, size);
4777 if((
false == ret) || (interactionmodecommand != interactionmodestatus))
4781 yError() <<
"check of embObjMotionControl::setInteractionModesRaw() failed for" << getBoardInfo() <<
" joint " << j <<
" mode " << Vocab32::decode(modes[j]);
4787 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4788 << Vocab32::decode(modes[j]) <<
" Got " << Vocab32::decode(
tmp);
4790 yError() <<
"setInteractionModeRaw failed for" << getBoardInfo() <<
" joint " << j <<
" because of interactionMode mismatching \n\tSet " \
4791 << Vocab32::decode(modes[j]) <<
" Got an unknown value!";
4804 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_core);
4805 eOmc_joint_status_core_t jcore = {0};
4812 case VOCAB_PIDTYPE_POSITION:
4813 if((eomc_controlmode_torque == jcore.modes.controlmodestatus) || (eomc_controlmode_current == jcore.modes.controlmodestatus))
4816 *
out = (double) jcore.ofpid.generic.output;
4821 case VOCAB_PIDTYPE_TORQUE:
4822 if ((eomc_controlmode_torque == jcore.modes.controlmodestatus) ||
4823 ((eomc_controlmode_position == jcore.modes.controlmodestatus) && (eOmc_interactionmode_compliant == jcore.modes.interactionmodestatus)))
4824 *
out = jcore.ofpid.generic.output;
4828 case VOCAB_PIDTYPE_CURRENT:
4831 case VOCAB_PIDTYPE_VELOCITY:
4835 yError()<<
"Invalid pidtype:"<<pidtype;
4844 for(
int j=0; j< _njoints; j++)
4864 eOmc_motor_status_basic_t status;
4865 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_status_basic);
4876 yError() << getBoardInfo() <<
"At timestamp" << yarp::os::Time::now() <<
"In motor" << m <<
"embObjMotionControl::getTemperatureRaw failed to complete getLocalValue()";
4885 *val = _temperatureSensorsVector.at(m)->convertRawToTempCelsius((
double)status.mot_temperature);
4894 for(
int j=0; j< _njoints; j++)
4915 *temp= _temperatureLimits[m].warningTemperatureLimit;
4922 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_temperaturelimit);
4923 eOmeas_temperature_t temperatureLimit = (eOmeas_pwm_t)
S_16(temp);
4930 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
4932 eOmc_current_limits_params_t currentlimits = {0};
4934 if(!askRemoteValue(protid, ¤tlimits, size))
4936 yError() <<
"embObjMotionControl::getPeakCurrentRaw() can't read current limits for" << getBoardInfo() <<
" motor " << m;
4940 *val = (double) currentlimits.peakCurrent ;
4946 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
4949 eOmc_current_limits_params_t currentlimits = {0};
4950 if(!askRemoteValue(protid, ¤tlimits, size))
4952 yError() <<
"embObjMotionControl::setPeakCurrentRaw can't read current limits for" << getBoardInfo() <<
" motor " << m ;
4957 currentlimits.peakCurrent = (eOmeas_current_t)
S_16(val);
4963 yError() <<
"embObjMotionControl::setPeakCurrentRaw failed sending new value for" << getBoardInfo() <<
" motor " << m ;
4970 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
4972 eOmc_current_limits_params_t currentlimits = {0};
4974 if(!askRemoteValue(protid, ¤tlimits, size))
4976 yError() <<
"embObjMotionControl::getNominalCurrentRaw() can't read current limits for" << getBoardInfo() <<
" motor " << m;
4980 *val = (double) currentlimits.nominalCurrent ;
4986 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, m, eoprot_tag_mc_motor_config_currentlimits);
4990 eOmc_current_limits_params_t currentlimits = {0};
4991 if(!askRemoteValue(protid, ¤tlimits, size))
4993 yError() <<
"embObjMotionControl::setNominalCurrentRaw can't read current limits for" << getBoardInfo() <<
" motor " << m ;
4998 currentlimits.nominalCurrent = (eOmeas_current_t)
S_16(val);
5004 yError() <<
"embObjMotionControl::setNominalCurrentRaw failed sending new value for" << getBoardInfo() <<
" motor " << m ;
5012 eOmc_motor_status_basic_t status;
5013 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_status_basic);
5018 *val = (double) status.mot_pwm;
5022 yError() <<
"embObjMotionControl::getPWMRaw failed for" << getBoardInfo() <<
" motor " << j ;
5031 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pwmlimit);
5033 eOmeas_pwm_t motorPwmLimit;
5035 bool ret = askRemoteValue(protid, &motorPwmLimit, size);
5038 *val = (double) motorPwmLimit;
5042 yError() <<
"embObjMotionControl::getPWMLimitRaw failed for" << getBoardInfo() <<
" motor " << j ;
5053 yError() <<
"embObjMotionControl::setPWMLimitRaw failed because pwmLimit is negative for" << getBoardInfo() <<
" motor " << j ;
5056 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pwmlimit);
5057 eOmeas_pwm_t motorPwmLimit = (eOmeas_pwm_t)
S_16(val);
5063 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_controller, 0, eoprot_tag_mc_controller_status);
5065 eOmc_controller_status_t controllerStatus;
5067 bool ret = askRemoteValue(protid, &controllerStatus, size);
5070 *val = (double) controllerStatus.supplyVoltage;
5074 yError() <<
"embObjMotionControl::getPowerSupplyVoltageRaw failed for" << getBoardInfo() <<
" motor " << j ;
5081 bool embObjMotionControl::askRemoteValue(eOprotID32_t id32,
void* value, uint16_t& size)
5088 bool embObjMotionControl::askRemoteValues(eOprotEndpoint_t ep, eOprotEntity_t entity, eOprotTag_t tag, std::vector<T>& values)
5090 std::vector<eOprotID32_t> idList;
5091 std::vector<void*> valueList;
5094 for(
int j=0; j<_njoints; j++)
5096 eOprotID32_t protoId = eoprot_ID_get(ep, entity, j, tag);
5097 idList.push_back(protoId);
5098 valueList.push_back((
void*)&values[j]);
5104 yError() <<
"embObjMotionControl::askRemoteValues failed for all joints of" << getBoardInfo();
5113 bool embObjMotionControl::checkRemoteControlModeStatus(
int joint,
int target_mode)
5116 eOenum08_t temp = 0;
5119 eOprotID32_t id32 = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joint, eoprot_tag_mc_joint_status_core_modes_controlmodestatus);
5120 const double timeout = 0.250;
5121 const int maxretries = 25;
5122 const double delaybetweenqueries = 0.010;
5126 double timeofstart = yarp::os::Time::now();
5129 for( attempt = 0; attempt < maxretries; attempt++)
5131 ret = askRemoteValue(id32, &temp, size);
5134 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());
5138 if(current_mode == target_mode)
5143 if((current_mode == VOCAB_CM_IDLE) && (target_mode == VOCAB_CM_FORCE_IDLE))
5148 if(current_mode == VOCAB_CM_HW_FAULT)
5150 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()); }
5155 if((yarp::os::Time::now()-timeofstart) > timeout)
5158 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());
5163 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());
5165 SystemClock::delaySystem(delaybetweenqueries);
5170 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);
5178 bool embObjMotionControl::iNeedCouplingsInfo(
void)
5180 eOmn_serv_type_t mc_serv_type = (eOmn_serv_type_t)serviceConfig.
ethservice.configuration.type;
5181 if( (mc_serv_type == eomn_serv_MC_foc) ||
5182 (mc_serv_type == eomn_serv_MC_mc4plus) ||
5183 (mc_serv_type == eomn_serv_MC_mc4plusmais) ||
5184 (mc_serv_type == eomn_serv_MC_mc2pluspsc) ||
5185 (mc_serv_type == eomn_serv_MC_mc4plusfaps) ||
5186 (mc_serv_type == eomn_serv_MC_advfoc)
5196 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
5198 eOmc_setpoint_t setpoint;
5200 setpoint.type = (eOenum08_t)eomc_setpoint_openloop;
5201 setpoint.to.openloop.value = (eOmeas_pwm_t)
S_16(v);
5209 for (
int j = 0; j<_njoints; j++)
5218 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_target);
5221 eOmc_joint_status_target_t target = { 0 };
5224 if (!askRemoteValue(protoId, &target, size))
5226 yError() <<
"embObjMotionControl::getRefDutyCycleRaw() could not read openloop reference for " << getBoardInfo() <<
"joint " << j;
5230 *v = (double)target.trgt_pwm;
5237 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
5238 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
5241 yError() <<
"embObjMotionControl::getDutyCyclesRaw failed for all joints of" << getBoardInfo();
5244 for (
int j = 0; j<_njoints; j++)
5246 v[j]= targetList[j].trgt_pwm;
5253 eOmc_motor_status_basic_t status;
5254 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_status_basic);
5259 *v = (double)status.mot_pwm;
5263 yError() <<
"embObjMotionControl::getDutyCycleRaw failed for" << getBoardInfo() <<
" motor " << j;
5273 for (
int j = 0; j< _njoints; j++)
5295 for (
int j = 0; j< _njoints; j++)
5305 for (
int j = 0; j<_njoints; j++)
5314 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_cmmnds_setpoint);
5316 eOmc_setpoint_t setpoint;
5318 setpoint.type = (eOenum08_t)eomc_setpoint_current;
5319 setpoint.to.current.value = (eOmeas_pwm_t)
S_16(t);
5327 for (
int j = 0; j<n_joint; j++)
5336 std::vector <eOmc_joint_status_target_t> targetList(_njoints);
5337 bool ret = askRemoteValues(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, eoprot_tag_mc_joint_status_target, targetList);
5340 yError() <<
"embObjMotionControl::getDutyCyclesRaw failed for all joints of" << getBoardInfo();
5343 for (
int j = 0; j<_njoints; j++)
5345 t[j] = targetList[j].trgt_current;
5352 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_target);
5355 eOmc_joint_status_target_t target = { 0 };
5358 if (!askRemoteValue(protoId, &target, size))
5360 yError() <<
"embObjMotionControl::getRefDutyCycleRaw() could not read openloop reference for " << getBoardInfo() <<
"joint " << j;
5364 *t = (double)target.trgt_current;
5369 bool embObjMotionControl::helper_setCurPidRaw(
int j,
const Pid &pid)
5371 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pidcurrent);
5375 if (!_cur_pids[j].enabled)
5377 yError() <<
"eoMc " << getBoardInfo() <<
": it is not possible set current pid for motor " << j <<
", because current pid is not enabled in xml files";
5385 yError() <<
"while setting velocity PIDs for" << getBoardInfo() <<
" joint " << j;
5394 bool embObjMotionControl::helper_setSpdPidRaw(
int j,
const Pid &pid)
5396 eOprotID32_t protoId = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config_pidspeed);
5400 if (!_cur_pids[j].enabled)
5402 yError() <<
"eoMc " << getBoardInfo() <<
": it is not possible set speed pid for motor " << j <<
", because speed pid is not enabled in xml files";
5410 yError() <<
"while setting velocity PIDs for" << getBoardInfo() <<
" joint " << j;
5419 bool embObjMotionControl::helper_getCurPidRaw(
int j, Pid *pid)
5421 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
5423 eOmc_motor_config_t motor_cfg;
5424 if(! askRemoteValue(protoid, &motor_cfg, size))
5428 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg.pidcurrent;
5434 bool embObjMotionControl::helper_getSpdPidRaw(
int j, Pid *pid)
5436 eOprotID32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, j, eoprot_tag_mc_motor_config);
5438 eOmc_motor_config_t motor_cfg;
5439 if (!askRemoteValue(protoid, &motor_cfg, size))
5443 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg.pidspeed;
5449 bool embObjMotionControl::helper_getCurPidsRaw(Pid *pid)
5451 std::vector <eOmc_motor_config_t> motor_cfg_list(_njoints);
5452 bool ret = askRemoteValues<eOmc_motor_config_t>(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, eoprot_tag_mc_motor_config, motor_cfg_list);
5456 for(
int j=0; j<_njoints; j++)
5458 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg_list[j].pidcurrent;
5464 bool embObjMotionControl::helper_getSpdPidsRaw(Pid *pid)
5466 std::vector <eOmc_motor_config_t> motor_cfg_list(_njoints);
5467 bool ret = askRemoteValues<eOmc_motor_config_t>(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, eoprot_tag_mc_motor_config, motor_cfg_list);
5471 for (
int j = 0; j<_njoints; j++)
5473 eOmc_PID_t
tmp = (eOmc_PID_t)motor_cfg_list[j].pidspeed;
5479 bool embObjMotionControl::getJointConfiguration(
int joint, eOmc_joint_config_t *jntCfg_ptr)
5481 uint32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, joint, eoprot_tag_mc_joint_config);
5483 if(!askRemoteValue(protoid, jntCfg_ptr, size))
5491 bool embObjMotionControl::getMotorConfiguration(
int axis, eOmc_motor_config_t *motCfg_ptr)
5493 uint32_t protoid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_motor, axis, eoprot_tag_mc_motor_config);
5495 if(!askRemoteValue(protoid, motCfg_ptr, size))
5504 bool embObjMotionControl::getGerabox_E2J(
int joint,
double *gearbox_E2J_ptr)
5506 eOmc_joint_config_t jntCfg;
5508 if(!getJointConfiguration(joint, &jntCfg))
5513 *gearbox_E2J_ptr = jntCfg.gearbox_E2J;
5517 bool embObjMotionControl::getJointEncTolerance(
int joint,
double *jEncTolerance_ptr)
5519 eOmc_joint_config_t jntCfg;
5521 if(!getJointConfiguration(joint, &jntCfg))
5526 *jEncTolerance_ptr = jntCfg.jntEncTolerance;
5530 bool embObjMotionControl::getMotorEncTolerance(
int axis,
double *mEncTolerance_ptr)
5532 eOmc_motor_config_t motorCfg;
5533 if(!getMotorConfiguration(axis, &motorCfg))
5538 *mEncTolerance_ptr = motorCfg.rotEncTolerance;
5544 eOmc_motor_status_t status;
5546 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol,
5547 eoprot_entity_mc_motor, j,
5548 eoprot_tag_mc_motor_status);
5557 message =
"Could not retrieve the fault state.";
5561 if (status.mc_fault_state == EOERROR_CODE_DUMMY)
5563 fault = EOERROR_CODE_DUMMY;
5564 message =
"No fault detected.";
5569 fault = eoerror_code2value(status.mc_fault_state);
5570 message = eoerror_code2string(status.mc_fault_state);
5575 bool embObjMotionControl::getRawData_core(std::string key, std::vector<std::int32_t> &
data)
5580 for(
int j=0; j< _njoints; j++)
5582 eOmc_joint_status_additionalInfo_t addinfo;
5583 eOprotID32_t protid = eoprot_ID_get(eoprot_endpoint_motioncontrol, eoprot_entity_mc_joint, j, eoprot_tag_mc_joint_status_addinfo_multienc);
5588 for (
int k = 0; k < std::size(addinfo.multienc); k++)
5590 data.push_back((int32_t)addinfo.multienc[k]);
5599 for (
auto it = _rawValuesMetadataMap.begin(); it != _rawValuesMetadataMap.end(); it++)
5601 if(!getRawData_core(it->first, _rawDataAuxVector))
5603 yError() << getBoardInfo() <<
"getRawData failed. Cannot retrieve all raw data from local memory";
5606 map.insert({it->first, _rawDataAuxVector});
5614 if(_rawValuesMetadataMap.find(key) != _rawValuesMetadataMap.end())
5616 getRawData_core(key,
data);
5620 yError() << getBoardInfo() <<
"Request key:" << key <<
"is not available. Cannot retrieve get raw data.";
5629 for (
const auto &
p : _rawValuesMetadataMap)
5631 keys.push_back(
p.first);
5639 return _rawValuesMetadataMap.size();
5644 if (_rawValuesMetadataMap.empty())
5646 yError() << getBoardInfo() <<
"embObjMotionControl Map is empty. Closing...";
5655 if(_rawValuesMetadataMap.find(key) != _rawValuesMetadataMap.end())
5657 meta = _rawValuesMetadataMap[key];
5661 yError() << getBoardInfo() <<
"Requested key" << key <<
"is not available in the map. Closing...";
#define MAX_POSITION_MOVE_INTERVAL
bool parseService(yarp::os::Searchable &config, servConfigMais_t &maisconfig)
servMC_encoder_t * getEncoderAtMotor(int index)
servMC_encoder_t * getEncoderAtJoint(int index)
virtual const Properties & getProperties()=0
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 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 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 getRawDataMap(std::map< std::string, std::vector< std::int32_t >> &map) 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 setNominalCurrentRaw(int m, const double val) override
virtual bool setMotorTorqueParamsRaw(int j, const MotorTorqueParameters params) override
virtual bool setRefCurrentRaw(int j, double t) override
virtual bool setTemperatureLimitRaw(int m, const double temp) override
virtual bool getRemoteVariableRaw(std::string key, yarp::os::Bottle &val) override
virtual bool calibrationDoneRaw(int j) override
virtual bool getEncoderTimedRaw(int j, double *encs, double *stamp) override
virtual bool getMetadataMap(rawValuesKeyMetadataMap &metamap) override
virtual bool getAxisNameRaw(int axis, std::string &name) override
virtual bool setPWMLimitRaw(int j, const double val) override
virtual bool getRefAccelerationRaw(int j, double *acc) override
virtual bool resetPidRaw(const PidControlTypeEnum &pidtype, int j) override
virtual bool getPidRaw(const PidControlTypeEnum &pidtype, int j, Pid *pid) override
virtual bool setPositionRaw(int j, double ref) override
virtual bool getRefSpeedRaw(int j, double *ref) override
virtual bool setPidErrorLimitRaw(const PidControlTypeEnum &pidtype, int j, double limit) override
virtual bool setControlModesRaw(const int n_joint, const int *joints, int *modes) override
bool getRotorEncoderResolutionRaw(int m, double &rotres)
virtual bool setRefDutyCycleRaw(int j, double v) override
virtual bool getImpedanceOffsetRaw(int j, double *offset) override
bool getWholeImpedanceRaw(int j, eOmc_impedance_t &imped)
virtual bool getEncoderSpeedsRaw(double *spds) override
virtual bool setPositionsRaw(const int n_joint, const int *joints, const double *refs) override
virtual bool resetMotorEncodersRaw() override
bool getJointEncoderTypeRaw(int j, int &type)
virtual bool getNumberOfMotorEncodersRaw(int *num) override
virtual bool getPidErrorLimitsRaw(const PidControlTypeEnum &pidtype, double *limits) override
virtual bool setMotorEncoderRaw(int m, const double val) override
virtual bool stopRaw() override
virtual bool getMotorEncoderTimedRaw(int m, double *encs, double *stamp) override
virtual bool setEncoderRaw(int j, double val) override
virtual bool resetEncoderRaw(int j) override
virtual bool setPidRaw(const PidControlTypeEnum &pidtype, int j, const Pid &pid) override
virtual bool getRefAccelerationsRaw(double *accs) override
virtual bool getPidOutputsRaw(const PidControlTypeEnum &pidtype, double *outs) override
virtual bool getRefPositionsRaw(double *refs) override
virtual bool getJointTypeRaw(int axis, yarp::dev::JointTypeEnum &type) override
virtual bool calibrateAxisWithParamsRaw(int axis, unsigned int type, double p1, double p2, double p3) override
virtual bool getNominalCurrentRaw(int m, double *val) override
virtual bool initialised()
virtual bool setRefTorquesRaw(const double *t) override
virtual bool getRefDutyCyclesRaw(double *v) override
virtual bool getCurrentRaw(int j, double *val) override
bool getMotorPolesRaw(int j, int &poles)
virtual bool getCurrentRangeRaw(int j, double *min, double *max) override
virtual bool getRefTorquesRaw(double *t) override
virtual bool setEncodersRaw(const double *vals) override
virtual bool getEncoderRaw(int j, double *v) override
virtual bool getKeys(std::vector< std::string > &keys) override
virtual bool setControlModeRaw(const int j, const int mode) override
virtual bool positionMoveRaw(int j, double ref) override
bool getKinematicMJRaw(int j, double &rotres)
virtual bool setLimitsRaw(int axis, double min, double max) override
virtual bool getEncoderAccelerationRaw(int j, double *spds) override
virtual bool getMotorTorqueParamsRaw(int j, MotorTorqueParameters *params) override
virtual bool getTemperatureRaw(int m, double *val) override
virtual int getNumberOfKeys() override
virtual bool setPidReferencesRaw(const PidControlTypeEnum &pidtype, const double *refs) override
virtual bool getCurrentImpedanceLimitRaw(int j, double *min_stiff, double *max_stiff, double *min_damp, double *max_damp) override
virtual bool getVelLimitsRaw(int axis, double *min, double *max) override
virtual bool getRefTorqueRaw(int j, double *t) override
virtual bool getNumberOfMotorsRaw(int *num) override
virtual bool setRefSpeedRaw(int j, double sp) override
virtual bool getMotorEncoderSpeedsRaw(double *spds) override
virtual bool getMaxCurrentRaw(int j, double *val) override
virtual bool getTemperaturesRaw(double *vals) override
virtual bool getMotorEncoderCountsPerRevolutionRaw(int m, double *v) override
virtual bool getEncoderAccelerationsRaw(double *accs) override
virtual bool getPidsRaw(const PidControlTypeEnum &pidtype, Pid *pids) override
virtual bool getRemoteVariablesListRaw(yarp::os::Bottle *listOfKeys) override
bool getTorqueControlFilterType(int j, int &type)
virtual bool getRefCurrentsRaw(double *t) override
virtual bool getPidErrorRaw(const PidControlTypeEnum &pidtype, int j, double *err) override
virtual bool setImpedanceOffsetRaw(int j, double offset) override
virtual bool getRefDutyCycleRaw(int j, double *v) override
virtual bool getMotorEncodersTimedRaw(double *encs, double *stamps) override
virtual int getVirtualAnalogSensorChannels() override
bool getRotorIndexOffsetRaw(int j, double &rotorOffset)
virtual bool setMotorEncodersRaw(const double *vals) override
virtual bool isPidEnabledRaw(const PidControlTypeEnum &pidtype, int j, bool *enabled) override
virtual bool setRefAccelerationRaw(int j, double acc) override
virtual bool getEncoderSpeedRaw(int j, double *sp) override
virtual bool getMotorEncoderSpeedRaw(int m, double *sp) override
virtual bool getMotorEncoderAccelerationRaw(int m, double *spds) override
virtual bool getAxes(int *ax) override
virtual bool getRefPositionRaw(const int joint, double *ref) override
virtual bool setRefDutyCyclesRaw(const double *v) override
virtual bool getKeyMetadata(std::string key, rawValuesKeyMetadata &meta) override
virtual bool velocityMoveRaw(int j, double sp) override
virtual bool getPeakCurrentRaw(int m, double *val) override
virtual bool getPidErrorsRaw(const PidControlTypeEnum &pidtype, double *errs) override
virtual bool getRefVelocitiesRaw(double *refs) override
virtual bool getTargetPositionsRaw(double *refs) override
bool getHasRotorEncoderIndexRaw(int j, int &ret)
virtual bool getDutyCycleRaw(int j, double *v) override
bool parseJointsetCfgGroup(yarp::os::Searchable &config, std::vector< JointsSet > &jsets, std::vector< int > &jointtoset)
bool parseJointsLimits(yarp::os::Searchable &config, std::vector< jointLimits_t > &jointsLimits)
bool parseAmpsToSensor(yarp::os::Searchable &config, double ampsToSensor[])
bool parseMechanicalsFlags(yarp::os::Searchable &config, int useMotorSpeedFbk[])
bool parseMotioncontrolVersion(yarp::os::Searchable &config, int &version)
bool parseAxisInfo(yarp::os::Searchable &config, int axisMap[], std::vector< axisInfo_t > &axisInfo)
bool parseFocGroup(yarp::os::Searchable &config, focBasedSpecificInfo_t *foc_based_info, std::string groupName, std::vector< std::unique_ptr< eomc::ITemperatureSensor >> &temperatureSensorsVector)
bool parseCouplingInfo(yarp::os::Searchable &config, couplingInfo_t &couplingInfo)
bool parsePids(yarp::os::Searchable &config, PidInfo *ppids, TrqPidInfo *tpids, PidInfo *cpids, PidInfo *spids, bool lowLevPidisMandatory)
bool parseTemperatureLimits(yarp::os::Searchable &config, std::vector< temperatureLimits_t > &temperatureLimits)
bool parseDeadzoneValue(yarp::os::Searchable &config, double deadzone[], bool *found)
bool isVerboseEnabled(yarp::os::Searchable &config)
bool parseTimeoutsGroup(yarp::os::Searchable &config, std::vector< timeouts_t > &timeouts, int defaultVelocityTimeout)
bool parseCurrentLimits(yarp::os::Searchable &config, std::vector< motorCurrentLimits_t > &currLimits)
bool parseEncoderFactor(yarp::os::Searchable &config, double encoderFactor[])
bool parsefullscalePWM(yarp::os::Searchable &config, double dutycycleToPWM[])
bool parseRotorsLimits(yarp::os::Searchable &config, std::vector< rotorLimits_t > &rotorsLimits)
bool parseImpedanceGroup(yarp::os::Searchable &config, std::vector< impedanceParameters_t > &impedance)
bool parseKalmanFilterParams(yarp::os::Searchable &config, std::vector< kalmanFilterParams_t > &kalmanFilterParams)
bool parseGearboxValues(yarp::os::Searchable &config, double gearbox_M2J[], double gearbox_E2J[])
bool parseBehaviourFalgs(yarp::os::Searchable &config, bool &useRawEncoderData, bool &pwmIsLimited)
std::string usernamePidSelected
yarp::dev::PidFeedbackUnitsEnum fbk_PidUnits
eOmc_ctrl_out_type_t out_type
yarp::dev::PidOutputUnitsEnum out_PidUnits
static uint32_t idx[BOARD_NUM]
static bool nv_not_found(void)
static bool NOT_YET_IMPLEMENTED(const char *txt)
#define PARSER_MOTION_CONTROL_VERSION
static bool DEPRECATED(const char *txt)
const double jointWithAKSIM2
const double jointWithAEA3
const double jointWithAMO
const double jointWithAEA
yarp::sig::Vector & map(yarp::sig::Vector &v, double(op)(double))
Performs a unary operator inplace on each element of a vector.
bool EncoderType_eo2iCub(const uint8_t *in, string *out)
int controlModeStatusConvert_embObj2yarp(eOenum08_t embObjMode)
bool interactionModeStatusConvert_embObj2yarp(eOenum08_t embObjMode, int &vocabOut)
bool controlModeCommandConvert_yarp2embObj(int vocabMode, eOenum08_t &embOut)
void copyPid_eo2iCub(eOmc_PID_t *in, Pid *out)
@ motor_temperature_sensor_pt100
@ motor_temperature_sensor_pt1000
@ motor_temperature_sensor_none
void copyPid_iCub2eo(const Pid *in, eOmc_PID_t *out)
bool interactionModeCommandConvert_yarp2embObj(int vocabMode, eOenum08_t &embOut)
std::vector< BufferedPort< Bottle > * > ports
eOmn_serv_diagn_cfg_t config
eOmn_serv_parameter_t ethservice
eOmc_encoder_descriptor_t desc
bool useRawEncoderData
its value depends on environment variable "ETH_VERBOSEWHENOK"
bool pwmIsLimited
if true than do not use calibration data
std::vector< double > matrixM2J
std::vector< double > matrixE2J
std::vector< double > matrixJ2M
bool hasRotorEncoderIndex