11#include <yarp/os/Bottle.h>
21#include <yarp/os/LogStream.h>
25#include "EoProtocol.h"
26#include "EoProtocolMN.h"
27#include "EoProtocolMC.h"
28#include "EoProtocolAS.h"
34using namespace yarp::os;
41inline void loadStrings(std::vector<std::string>& dest,
const yarp::os::Bottle& source)
44 for (
unsigned int i = 1; i < source.size(); ++i)
46 dest.push_back(source.get(i).asString());
77 outType = it->second.enumValue;
78 description = it->second.description;
82 outType = eomc_ctrl_out_type_n_a;
83 description =
"Unknown control output type";
93 : _defaultSettings(
defaults::DefaultsFactory::getInstance().getDefaults())
95 _njoints = numofjoints;
96 _boardname = boardname;
98 _optionalParametersUsed.clear();
109bool Parser::extractGroup(Bottle &input, Bottle &
out,
const std::string &key1,
const std::string &txt,
int size,
bool mandatory)
113 Bottle &tmp=input.findGroup(key1.c_str(), txt.c_str());
116 std::string message = key1 +
" parameter not found for board " + _boardname +
" in bottle " + input.toString();
118 yError () << message.c_str();
126 yError () << key1.c_str() <<
" incorrect number of entries in BOARD " << _boardname;
134bool Parser::areControlPidGroupEqualInJointSet(
const std::vector<std::string> &controlGroup,
const std::vector<int> &joint2set,
const std::string &controlName)
136 if(
static_cast<int>(controlGroup.size()) != _njoints)
138 yError() <<
"embObjMC BOARD " << _boardname <<
"Control group" << controlName.c_str() <<
"has" << controlGroup.size() <<
"entries but" << _njoints <<
"joints are expected. Quitting.";
142 if(
static_cast<int>(joint2set.size()) != _njoints)
144 yError() <<
"embObjMC BOARD " << _boardname <<
"Invalid joint2set size while checking" << controlName.c_str() <<
". Quitting.";
148 std::vector<bool> setNameAssigned(_njoints,
false);
149 std::vector<std::string> setName(_njoints);
151 for(
int j = 0; j < _njoints; ++j)
153 const int setId = joint2set[j];
154 if((setId < 0) || (setId >= _njoints))
156 yError() <<
"embObjMC BOARD " << _boardname <<
"Invalid set id" << setId <<
"for joint" << j <<
"while checking" << controlName.c_str() <<
". Quitting.";
160 if(!setNameAssigned[setId])
162 setNameAssigned[setId] =
true;
163 setName[setId] = controlGroup[j];
167 if(setName[setId] != controlGroup[j])
169 yError() <<
"embObjMC BOARD " << _boardname <<
"Joints belonging to set" << setId
170 <<
"must have the same" << controlName.c_str() <<
"name. Joint" << j
171 <<
"uses" << controlGroup[j].c_str() <<
"while expected" << setName[setId].c_str() <<
". Quitting.";
179inline bool Parser::GetGroupBottle(yarp::os::Searchable& config,
const std::string& controlName, yarp::os::Bottle& outBottle,
bool mandatory)
186 yarp::os::Bottle&
tmp = config.findGroup(controlName.c_str());
192 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable to find" << controlName.c_str() <<
" in config file.";
205bool Parser::readUserNameControlsGroup(yarp::os::Searchable &config)
207 Bottle controlsGroup, xtmp, jointsetcfg;
208 std::vector<JointsSet> jsets(_njoints);
209 std::vector<int> joint2set(_njoints, -1);
211 auto readControlNames = [&](
const std::string ¶mName,
212 const std::string &description,
213 std::vector<std::string> &dest) ->
bool
215 if (!extractGroup(controlsGroup, xtmp, paramName, description, _njoints))
221 return areControlPidGroupEqualInJointSet(dest, joint2set, paramName);
224 if(!GetGroupBottle(config,
"CONTROLS", controlsGroup))
return false;
226 if(GetGroupBottle(config,
"JOINTSET_CFG", jointsetcfg,
false))
230 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable to parse JOINTSET_CFG while checking control groups consistency. Quitting.";
237 std::fill(joint2set.begin(), joint2set.end(), 0);
246 for(
int j = 0; j < _njoints; ++j)
248 if(!isEquals(_userNameControlVelocity[j], _userNameControlPosition[j]))
250 yError() <<
"embObjMC BOARD " << _boardname <<
": velocityControl parameter for joint" << j <<
"(" << _userNameControlVelocity[j].c_str()
251 <<
") must be equal to positionControl parameter (" << _userNameControlPosition[j].c_str() <<
") or set to " <<
ParamValues::NONE_STR
252 <<
" because embedded control uses the same pid parameters for both position and velocity control. Quitting.";
260 for(
int j = 0; j < _njoints; ++j)
262 if(!isEquals(_userNameControlMixed[j], _userNameControlPosition[j]))
264 yError() <<
"embObjMC BOARD " << _boardname <<
": mixedControl parameter for joint" << j <<
"(" << _userNameControlMixed[j].c_str()
265 <<
") must be equal to positionControl parameter (" << _userNameControlPosition[j].c_str() <<
") or set to " <<
ParamValues::NONE_STR
266 <<
" because embedded control uses the same pid parameters for both position and velocity control. Quitting.";
287bool yarp::dev::eomc::Parser::getOutputType(yarp::os::Bottle& pidsGroup, eOmc_ctrl_out_type_t &outType)
289 Value &valOutputType= pidsGroup.find(
"outputType");
290 if( (valOutputType.isNull()) || (!valOutputType.isString()) )
292 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable read outputType parameter. Quitting.";
295 std::string description;
301 bool Parser::readControlLaw(yarp::os::Bottle& pidsGroup, std::string &controlLaw_str)
304 Value &valControlLaw = pidsGroup.find(
"controlLaw");
305 if ((valControlLaw.isNull()) || (!valControlLaw.isString()))
307 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable read control law parameter. Quitting.";
311 controlLaw_str = valControlLaw.toString();
315bool Parser::parsePidUnitsType(yarp::os::Bottle& pidsGroup, eOmc_ctrl_out_type_t outType,
316 yarp::dev::PidFeedbackUnitsEnum &fbk_pidunits,
317 yarp::dev::PidOutputUnitsEnum& out_pidunits)
319 Value &fbkControlUnits = pidsGroup.find(
"fbkControlUnits");
320 Value &outControlUnits = pidsGroup.find(
"outputControlUnits");
321 if(fbkControlUnits.isNull())
323 yError() <<
"embObjMC BOARD " << _boardname <<
" missing fbkControlUnits parameter";
326 if(!fbkControlUnits.isString())
328 yError() <<
"embObjMC BOARD " << _boardname <<
" fbkControlUnits parameter is not a string";
331 if (outControlUnits.isNull())
333 yError() <<
"embObjMC BOARD " << _boardname <<
" missing outputControlUnits parameter";
336 if (!outControlUnits.isString())
338 yError() <<
"embObjMC BOARD " << _boardname <<
" outputControlUnits parameter is not a string";
344 fbk_pidunits = yarp::dev::PidFeedbackUnitsEnum::METRIC;
348 fbk_pidunits = yarp::dev::PidFeedbackUnitsEnum::RAW_MACHINE_UNITS;
352 yError() <<
"embObjMC BOARD " << _boardname <<
" invalid fbkControlUnits value: " << fbkControlUnits.toString().c_str();
356 const std::string outUnitsStr = outControlUnits.toString();
359 out_pidunits = yarp::dev::PidOutputUnitsEnum::RAW_MACHINE_UNITS;
366 case eomc_ctrl_out_type_pwm: out_pidunits = yarp::dev::PidOutputUnitsEnum::DUTYCYCLE_PWM_PERCENT;
break;
367 case eomc_ctrl_out_type_vel_pwm:
368 case eomc_ctrl_out_type_vel_cur:
369 out_pidunits = yarp::dev::PidOutputUnitsEnum::VELOCITY_METRIC;
371 case eomc_ctrl_out_type_cur: out_pidunits = yarp::dev::PidOutputUnitsEnum::CURRENT_METRIC;
break;
373 yError() <<
"embObjMC BOARD " << _boardname
374 <<
" outputControlUnits=metric_units is not supported for outputType " << (int)outType;
380 yError() <<
"embObjMC BOARD " << _boardname <<
" invalid outputControlUnits value: \"" << outUnitsStr
397 if(!readUserNameControlsGroup(config))
400 if(!parseSelectedCurrentPid(config, lowLevPidisMandatory, pids.
cur))
403 if(!parseSelectedPositionControl(config, pids.
trj))
406 if(!parseSelectedVelocityControl(config, pids.
vel))
409 if(!parseSelectedMixedControl(config, pids.
mix))
412 if(!parseSelectedPositionDirectControl(config, pids.
dir_pos))
415 if(!parseSelectedVelocityDirectControl(config, pids.
dir_vel))
418 if(!parseSelectedTorqueControl(config, pids.
trq))
424bool Parser::parseSelectedCurrentPid(yarp::os::Searchable &config,
bool pidisMandatory, std::vector<eomc::PidInfo> &curr_pids)
427 int enabledCurrentPids = 0;
428 for(
int j = 0; j < _njoints; ++j)
432 ++enabledCurrentPids;
436 if((enabledCurrentPids == 0) && pidisMandatory)
438 for (
auto& current_pid : curr_pids)
440 current_pid.enabled =
false;
442 yError() <<
"embObjMC BOARD " << _boardname <<
"CurrentPid is mandatory. It should be different from none for at least one joint.";
446 std::map<std::string, std::vector<eomc::PidInfo>> parsedGroups;
447 std::map<std::string, std::string> groupControlLaw;
448 std::map<std::string, yarp::dev::PidFeedbackUnitsEnum> groupFbkUnits;
449 std::map<std::string, yarp::dev::PidOutputUnitsEnum> groupOutUnits;
451 for(
int j = 0; j < _njoints; ++j)
453 const std::string &groupName = _userNameControlCurrent[j];
459 if(parsedGroups.find(groupName) != parsedGroups.end())
465 if (!GetGroupBottle(config, groupName, bot_ctrl))
return false;
467 std::string strControlLaw;
468 if(!readControlLaw(bot_ctrl, strControlLaw))
return false;
472 yError() <<
"embObjMC BOARD" << _boardname <<
"Unable to use" << strControlLaw <<
"control law for current pid group" << groupName.c_str() <<
". Quitting.";
476 yarp::dev::PidFeedbackUnitsEnum fbk_unitstype;
477 yarp::dev::PidOutputUnitsEnum out_unitstype;
478 if (!parsePidUnitsType(bot_ctrl, eomc_ctrl_out_type_cur, fbk_unitstype, out_unitstype))
return false;
480 std::vector<eomc::PidInfo> parsed(_njoints);
481 if(!parsePidsGroup2FOC(bot_ctrl, parsed))
return false;
483 parsedGroups[groupName] = parsed;
484 groupControlLaw[groupName] = strControlLaw;
485 groupFbkUnits[groupName] = fbk_unitstype;
486 groupOutUnits[groupName] = out_unitstype;
489 for(
int j = 0; j < _njoints; ++j)
491 const std::string &groupName = _userNameControlCurrent[j];
494 curr_pids[j].enabled =
false;
499 curr_pids[j] = parsedGroups[groupName][j];
500 curr_pids[j].enabled =
true;
501 curr_pids[j].fbk_PidUnits = groupFbkUnits[groupName];
502 curr_pids[j].out_PidUnits = groupOutUnits[groupName];
503 curr_pids[j].controlLaw = groupControlLaw[groupName];
504 curr_pids[j].usernamePidSelected = groupName;
505 curr_pids[j].out_type = eomc_ctrl_out_type_cur;
511bool Parser::parseSelectedPositionControl(yarp::os::Searchable &config, std::vector<eomc::PidInfo> &pos_pids)
513 int enabledPositionPids = 0;
514 for(
int j = 0; j < _njoints; ++j)
518 ++enabledPositionPids;
522 if(enabledPositionPids == 0)
524 for (
auto& p_pid : pos_pids) p_pid.enabled =
false;
525 yError() <<
"embObjMC BOARD " << _boardname <<
"position Pid is mandatory. It should be different from none for at least one joint.";
529 std::map<std::string, std::vector<eomc::PidInfo>> parsedGroups;
530 std::map<std::string, std::string> groupControlLaw;
531 std::map<std::string, yarp::dev::PidFeedbackUnitsEnum> groupFbkUnits;
532 std::map<std::string, yarp::dev::PidOutputUnitsEnum> groupOutUnits;
533 std::map<std::string, eOmc_ctrl_out_type_t> groupOutType;
535 for(
int j = 0; j < _njoints; ++j)
537 const std::string &groupName = _userNameControlPosition[j];
543 if(parsedGroups.find(groupName) != parsedGroups.end())
548 Bottle bot_ctrl = config.findGroup(groupName.c_str());
549 if(bot_ctrl.isNull())
551 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable to find position control group " << groupName.c_str() <<
" in config file. Quitting.";
555 std::string strControlLaw;
556 if(!readControlLaw(bot_ctrl, strControlLaw))
return false;
560 yError() <<
"embObjMC BOARD " << _boardname <<
" Unable to use " << strControlLaw <<
" control law for position pid group " << groupName.c_str() <<
". Quitting.";
564 eOmc_ctrl_out_type_t out_type;
565 if(!getOutputType(bot_ctrl, out_type))
return false;
567 yarp::dev::PidFeedbackUnitsEnum fbk_unitstype;
568 yarp::dev::PidOutputUnitsEnum out_unitstype;
569 if (!parsePidUnitsType(bot_ctrl, out_type, fbk_unitstype, out_unitstype))
return false;
571 std::vector<eomc::PidInfo> parsed(_njoints);
572 bool parseOk =
false;
575 case eomc_ctrl_out_type_pwm:
576 case eomc_ctrl_out_type_cur:
577 parseOk = parsePidsGroupRegulationParams(bot_ctrl, parsed);
579 case eomc_ctrl_out_type_vel_pwm:
580 case eomc_ctrl_out_type_vel_cur:
581 parseOk = parsePidsGroupMinimalParams(bot_ctrl, parsed);
584 yError() <<
"embObjMC BOARD " << _boardname <<
"Unsupported output type for position control group " << groupName.c_str() <<
". Quitting.";
589 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable to parse pid values for " << groupName.c_str() <<
". Quitting.";
593 parsedGroups[groupName] = parsed;
594 groupControlLaw[groupName] = strControlLaw;
595 groupFbkUnits[groupName] = fbk_unitstype;
596 groupOutUnits[groupName] = out_unitstype;
597 groupOutType[groupName] = out_type;
600 for(
int j = 0; j < _njoints; ++j)
602 const std::string &groupName = _userNameControlPosition[j];
605 pos_pids[j].enabled =
false;
610 pos_pids[j] = parsedGroups[groupName][j];
611 pos_pids[j].enabled =
true;
612 pos_pids[j].fbk_PidUnits = groupFbkUnits[groupName];
613 pos_pids[j].out_PidUnits = groupOutUnits[groupName];
614 pos_pids[j].controlLaw = groupControlLaw[groupName];
615 pos_pids[j].usernamePidSelected = groupName;
616 pos_pids[j].out_type = groupOutType[groupName];
622bool Parser::parseSelectedVelocityControl(yarp::os::Searchable &config, std::vector<eomc::PidInfo> &vel_pids)
624 int enabledVelocityPids = 0;
625 for(
int j = 0; j < _njoints; ++j)
629 ++enabledVelocityPids;
633 if(enabledVelocityPids == 0)
635 for (
auto& v_pid : vel_pids)
637 v_pid.enabled =
false;
641 yWarning() <<
"embObjMC BOARD " << _boardname <<
"Velocity pid has been desabled";
645 std::map<std::string, std::vector<eomc::PidInfo>> parsedGroups;
646 std::map<std::string, std::string> groupControlLaw;
647 std::map<std::string, yarp::dev::PidFeedbackUnitsEnum> groupFbkUnits;
648 std::map<std::string, yarp::dev::PidOutputUnitsEnum> groupOutUnits;
649 std::map<std::string, eOmc_ctrl_out_type_t> groupOutType;
651 for(
int j = 0; j < _njoints; ++j)
653 const std::string &groupName = _userNameControlVelocity[j];
659 if(parsedGroups.find(groupName) != parsedGroups.end())
665 if (!GetGroupBottle(config, groupName, bot_ctrl))
return false;
667 std::string strControlLaw;
668 if(!readControlLaw(bot_ctrl, strControlLaw))
return false;
672 yError() <<
"embObjMC BOARD " << _boardname <<
" Unable to use " << strControlLaw <<
" control law for velocity pid group " << groupName.c_str() <<
". Quitting.";
676 eOmc_ctrl_out_type_t out_type;
677 if(!getOutputType(bot_ctrl, out_type))
return false;
679 yarp::dev::PidFeedbackUnitsEnum fbk_unitstype;
680 yarp::dev::PidOutputUnitsEnum out_unitstype;
681 if (!parsePidUnitsType(bot_ctrl, out_type, fbk_unitstype, out_unitstype))
return false;
683 std::vector<eomc::PidInfo> parsed(_njoints);
684 bool parseOk =
false;
687 case eomc_ctrl_out_type_pwm:
688 case eomc_ctrl_out_type_cur:
689 parseOk = parsePidsGroupRegulationParams(bot_ctrl, parsed);
691 case eomc_ctrl_out_type_vel_pwm:
692 case eomc_ctrl_out_type_vel_cur:
693 parseOk = parsePidsGroupMinimalParams(bot_ctrl, parsed);
696 yError() <<
"embObjMC BOARD " << _boardname <<
"Unsupported output type for position control group " << groupName.c_str() <<
". Quitting.";
701 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable to parse pid values for " << groupName.c_str() <<
". Quitting.";
705 parsedGroups[groupName] = parsed;
706 groupControlLaw[groupName] = strControlLaw;
707 groupFbkUnits[groupName] = fbk_unitstype;
708 groupOutUnits[groupName] = out_unitstype;
709 groupOutType[groupName] = out_type;
712 for(
int j = 0; j < _njoints; ++j)
714 const std::string &groupName = _userNameControlVelocity[j];
717 vel_pids[j].enabled =
false;
722 vel_pids[j] = parsedGroups[groupName][j];
723 vel_pids[j].enabled =
true;
724 vel_pids[j].fbk_PidUnits = groupFbkUnits[groupName];
725 vel_pids[j].out_PidUnits = groupOutUnits[groupName];
726 vel_pids[j].controlLaw = groupControlLaw[groupName];
727 vel_pids[j].usernamePidSelected = groupName;
728 vel_pids[j].out_type = groupOutType[groupName];
735bool Parser::parseSelectedMixedControl(yarp::os::Searchable &config, std::vector<eomc::PidInfo> &mix_pids)
737 int enabledMixedPids = 0;
738 for(
int j = 0; j < _njoints; ++j)
746 if(enabledMixedPids == 0)
748 for (
auto& m_pid : mix_pids)
750 m_pid.enabled =
false;
754 yInfo() <<
"embObjMC BOARD " << _boardname <<
"Mixed pid has been desabled";
758 for(
int j = 0; j < _njoints; ++j)
760 if(!isEquals(_userNameControlMixed[j], _userNameControlPosition[j]))
762 yError() <<
"embObjMC BOARD " << _boardname <<
"Mixed control law has a different name than position control law for joint" << j <<
". Currently fw doesn't support different pid values for mixed control from position control, so the control law name should be the same. Quitting.";
767 std::map<std::string, std::vector<eomc::PidInfo>> parsedGroups;
768 std::map<std::string, std::string> groupControlLaw;
769 std::map<std::string, yarp::dev::PidFeedbackUnitsEnum> groupFbkUnits;
770 std::map<std::string, yarp::dev::PidOutputUnitsEnum> groupOutUnits;
771 std::map<std::string, eOmc_ctrl_out_type_t> groupOutType;
773 for(
int j = 0; j < _njoints; ++j)
775 const std::string &groupName = _userNameControlMixed[j];
781 if(parsedGroups.find(groupName) != parsedGroups.end())
787 if (!GetGroupBottle(config, groupName, bot_ctrl))
return false;
789 std::string strControlLaw;
790 if(!readControlLaw(bot_ctrl, strControlLaw))
return false;
794 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable to use " << strControlLaw <<
" control law for mixed pid group " << groupName.c_str() <<
". Quitting.";
798 eOmc_ctrl_out_type_t out_type;
799 if(!getOutputType(bot_ctrl, out_type))
return false;
801 yarp::dev::PidFeedbackUnitsEnum fbk_unitstype;
802 yarp::dev::PidOutputUnitsEnum out_unitstype;
803 if (!parsePidUnitsType(bot_ctrl, out_type, fbk_unitstype, out_unitstype))
return false;
805 std::vector<eomc::PidInfo> parsed(_njoints);
806 bool parseOk =
false;
809 case eomc_ctrl_out_type_pwm:
810 case eomc_ctrl_out_type_cur:
811 parseOk = parsePidsGroupRegulationParams(bot_ctrl, parsed);
813 case eomc_ctrl_out_type_vel_pwm:
814 case eomc_ctrl_out_type_vel_cur :
815 parseOk = parsePidsGroupMinimalParams(bot_ctrl, parsed);
818 yError() <<
"embObjMC BOARD " << _boardname <<
"Unsupported output type for position control group " << groupName.c_str() <<
". Quitting.";
823 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable to parse pid values for " << groupName.c_str() <<
". Quitting.";
827 parsedGroups[groupName] = parsed;
828 groupControlLaw[groupName] = strControlLaw;
829 groupFbkUnits[groupName] = fbk_unitstype;
830 groupOutUnits[groupName] = out_unitstype;
831 groupOutType[groupName] = out_type;
834 for(
int j = 0; j < _njoints; ++j)
836 const std::string &groupName = _userNameControlMixed[j];
839 mix_pids[j].enabled =
false;
844 mix_pids[j] = parsedGroups[groupName][j];
845 mix_pids[j].enabled =
true;
846 mix_pids[j].fbk_PidUnits = groupFbkUnits[groupName];
847 mix_pids[j].out_PidUnits = groupOutUnits[groupName];
848 mix_pids[j].controlLaw = groupControlLaw[groupName];
849 mix_pids[j].usernamePidSelected = groupName;
850 mix_pids[j].out_type = groupOutType[groupName];
857bool Parser::parseSelectedPositionDirectControl(yarp::os::Searchable &config, std::vector<eomc::PidInfo> &posdir_pids)
859 int enabledPosDirectPids = 0;
860 for(
int j = 0; j < _njoints; ++j)
864 ++enabledPosDirectPids;
868 if(enabledPosDirectPids == 0)
870 for (
auto& pd_pid : posdir_pids)
872 pd_pid.enabled =
false;
881 std::map<std::string, std::vector<eomc::PidInfo>> parsedGroups;
882 std::map<std::string, std::string> groupControlLaw;
883 std::map<std::string, yarp::dev::PidFeedbackUnitsEnum> groupFbkUnits;
884 std::map<std::string, yarp::dev::PidOutputUnitsEnum> groupOutUnits;
885 std::map<std::string, eOmc_ctrl_out_type_t> groupOutType;
887 for(
int j = 0; j < _njoints; ++j)
889 const std::string &groupName = _userNameControlPositionDirect[j];
895 if(parsedGroups.find(groupName) != parsedGroups.end())
901 if (!GetGroupBottle(config, groupName, bot_ctrl))
return false;
903 std::string strControlLaw;
904 if(!readControlLaw(bot_ctrl, strControlLaw))
return false;
908 yError() <<
"embObjMC BOARD " << _boardname <<
" Unable to use " << strControlLaw <<
" control law for position direct pid group " << groupName.c_str() <<
". Quitting.";
912 eOmc_ctrl_out_type_t out_type;
913 if(!getOutputType(bot_ctrl, out_type))
return false;
915 yarp::dev::PidFeedbackUnitsEnum fbk_unitstype;
916 yarp::dev::PidOutputUnitsEnum out_unitstype;
917 if (!parsePidUnitsType(bot_ctrl, out_type, fbk_unitstype, out_unitstype))
return false;
919 std::vector<eomc::PidInfo> parsed(_njoints);
920 bool parseOk =
false;
923 case eomc_ctrl_out_type_pwm:
924 case eomc_ctrl_out_type_cur:
925 parseOk = parsePidsGroupRegulationParams(bot_ctrl, parsed);
927 case eomc_ctrl_out_type_vel_pwm:
928 case eomc_ctrl_out_type_vel_cur:
929 parseOk = parsePidsGroupMinimalParams(bot_ctrl, parsed);
932 yError() <<
"embObjMC BOARD " << _boardname <<
"Unsupported output type for position control group " << groupName.c_str() <<
". Quitting.";
937 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable to parse pid values for " << groupName.c_str() <<
". Quitting.";
941 parsedGroups[groupName] = parsed;
942 groupControlLaw[groupName] = strControlLaw;
943 groupFbkUnits[groupName] = fbk_unitstype;
944 groupOutUnits[groupName] = out_unitstype;
945 groupOutType[groupName] = out_type;
948 for(
int j = 0; j < _njoints; ++j)
950 const std::string &groupName = _userNameControlPositionDirect[j];
953 posdir_pids[j].enabled =
false;
958 posdir_pids[j] = parsedGroups[groupName][j];
959 posdir_pids[j].enabled =
true;
960 posdir_pids[j].fbk_PidUnits = groupFbkUnits[groupName];
961 posdir_pids[j].out_PidUnits = groupOutUnits[groupName];
962 posdir_pids[j].controlLaw = groupControlLaw[groupName];
963 posdir_pids[j].usernamePidSelected = groupName;
964 posdir_pids[j].out_type = groupOutType[groupName];
970bool Parser::parseSelectedVelocityDirectControl(yarp::os::Searchable &config, std::vector<eomc::PidInfo> &veldir_pids)
972 int enabledVelDirectPids = 0;
973 for(
int j = 0; j < _njoints; ++j)
977 ++enabledVelDirectPids;
981 if(enabledVelDirectPids == 0)
983 for (
auto& vd_pid : veldir_pids)
985 vd_pid.enabled =
false;
993 std::map<std::string, std::vector<eomc::PidInfo>> parsedGroups;
994 std::map<std::string, std::string> groupControlLaw;
995 std::map<std::string, yarp::dev::PidFeedbackUnitsEnum> groupFbkUnits;
996 std::map<std::string, yarp::dev::PidOutputUnitsEnum> groupOutUnits;
997 std::map<std::string, eOmc_ctrl_out_type_t> groupOutType;
999 for(
int j = 0; j < _njoints; ++j)
1001 const std::string &groupName = _userNameControlVelocityDirect[j];
1007 if(parsedGroups.find(groupName) != parsedGroups.end())
1013 if (!GetGroupBottle(config, groupName, bot_ctrl))
return false;
1015 std::string strControlLaw;
1016 if(!readControlLaw(bot_ctrl, strControlLaw))
return false;
1020 yError() <<
"embObjMC BOARD " << _boardname <<
" Unable to use " << strControlLaw <<
" control law for velocity direct pid group " << groupName.c_str() <<
". Quitting.";
1024 eOmc_ctrl_out_type_t out_type;
1025 if(!getOutputType(bot_ctrl, out_type))
return false;
1027 yarp::dev::PidFeedbackUnitsEnum fbk_unitstype;
1028 yarp::dev::PidOutputUnitsEnum out_unitstype;
1029 if (!parsePidUnitsType(bot_ctrl, out_type, fbk_unitstype, out_unitstype))
return false;
1032 if (out_type == eomc_ctrl_out_type_pwm)
1034 out_type = eomc_ctrl_out_type_vel_pwm;
1036 else if (out_type == eomc_ctrl_out_type_cur)
1038 out_type = eomc_ctrl_out_type_vel_cur;
1041 std::vector<eomc::PidInfo> parsed(_njoints);
1042 if(!parsePidsGroup2FOC(bot_ctrl, parsed))
1044 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable to parse pid values for " << groupName.c_str() <<
". Quitting.";
1048 parsedGroups[groupName] = parsed;
1049 groupControlLaw[groupName] = strControlLaw;
1050 groupFbkUnits[groupName] = fbk_unitstype;
1051 groupOutUnits[groupName] = out_unitstype;
1052 groupOutType[groupName] = out_type;
1055 for(
int j = 0; j < _njoints; ++j)
1057 const std::string &groupName = _userNameControlVelocityDirect[j];
1060 veldir_pids[j].enabled =
false;
1065 veldir_pids[j] = parsedGroups[groupName][j];
1066 veldir_pids[j].enabled =
true;
1067 veldir_pids[j].fbk_PidUnits = groupFbkUnits[groupName];
1068 veldir_pids[j].out_PidUnits = groupOutUnits[groupName];
1069 veldir_pids[j].controlLaw = groupControlLaw[groupName];
1070 veldir_pids[j].usernamePidSelected = groupName;
1071 veldir_pids[j].out_type = groupOutType[groupName];
1077bool Parser::parseSelectedTorqueControl(yarp::os::Searchable &config, std::vector<eomc::TrqPidInfo> &trq_pids)
1079 int enabledTorquePids = 0;
1080 for(
int j = 0; j < _njoints; ++j)
1084 ++enabledTorquePids;
1088 if(enabledTorquePids == 0)
1090 for (
auto& t_pid : trq_pids)
1092 t_pid.enabled =
false;
1098 std::map<std::string, std::vector<eomc::TrqPidInfo>> parsedGroups;
1099 std::map<std::string, std::string> groupControlLaw;
1100 std::map<std::string, yarp::dev::PidFeedbackUnitsEnum> groupFbkUnits;
1101 std::map<std::string, yarp::dev::PidOutputUnitsEnum> groupOutUnits;
1102 std::map<std::string, eOmc_ctrl_out_type_t> groupOutType;
1104 for(
int j = 0; j < _njoints; ++j)
1106 const std::string &groupName = _userNameControlTorque[j];
1112 if(parsedGroups.find(groupName) != parsedGroups.end())
1118 if (!GetGroupBottle(config, groupName, bot_ctrl))
return false;
1120 std::string strControlLaw;
1121 if(!readControlLaw(bot_ctrl, strControlLaw))
return false;
1125 yError() <<
"embObjMC BOARD " << _boardname <<
" Unable to use " << strControlLaw <<
" control law for torque pid group " << groupName.c_str() <<
". Quitting.";
1129 eOmc_ctrl_out_type_t out_type;
1130 if(!getOutputType(bot_ctrl, out_type))
return false;
1132 yarp::dev::PidFeedbackUnitsEnum fbk_unitstype;
1133 yarp::dev::PidOutputUnitsEnum out_unitstype;
1134 if (!parsePidUnitsType(bot_ctrl, out_type, fbk_unitstype, out_unitstype))
return false;
1136 std::vector<eomc::TrqPidInfo> parsed(_njoints);
1137 bool parseOk =
false;
1140 case eomc_ctrl_out_type_pwm:
1141 case eomc_ctrl_out_type_cur:
1142 parseOk = parsePidsGroupTorqueCompensationParams(bot_ctrl, parsed);
1144 case eomc_ctrl_out_type_vel_cur:
1145 case eomc_ctrl_out_type_vel_pwm:
1146 parseOk = parsePidsGroupRegulationParams(bot_ctrl, parsed);
1149 yError() <<
"embObjMC BOARD " << _boardname <<
"Unsupported output type for position control group " << groupName.c_str() <<
". Quitting.";
1154 yError() <<
"embObjMC BOARD " << _boardname <<
"Unable to parse pid values for " << groupName.c_str() <<
". Quitting.";
1158 parsedGroups[groupName] = parsed;
1159 groupControlLaw[groupName] = strControlLaw;
1160 groupFbkUnits[groupName] = fbk_unitstype;
1161 groupOutUnits[groupName] = out_unitstype;
1162 groupOutType[groupName] = out_type;
1165 for(
int j = 0; j < _njoints; ++j)
1167 const std::string &groupName = _userNameControlTorque[j];
1170 trq_pids[j].enabled =
false;
1175 trq_pids[j] = parsedGroups[groupName][j];
1176 trq_pids[j].enabled =
true;
1177 trq_pids[j].fbk_PidUnits = groupFbkUnits[groupName];
1178 trq_pids[j].out_PidUnits = groupOutUnits[groupName];
1179 trq_pids[j].controlLaw = groupControlLaw[groupName];
1180 trq_pids[j].usernamePidSelected = groupName;
1181 trq_pids[j].out_type = groupOutType[groupName];
1216bool Parser::parsePidsGroup2FOC(yarp::os::Bottle& pidsGroup, std::vector<eomc::PidInfo> &curr_pids)
1220 if (!extractGroup(pidsGroup, xtmp,
"kff",
"kff parameter", _njoints))
return false;
1221 for (
int j = 0; j<_njoints; j++) curr_pids[j].pid.kff = xtmp.get(j + 1).asFloat64();
1223 if (!extractGroup(pidsGroup, xtmp,
"kp",
"kp parameter", _njoints))
return false;
1224 for (
int j = 0; j<_njoints; j++) curr_pids[j].pid.kp = xtmp.get(j + 1).asFloat64();
1226 if (!extractGroup(pidsGroup, xtmp,
"kd",
"kd parameter", _njoints))
return false;
1227 for (
int j = 0; j<_njoints; j++) curr_pids[j].pid.kd = xtmp.get(j + 1).asFloat64();
1229 if (!extractGroup(pidsGroup, xtmp,
"maxOutput",
"maxOutput parameter", _njoints))
return false;
1230 for (
int j = 0; j<_njoints; j++) curr_pids[j].pid.max_output = xtmp.get(j + 1).asFloat64();
1232 if (!extractGroup(pidsGroup, xtmp,
"ki",
"ki parameter", _njoints))
return false;
1233 for (
int j = 0; j<_njoints; j++) curr_pids[j].pid.ki = xtmp.get(j + 1).asFloat64();
1235 if (!extractGroup(pidsGroup, xtmp,
"maxInt",
"maxInt parameter", _njoints))
return false;
1236 for (
int j = 0; j<_njoints; j++) curr_pids[j].pid.max_int = xtmp.get(j + 1).asFloat64();
1238 if (!extractGroup(pidsGroup, xtmp,
"shift",
"shift parameter", _njoints))
return false;
1239 for (
int j = 0; j<_njoints; j++) curr_pids[j].pid.scale = xtmp.get(j + 1).asFloat64();
1245bool Parser::parsePidsGroupMinimalParams(Bottle& pidsGroup, std::vector<eomc::PidInfo> &pids)
1256 if (!extractGroup(pidsGroup, xtmp,
"kff",
"kff parameter", _njoints))
return false;
1257 for (
int j = 0; j<_njoints; j++) pids[j].pid.kff = xtmp.get(j + 1).asFloat64();
1259 if (!extractGroup(pidsGroup, xtmp,
"kp",
"kp parameter", _njoints))
return false;
1260 for (
int j = 0; j<_njoints; j++) pids[j].pid.kp = xtmp.get(j + 1).asFloat64();
1262 if (!extractGroup(pidsGroup, xtmp,
"kd",
"kd parameter", _njoints))
return false;
1263 for (
int j = 0; j<_njoints; j++) pids[j].pid.kd = xtmp.get(j + 1).asFloat64();
1265 if (!extractGroup(pidsGroup, xtmp,
"maxOutput",
"maxOutput parameter", _njoints))
return false;
1266 for (
int j = 0; j<_njoints; j++) pids[j].pid.max_output = xtmp.get(j + 1).asFloat64();
1271bool Parser::parsePidsGroupRegulationParams(Bottle& pidsGroup, std::vector<eomc::PidInfo> &pids)
1280 if (!parsePidsGroupMinimalParams(pidsGroup, pids))
return false;
1289 if (!extractGroup(pidsGroup, xtmp,
"ki",
"ki parameter", _njoints))
return false;
1290 for (
int j = 0; j<_njoints; j++) pids[j].pid.ki = xtmp.get(j + 1).asFloat64();
1292 if (!extractGroup(pidsGroup, xtmp,
"maxInt",
"maxInt parameter", _njoints))
return false;
1293 for (
int j = 0; j<_njoints; j++) pids[j].pid.max_int = xtmp.get(j + 1).asFloat64();
1298bool Parser::parsePidsGroupRegulationParams(Bottle& pidsGroup, std::vector<eomc::TrqPidInfo>& pids)
1300 std::vector<eomc::PidInfo> basePids(_njoints);
1301 if (!parsePidsGroupRegulationParams(pidsGroup, basePids))
return false;
1302 for (
int j = 0; j < _njoints; j++)
1304 static_cast<eomc::PidInfo&
>(pids[j]) = basePids[j];
1309bool Parser::parsePidsGroupTorqueCompensationParams(Bottle& pidsGroup, std::vector<eomc::TrqPidInfo> &pids)
1320 if (!parsePidsGroupRegulationParams(pidsGroup, pids))
return false;
1324 if (!extractGroup(pidsGroup, xtmp,
"ktau",
"ktau parameter", _njoints))
return false;
1325 for (
int j = 0; j<_njoints; j++) pids[j].ktau = xtmp.get(j + 1).asFloat64();
1327 if (!extractGroup(pidsGroup, xtmp,
"filterType",
"filterType param", _njoints))
return false;
1328 for (
int j = 0; j<_njoints; j++) pids[j].filterType = xtmp.get(j + 1).asInt32();
1331 if (!extractGroup(pidsGroup, xtmp,
"viscousPos",
"viscousPos parameter", _njoints,
false))
1334 for (
int j = 0; j<_njoints; j++) pids[j].viscousPos = _defaultSettings.torquePidDefaults.viscousPos;
1338 for (
int j = 0; j<_njoints; j++) pids[j].viscousPos = xtmp.get(j + 1).asFloat64();
1341 if (!extractGroup(pidsGroup, xtmp,
"viscousNeg",
"viscousNeg parameter", _njoints,
false))
1344 for (
int j = 0; j<_njoints; j++) pids[j].viscousNeg = _defaultSettings.torquePidDefaults.viscousNeg;
1348 for (
int j = 0; j<_njoints; j++) pids[j].viscousNeg = xtmp.get(j + 1).asFloat64();
1351 if (!extractGroup(pidsGroup, xtmp,
"coulombPos",
"coulombPos parameter", _njoints,
false))
1354 for (
int j = 0; j<_njoints; j++) pids[j].coulombPos = _defaultSettings.torquePidDefaults.coulombPos;
1358 for (
int j = 0; j<_njoints; j++) pids[j].coulombPos = xtmp.get(j + 1).asFloat64();
1361 if (!extractGroup(pidsGroup, xtmp,
"coulombNeg",
"coulombNeg parameter", _njoints,
false))
1364 for (
int j = 0; j<_njoints; j++) pids[j].coulombNeg = _defaultSettings.torquePidDefaults.coulombNeg;
1368 for (
int j = 0; j<_njoints; j++) pids[j].coulombNeg = xtmp.get(j + 1).asFloat64();
1371 if (!extractGroup(pidsGroup, xtmp,
"velocityThres",
"velocity threshold parameter for torque control", _njoints,
false))
1374 for (
int j = 0; j<_njoints; j++) pids[j].velocityThres = _defaultSettings.torquePidDefaults.velocityThres;
1378 for (
int j = 0; j<_njoints; j++) pids[j].velocityThres = xtmp.get(j + 1).asFloat64();
1386bool Parser::parseFocGroup(yarp::os::Searchable &config, std::vector<focBasedSpecificInfo_t>& foc_based_info, std::string groupName, std::vector<std::unique_ptr<eomc::ITemperatureSensor>>& temperatureSensorsVector)
1388 Bottle &focGroup=config.findGroup(groupName);
1389 if (focGroup.isNull() )
1391 yError() <<
"embObjMC BOARD " << _boardname <<
" detected that Group " << groupName <<
" is not found in configuration file";
1398 if (!extractGroup(focGroup, xtmp,
"HasHallSensor",
"HasHallSensor 0/1 ", _njoints))
1401 for (i = 1; i < xtmp.size(); i++)
1402 foc_based_info[i - 1].hasHallSensor = xtmp.get(i).asInt32() != 0;
1405 if (extractGroup(focGroup, xtmp,
"HasTempSensor",
"HasTempSensor 0/1 ", _njoints,
false))
1407 yError() << _boardname <<
"ATTENTION: HasTempSensor is deprecated. Use TemperatureSensorType (PT100, PT1000, NONE). If not specified, TemperatureSensorType defaults to NONE and the firmware does not check the motor temperature";
1411 if (!extractGroup(focGroup, xtmp,
"TemperatureSensorType",
"TemperatureSensorType PT100/PT1000/NONE ", _njoints,
false))
1414 for (i = 0; i < (unsigned)_njoints; i++)
1416 foc_based_info[i].hasTempSensor = 0;
1417 temperatureSensorsVector.at(i) = std::make_unique<eomc::TemperatureSensorNONE>();
1422 for (i = 1; i < xtmp.size(); i++)
1424 std::string s = xtmp.get(i).asString();
1427 foc_based_info[i - 1].hasTempSensor = 1;
1428 temperatureSensorsVector.at(i-1) = std::make_unique<eomc::TemperatureSensorPT100>();
1434 foc_based_info[i - 1].hasTempSensor = 1;
1435 temperatureSensorsVector.at(i-1) = std::make_unique<eomc::TemperatureSensorPT1000>();
1439 foc_based_info[i - 1].hasTempSensor = 0;
1440 temperatureSensorsVector.at(i-1) = std::make_unique<eomc::TemperatureSensorNONE>();
1445 foc_based_info[i - 1].hasTempSensor = 0;
1446 temperatureSensorsVector.at(i-1) = std::make_unique<eomc::TemperatureSensorNONE>();
1453 if (!extractGroup(focGroup, xtmp,
"HasRotorEncoder",
"HasRotorEncoder 0/1 ", _njoints))
1460 for (i = 1; i < xtmp.size(); i++)
1461 foc_based_info[i - 1].hasRotorEncoder = xtmp.get(i).asInt32() != 0;
1463 if (!extractGroup(focGroup, xtmp,
"HasRotorEncoderIndex",
"HasRotorEncoderIndex 0/1 ", _njoints))
1469 for (i = 1; i < xtmp.size(); i++)
1470 foc_based_info[i - 1].hasRotorEncoderIndex = xtmp.get(i).asInt32() != 0;
1473 if (!extractGroup(focGroup, xtmp,
"Verbose",
"Verbose 0/1 ", _njoints,
false))
1476 for (i = 0; i < (unsigned)_njoints; i++)
1477 foc_based_info[i].verbose = 0;
1481 for (i = 1; i < xtmp.size(); i++)
1482 foc_based_info[i - 1].verbose = xtmp.get(i).asInt32() != 0;
1485 std::vector<int> AutoCalibration (_njoints);
1486 if (!extractGroup(focGroup, xtmp,
"AutoCalibration",
"AutoCalibration 0/1 ", _njoints,
false))
1489 for (i = 0; i < (unsigned)_njoints; i++)
1490 AutoCalibration[i] = 0;
1494 for (i = 1; i < xtmp.size(); i++)
1495 AutoCalibration[i - 1] = xtmp.get(i).asInt32();
1498 std::vector<float> Kbemf (_njoints);
1499 if (!extractGroup(focGroup, xtmp,
"Kbemf",
"Kbemf", _njoints,
true))
1501 yError() <<
"In " << _boardname <<
" missing param Kbemf";
1506 for (i = 1; i < xtmp.size(); i++)
1507 foc_based_info[i-1].kbemf = xtmp.get(i).asFloat32();
1510 if (!extractGroup(focGroup, xtmp,
"RotorIndexOffset",
"RotorIndexOffset", _njoints))
1516 for (i = 1; i < xtmp.size(); i++)
1518 if(AutoCalibration[i-1] == 0)
1520 foc_based_info[i - 1].rotorIndexOffset = xtmp.get(i).asInt32();
1521 if (foc_based_info[i - 1].rotorIndexOffset <0 || foc_based_info[i - 1].rotorIndexOffset >359)
1523 yError() <<
"In " << _boardname <<
"joint " << i-1 <<
": rotorIndexOffset should be in [0,359] range." ;
1529 yWarning() <<
"In " << _boardname <<
"joint " << i-1 <<
": motor autocalibration is enabled!!! ATTENTION!!!" ;
1530 foc_based_info[i - 1].rotorIndexOffset = -1;
1537 for (i = 0; i < (unsigned)_njoints; i++)
1539 if((0 == foc_based_info[i].hasRotorEncoderIndex) && (0 != foc_based_info[i].rotorIndexOffset))
1541 yError() <<
"In " << _boardname <<
"joint " << i <<
": inconsistent configuration: if rotor encoder hasn't index then its offset should be 0." ;
1547 if (!extractGroup(focGroup, xtmp,
"MotorPoles",
"MotorPoles", _njoints))
1553 for (i = 1; i < xtmp.size(); i++)
1554 foc_based_info[i - 1].motorPoles = xtmp.get(i).asInt32();
1557 if (!extractGroup(focGroup, xtmp,
"HasSpeedEncoder",
"HasSpeedEncoder 0/1 ", _njoints))
1559 yWarning () <<
"missing param HasSpeedEncoder";
1565 for (i = 1; i < xtmp.size(); i++)
1566 foc_based_info[i - 1].hasSpeedEncoder = xtmp.get(i).asInt32() != 0;
1580 Bottle jointsetcfg, xml;
1582 if(!GetGroupBottle(config,
"JOINTSET_CFG", jointsetcfg))
return false;
1588 if(!extractGroup(jointsetcfg, xtmp,
"numberofsets",
"number of sets ", 1))
1591 numofsets = xtmp.get(1).asInt32();
1592 if((0 == numofsets) || (numofsets > _njoints))
1594 yError() <<
"embObjMC BOARD " << _boardname <<
"Number of jointsets is not correct. it should belong to (1, " << _njoints <<
")";
1598 if(!checkAndSetVectorSize(jsets, numofsets,
"parseJointsetCfgGroup"))
1601 if(!checkAndSetVectorSize(joint2set, _njoints,
"parseJointsetCfgGroup"))
1604 for(
unsigned int s=0;s<(unsigned)numofsets;s++)
1606 char jointset_string[80];
1607 sprintf(jointset_string,
"JOINTSET_%d", s);
1608 bool formaterror =
false;
1611 Bottle &js_cfg = jointsetcfg.findGroup(jointset_string);
1614 yError() <<
"embObjMC BOARD " << _boardname <<
"cannot find " << jointset_string;
1623 Bottle &b_listofjoints=js_cfg.findGroup(
"listofjoints",
"list of joints");
1624 if (b_listofjoints.isNull())
1626 yError() <<
"embObjMC BOARD " << _boardname <<
"listofjoints parameter not found";
1630 int numOfJointsInSet = b_listofjoints.size()-1;
1631 if((numOfJointsInSet < 1) || (numOfJointsInSet>_njoints))
1633 yError() <<
"embObjMC BOARD " << _boardname <<
"numof joints of set " << s <<
" is not correct";
1638 for (
int j = 0; j <numOfJointsInSet; j++)
1640 int jointofthisset = b_listofjoints.get(j+1).asInt32();
1642 if((jointofthisset< 0) || (jointofthisset>_njoints))
1644 yError() <<
"embObjMC BOARD " << _boardname <<
"invalid joint number for set " << s;
1648 jsets.at(s).joints.push_back(jointofthisset);
1651 joint2set.at(jointofthisset) = s;
1655 if(!extractGroup(js_cfg, xtmp,
"constraint",
"type of jointset constraint ", 1))
1660 eOmc_jsetconstraint_t constraint;
1661 if(!convert(xtmp.get(1).asString(), constraint, formaterror))
1665 jsets.at(s).cfg.constraints.type = constraint;
1668 if(!extractGroup(js_cfg, xtmp,
"param1",
"param1 of jointset constraint ", 1))
1672 jsets.at(s).cfg.constraints.param1 = (float)xtmp.get(1).asFloat64();
1675 if(!extractGroup(js_cfg, xtmp,
"param2",
"param2 of jointset constraint ", 1))
1679 jsets.at(s).cfg.constraints.param2 = (float)xtmp.get(1).asFloat64();
1693 Bottle timeoutsGroup, xtmp;
1706 if(!GetGroupBottle(config,
"TIMEOUTS", timeoutsGroup,
false))
1709 for(
auto i=0; i<_njoints; i++)
1711 timeouts[i].velocity_ref = _defaultSettings.timeoutsDefaults.velocity_ref;
1712 timeouts[i].current_ref = _defaultSettings.timeoutsDefaults.current_ref;
1713 timeouts[i].pwm_ref = _defaultSettings.timeoutsDefaults.pwm_ref;
1714 timeouts[i].torque_ref = _defaultSettings.timeoutsDefaults.torque_ref;
1715 timeouts[i].torque_fbk = _defaultSettings.timeoutsDefaults.torque_fbk;
1721 if (!extractGroup(timeoutsGroup, xtmp,
"velocity",
"a list of timeout to be used in the vmo control", _njoints,
false))
1724 for(
auto i=0; i<_njoints; i++) timeouts[i].velocity_ref = _defaultSettings.timeoutsDefaults.velocity_ref;
1728 for(
auto i=0; i<_njoints; i++) timeouts[i].velocity_ref = xtmp.get(i+1).asInt32();
1731 if (!extractGroup(timeoutsGroup, xtmp,
"current",
"a list of timeout to be used in the vmo control", _njoints,
false))
1734 for(
auto i=0; i<_njoints; i++) timeouts[i].current_ref = _defaultSettings.timeoutsDefaults.current_ref;
1738 for(
auto i=0; i<_njoints; i++) timeouts[i].current_ref = xtmp.get(i+1).asInt32();
1741 if (!extractGroup(timeoutsGroup, xtmp,
"pwm",
"a list of timeout to be used in the vmo control", _njoints,
false))
1744 for(
auto i=0; i<_njoints; i++) timeouts[i].pwm_ref = _defaultSettings.timeoutsDefaults.pwm_ref;
1748 for(
auto i=0; i<_njoints; i++) timeouts[i].pwm_ref = xtmp.get(i+1).asInt32();
1751 if (!extractGroup(timeoutsGroup, xtmp,
"torque",
"a list of timeout to be used in the vmo control", _njoints,
false))
1754 for(
auto i=0; i<_njoints; i++) timeouts[i].torque_ref = _defaultSettings.timeoutsDefaults.torque_ref;
1758 for(
auto i=0; i<_njoints; i++) timeouts[i].torque_ref = xtmp.get(i+1).asInt32();
1761 if (!extractGroup(timeoutsGroup, xtmp,
"torque_measure",
"a list of timeout to be used in the vmo control", _njoints,
false))
1763 registerOptionalParameter(
"timeout.torque_measure", std::to_string(_defaultSettings.timeoutsDefaults.torque_fbk),
true);
1764 for(
auto i=0; i<_njoints; i++) timeouts[i].torque_fbk = _defaultSettings.timeoutsDefaults.torque_fbk;
1768 for(
auto i=0; i<_njoints; i++) timeouts[i].torque_fbk = xtmp.get(i+1).asInt32();
1779 Bottle limits, xtmp;
1780 if(!GetGroupBottle(config,
"LIMITS", limits))
return false;
1783 if (!extractGroup(limits, xtmp,
"motorOverloadCurrents",
"a list of current limits", _njoints))
1786 for(
auto i=1; i<xtmp.size(); i++) currLimits[i-1].overloadCurrent=xtmp.get(i).asFloat64();
1789 if (!extractGroup(limits, xtmp,
"motorNominalCurrents",
"a list of nominal current limits", _njoints))
1791 for(
auto i=1; i<xtmp.size(); i++) currLimits[i-1].nominalCurrent =xtmp.get(i).asFloat64();
1794 if (!extractGroup(limits, xtmp,
"motorPeakCurrents",
"a list of peak current limits", _njoints))
1796 for(
auto i=1; i<xtmp.size(); i++) currLimits[i-1].peakCurrent=xtmp.get(i).asFloat64();
1807 Bottle limits, xtmp;
1808 if(!GetGroupBottle(config,
"LIMITS", limits))
return false;
1812 if(!extractGroup(limits, xtmp,
"hardwareTemperatureLimits",
"a list of temperature limits", _njoints,
false))
1814 registerOptionalParameter(
"hardwareTemperatureLimits", std::to_string(_defaultSettings.temperatureLimitsDefaults.hardware),
false);
1816 for (
auto i = 0; i < (unsigned)_njoints; i++)
1818 temperatureLimits[i].hardware = _defaultSettings.temperatureLimitsDefaults.hardware;
1819 temperatureLimits[i].warning = _defaultSettings.temperatureLimitsDefaults.warning;
1824 for (
auto i = 1; i < xtmp.size(); i++) temperatureLimits[i - 1].hardware = xtmp.get(i).asFloat64();
1825 if (!extractGroup(limits, xtmp,
"warningTemperatureLimits",
"a list of warning temperature limits", _njoints,
false))
1828 registerOptionalParameter(
"warningTemperatureLimits", std::to_string(_defaultSettings.temperatureLimitsDefaults.warning),
false);
1831 for (
auto i = 0; i < (unsigned)_njoints; i++) temperatureLimits[i].warning = _defaultSettings.temperatureLimitsDefaults.warning;
1835 for (
auto i = 1; i < xtmp.size(); i++) temperatureLimits[i - 1].warning = xtmp.get(i).asFloat64();
1842 for (
auto i = 0; i < (unsigned)_njoints; i++)
1844 if(temperatureLimits[i].warning > (0.85 * temperatureLimits[i].hardware))
1846 yError() <<
"In " << _boardname <<
"joint " << i <<
": inconsistent temperature limits. warningTemperatureLimit must be smaller than 85% of hardwareTemperatureLimit" ;
1858 Bottle limits, xtmp;
1859 if(!GetGroupBottle(config,
"LIMITS", limits))
return false;
1862 if (!extractGroup(limits, xtmp,
"jntPosMax",
"a list of user maximum angles (in degrees)", _njoints))
1865 for(
auto i=1; i<xtmp.size(); i++) jointsLimits[i-1].posMax = xtmp.get(i).asFloat64();
1868 if (!extractGroup(limits, xtmp,
"jntPosMin",
"a list of user minimum angles (in degrees)", _njoints))
1871 for(
auto i=1; i<xtmp.size(); i++) jointsLimits[i-1].posMin = xtmp.get(i).asFloat64();
1874 if (!extractGroup(limits, xtmp,
"hardwareJntPosMax",
"a list of hardware maximum angles (in degrees)", _njoints))
1878 for(
auto i=1; i<xtmp.size(); i++) jointsLimits[i-1].posHwMax = xtmp.get(i).asFloat64();
1881 for(
auto i=0; i<(unsigned)_njoints; i++)
1883 if(jointsLimits[i].posMax > jointsLimits[i].posHwMax)
1885 yError() <<
"embObjMotionControl: user has set a limit bigger then hardware limit!. Please check jntPosMax.";
1892 if (!extractGroup(limits, xtmp,
"hardwareJntPosMin",
"a list of hardware minimum angles (in degrees)", _njoints))
1898 for(
auto i=1; i<xtmp.size(); i++) jointsLimits[i-1].posHwMin = xtmp.get(i).asFloat64();
1901 for(
auto i=0; i<(unsigned)_njoints; i++)
1903 if(jointsLimits[i].posMin < jointsLimits[i].posHwMin)
1905 yError() <<
"embObjMotionControl: user has set a limit bigger then hardware limit!. Please check jntPosMin.";
1913 if (!extractGroup(limits, xtmp,
"jntVelMax",
"a list of maximum velocities for the joints (in degrees/s)", _njoints))
1916 for (
auto i = 1; i<xtmp.size(); i++) jointsLimits[i - 1].velMax = xtmp.get(i).asFloat64();
1926 Bottle limits, xtmp;
1927 if(!GetGroupBottle(config,
"LIMITS", limits))
return false;
1930 if (!extractGroup(limits, xtmp,
"rotorPosMax",
"a list of maximum rotor angles (in degrees)", _njoints))
1932 for(
auto i=1; i<xtmp.size(); i++) rotorsLimits[i-1].posMax = xtmp.get(i).asFloat64();
1935 if (!extractGroup(limits, xtmp,
"rotorPosMin",
"a list of minimum roto angles (in degrees)", _njoints))
1937 for(
auto i=1; i<xtmp.size(); i++) rotorsLimits[i-1].posMin = xtmp.get(i).asFloat64();
1940 if (!extractGroup(limits, xtmp,
"motorPwmLimit",
"a list of motor PWM limits", _njoints))
1943 for(
auto i=1; i<xtmp.size(); i++)
1945 rotorsLimits[i-1].pwmMax = xtmp.get(i).asFloat64();
1946 if(rotorsLimits[i-1].pwmMax<0)
1948 yError() <<
"In board " << _boardname <<
" motorPwmLimit should be a positive value";
1961 if (!config.findGroup(
"GENERAL").find(
"MotioncontrolVersion").isInt32())
1963 yError() <<
"Missing MotioncontrolVersion parameter. RobotInterface cannot start. Please contact icub-support@iit.it";
1967 version = config.findGroup(
"GENERAL").find(
"MotioncontrolVersion").asInt32();
1976 if(!config.findGroup(
"GENERAL").find(
"verbose").isBool())
1978 yError() <<
"embObjMotionControl::open() detects that general->verbose bool param is different from accepted values (true / false). Assuming false";
1983 ret = config.findGroup(
"GENERAL").find(
"verbose").asBool();
1992 Value use_raw = config.findGroup(
"GENERAL").find(
"useRawEncoderData");
1994 if(use_raw.isNull())
1996 useRawEncoderData =
false;
2000 if(!use_raw.isBool())
2002 yWarning() <<
"embObjMotionControl::open() detected that useRawEncoderData bool param is different from accepted values (true / false). Assuming false";
2003 useRawEncoderData =
false;
2007 useRawEncoderData = use_raw.asBool();
2008 if(useRawEncoderData)
2010 yWarning() <<
"embObjMotionControl::open() detected that it is using raw data from encoders! Be careful See 'useRawEncoderData' param in config file";
2011 yWarning() <<
"DO NOT USE OR CALIBRATE THE ROBOT IN THIS CONFIGURATION!";
2012 yWarning() <<
"CHECK IF THE FAULT BUTTON IS PRESSED and press ENTER to continue";
2019 Value use_limitedPWM = config.findGroup(
"GENERAL").find(
"useLimitedPWM");
2020 if(use_limitedPWM.isNull())
2022 pwmIsLimited =
false;
2026 if(!use_limitedPWM.isBool())
2028 pwmIsLimited =
false;
2032 pwmIsLimited = use_limitedPWM.asBool();
2042 Bottle &maintenanceGroup=config.findGroup(
"MAINTENANCE");
2043 if (maintenanceGroup.isNull())
2045 skipRecalibrationEnabled =
false;
2050 Value skip_recalibration = maintenanceGroup.find(
"skipRecalibration");
2051 if (skip_recalibration.isNull())
2053 skipRecalibrationEnabled =
false;
2057 if (!skip_recalibration.isBool())
2059 yError() <<
"embObjMotionControl::open() detected that skipRecalibration bool param is different from accepted values (true / false). Assuming false";
2060 skipRecalibrationEnabled =
false;
2064 skipRecalibrationEnabled = skip_recalibration.asBool();
2065 if(skipRecalibrationEnabled)
2067 yWarning() <<
"embObjMotionControl::open() detected that skipRecalibration is requested! Be careful See 'skipRecalibration' param in config file";
2068 yWarning() <<
"THE ROBOT WILL SKIP THE RECALIBRATION IN THIS CONFIGURATION!";
2080 Bottle general, xtmp;
2081 if(!GetGroupBottle(config,
"GENERAL", general))
return false;
2083 if (!extractGroup(general, xtmp,
"AxisMap",
"a list of reordered indices for the axes", _njoints))
2086 for (
auto i = 1; i < xtmp.size(); i++)
2088 int user_joint = xtmp.get(i).asInt32();
2089 if(user_joint>= _njoints)
2091 yError() <<
"embObjMC BOARD " << _boardname <<
"In AxisMap param: joint " << i-1 <<
"has been mapped to not-existing joint ("<< user_joint <<
"). Here there are only "<< _njoints <<
"joints";
2094 axisMap[i-1] = user_joint;
2098 if (!extractGroup(general, xtmp,
"AxisName",
"a list of strings representing the axes names", _njoints))
2102 for (
auto i = 1; i < xtmp.size(); i++)
2104 int mappedto = axisInfo[i-1].mappedto;
2105 axisInfo[axisMap[i - 1]].name = xtmp.get(i).asString();
2108 if (!extractGroup(general, xtmp,
"AxisType",
"a list of strings representing the axes type (revolute/prismatic)", _njoints))
2112 for (
auto i = 1; i < xtmp.size(); i++)
2114 string s = xtmp.get(i).asString();
2115 int mappedto = axisInfo[i-1].mappedto;
2120 yError() <<
"embObjMC BOARD " << _boardname <<
"Unknown AxisType value" << s.c_str() <<
"!";
2121 axisInfo[axisMap[i - 1]].type = yarp::dev::JointTypeEnum::VOCAB_JOINTTYPE_UNKNOWN;
2131 Bottle general, xtmp;
2132 if(!GetGroupBottle(config,
"GENERAL", general))
return false;
2137 if (!extractGroup(general, xtmp,
"Encoder",
"a list of scales for the encoders", _njoints))
2140 for (
auto i = 1; i < xtmp.size(); i++)
2142 tmp_A2E = xtmp.get(i).asFloat64();
2145 yWarning() <<
"embObjMC BOARD " << _boardname <<
"Encoder parameter should be positive!";
2147 encoderFactor[i - 1] = tmp_A2E;
2155 Bottle general, xtmp;
2156 if(!GetGroupBottle(config,
"GENERAL", general))
return false;
2161 if (!extractGroup(general, xtmp,
"fullscalePWM",
"a list of scales for the fullscalePWM conversion factor", _njoints))
2164 for (
auto i = 1; i < xtmp.size(); i++)
2166 tmpval = xtmp.get(i).asFloat64();
2169 yError() <<
"embObjMC BOARD " << _boardname <<
"fullscalePWM parameter should be positive!";
2172 dutycycleToPWM[i - 1] = tmpval / 100.0;
2180 Bottle general, xtmp;
2181 if(!GetGroupBottle(config,
"GENERAL", general))
return false;
2184 if (!extractGroup(general, xtmp,
"ampsToSensor",
"a list of scales for the ampsToSensor conversion factor", _njoints))
2187 for (
auto i = 1; i < xtmp.size(); i++)
2189 double tmpval = xtmp.get(i).asFloat64();
2192 yError() <<
"embObjMC BOARD " << _boardname <<
"ampsToSensor parameter should be positive!";
2195 ampsToSensor[i - 1] = tmpval;
2203 Bottle general, xtmp;
2204 if(!GetGroupBottle(config,
"GENERAL", general))
return false;
2207 if (!extractGroup(general, xtmp,
"Gearbox_M2J",
"The gearbox reduction ratio", _njoints))
2210 for (
auto i = 1; i < xtmp.size(); i++)
2212 gearbox_M2J[i-1] = xtmp.get(i).asFloat64();
2213 if (gearbox_M2J[i-1]==0)
2215 yError() <<
"embObjMC BOARD " << _boardname <<
"Using a gearbox value = 0 may cause problems! Check your configuration files";
2222 if (!extractGroup(general, xtmp,
"Gearbox_E2J",
"The gearbox reduction ratio between encoder and joint", _njoints))
2225 int test = xtmp.size();
2226 for (
auto i = 1; i < xtmp.size(); i++)
2228 gearbox_E2J[i-1] = xtmp.get(i).asFloat64();
2229 if (gearbox_E2J[i-1]==0)
2231 yError() <<
"embObjMC BOARD " << _boardname <<
"Using a gearbox value = 0 may cause problems! Check your configuration files";
2242 Bottle general, xtmp;
2243 if(!GetGroupBottle(config,
"GENERAL", general))
return false;
2245 if(!extractGroup(general, xtmp,
"useMotorSpeedFbk",
"Use motor speed feedback", _njoints))
2247 for (
auto i = 1; i < xtmp.size(); i++)
2249 useMotorSpeedFbk[i-1] = xtmp.get(i).asInt32();
2257 Bottle coupling_bottle, xtmp;
2258 if(!GetGroupBottle(config,
"COUPLINGS", coupling_bottle))
return false;
2260 int fixedMatrix4X4Size = 16;
2261 int fixedMatrix4X6Size = 24;
2262 bool formaterror =
false;
2265 if (!extractGroup(coupling_bottle, xtmp,
"matrixJ2M",
"matrixJ2M ", fixedMatrix4X4Size))
2268 if(
false == convert(xtmp, couplingInfo.
matrixJ2M, formaterror, fixedMatrix4X4Size))
2270 yError() <<
"embObjMC BOARD " << _boardname <<
" has detected an illegal format for some of the values of CONTROLLER.matrixJ2M";
2275 if (!extractGroup(coupling_bottle, xtmp,
"matrixE2J",
"matrixE2J ", fixedMatrix4X6Size))
2278 formaterror =
false;
2279 if(
false == convert(xtmp, couplingInfo.
matrixE2J, formaterror, fixedMatrix4X6Size))
2281 yError() <<
"embObjMC BOARD " << _boardname <<
" has detected an illegal format for some of the values of CONTROLLER.matrixE2J";
2286 if (!extractGroup(coupling_bottle, xtmp,
"matrixM2J",
"matrixM2J ", fixedMatrix4X4Size))
2289 formaterror =
false;
2290 if(
false == convert(xtmp, couplingInfo.
matrixM2J, formaterror, fixedMatrix4X4Size))
2292 yError() <<
"embObjMC BOARD " << _boardname <<
" has detected an illegal format for some of the values of CONTROLLER.matrixM2J";
2306 Bottle general = config.findGroup(
"OTHER_CONTROL_PARAMETERS");
2307 if (general.isNull())
2315 if (!extractGroup(general, xtmp,
"deadZone",
"The deadzone of joint", _njoints,
false))
2322 for (
auto i = 1; i < xtmp.size(); i++) deadzone[i-1] = xtmp.get(i).asFloat64();
2331 if(!GetGroupBottle(config,
"KALMAN_FILTER", general,
false))
2338 for(
int j=0; j<_njoints; j++)
2340 kalmanFilterParams[j].enabled = _defaultSettings.controlParametersDefaults.kalmanFilterParams.enabled;
2341 kalmanFilterParams[j].x0 = _defaultSettings.controlParametersDefaults.kalmanFilterParams.x0;
2342 kalmanFilterParams[j].Q = _defaultSettings.controlParametersDefaults.kalmanFilterParams.Q;
2343 kalmanFilterParams[j].R = _defaultSettings.controlParametersDefaults.kalmanFilterParams.R;
2344 kalmanFilterParams[j].P0 = _defaultSettings.controlParametersDefaults.kalmanFilterParams.P0;
2353 if (!extractGroup(general, xtmp,
"kalmanFilterEnabled",
"kalman filter of joint: ", _njoints,
true))
2355 for (
int j = 0; j<_njoints; j++) kalmanFilterParams[j].enabled = xtmp.get(j + 1).asBool();
2358 if (!extractGroup(general, xtmp,
"x0",
"Initial state x0 of kalman filter of joint: ", _njoints,
true))
2360 for (
int j = 0; j<_njoints; j++) kalmanFilterParams[j].x0.at(0) = xtmp.get(j + 1).asFloat32();
2363 if (!extractGroup(general, xtmp,
"x1",
"Initial state x1 of kalman filter of joint: ", _njoints,
true))
2365 for (
int j = 0; j<_njoints; j++) kalmanFilterParams[j].x0.at(1) = xtmp.get(j + 1).asFloat32();
2368 if (!extractGroup(general, xtmp,
"x2",
"Initial state x2 of kalman filter of joint: ", _njoints,
true))
2370 for (
int j = 0; j<_njoints; j++) kalmanFilterParams[j].x0.at(2) = xtmp.get(j + 1).asFloat32();
2373 if (!extractGroup(general, xtmp,
"Q0",
"Process Q0 noise covariance matrix of kalman filter of joint: ", _njoints,
true))
2375 for (
int j = 0; j<_njoints; j++) kalmanFilterParams[j].Q.at(0) = xtmp.get(j + 1).asFloat32();
2378 if (!extractGroup(general, xtmp,
"Q1",
"Process Q1 noise covariance matrix of kalman filter of joint: ", _njoints,
true))
2380 for (
int j = 0; j<_njoints; j++) kalmanFilterParams[j].Q.at(1) = xtmp.get(j + 1).asFloat32();
2383 if (!extractGroup(general, xtmp,
"Q2",
"Process Q2 noise covariance matrix of kalman filter of joint: ", _njoints,
true))
2385 for (
int j = 0; j<_njoints; j++) kalmanFilterParams[j].Q.at(2) = xtmp.get(j + 1).asFloat32();
2388 if (!extractGroup(general, xtmp,
"R",
"Measurement noise covariance matrix of kalman filter for joint: ", _njoints,
true))
2390 for (
int j = 0; j<_njoints; j++) kalmanFilterParams[j].R = xtmp.get(j + 1).asFloat32();
2393 if (!extractGroup(general, xtmp,
"P0",
"Initial state estimation error covariance matrix of kalman filter of joint: ", _njoints,
true))
2395 for (
int j = 0; j<_njoints; j++) kalmanFilterParams[j].P0 = xtmp.get(j + 1).asFloat32();
2403 Bottle impedanceGroup, xtmp;
2404 if(!GetGroupBottle(config,
"IMPEDANCE", impedanceGroup))
return false;
2407 if (!extractGroup(impedanceGroup, xtmp,
"stiffness",
"stiffness parameter", _njoints))
2410 for (
auto j=0; j<_njoints; j++)
2411 impedance[j].stiffness = xtmp.get(j+1).asFloat64();
2413 if (!extractGroup(impedanceGroup, xtmp,
"damping",
"damping parameter", _njoints))
2416 for (
auto j=0; j<_njoints; j++)
2417 impedance[j].damping = xtmp.get(j+1).asFloat64();
2424 Bottle lugreGroup, xtmp;
2425 if(!GetGroupBottle(config,
"LUGRE", lugreGroup,
false))
2428 for (
int j = 0; j<_njoints; ++j)
2430 lugre[j].Km = _defaultSettings.controlParametersDefaults.lugre.Km;
2436 if (!extractGroup(lugreGroup, xtmp,
"Km",
"torque constant parameter", _njoints))
2439 for (
auto j=0; j<_njoints; j++)
2440 lugre[j].Km = xtmp.get(j+1).asFloat64();
2442 if (!extractGroup(lugreGroup, xtmp,
"Kw",
"viscous friction parameter", _njoints))
2445 for (
auto j=0; j<_njoints; j++)
2446 lugre[j].Kw = xtmp.get(j+1).asFloat64();
2448 if (!extractGroup(lugreGroup, xtmp,
"S0",
"hysteresis position parameter", _njoints))
2451 for (
auto j=0; j<_njoints; j++)
2452 lugre[j].S0 = xtmp.get(j+1).asFloat64();
2454 if (!extractGroup(lugreGroup, xtmp,
"S1",
"hysteresis velocity parameter", _njoints))
2457 for (
auto j=0; j<_njoints; j++)
2458 lugre[j].S1 = xtmp.get(j+1).asFloat64();
2460 if (!extractGroup(lugreGroup, xtmp,
"Vth",
"velocity threshold parameter", _njoints))
2463 for (
auto j=0; j<_njoints; j++)
2464 lugre[j].Vth = xtmp.get(j+1).asFloat64();
2466 if (!extractGroup(lugreGroup, xtmp,
"Fc_pos",
"Coulomb force parameter (forward)", _njoints))
2469 for (
auto j=0; j<_njoints; j++)
2470 lugre[j].Fc_pos = xtmp.get(j+1).asFloat64();
2472 if (!extractGroup(lugreGroup, xtmp,
"Fc_neg",
"Coulomb force parameter (backward)", _njoints))
2475 for (
auto j=0; j<_njoints; j++)
2476 lugre[j].Fc_neg = xtmp.get(j+1).asFloat64();
2478 if (!extractGroup(lugreGroup, xtmp,
"Fs_pos",
"Stribeck force parameter (forward)", _njoints))
2481 for (
auto j=0; j<_njoints; j++)
2482 lugre[j].Fs_pos = xtmp.get(j+1).asFloat64();
2484 if (!extractGroup(lugreGroup, xtmp,
"Fs_neg",
"Stribeck force parameter (backward)", _njoints))
2487 for (
auto j=0; j<_njoints; j++)
2488 lugre[j].Fs_neg = xtmp.get(j+1).asFloat64();
2497bool Parser::convert(std::string
const &fromstring, eOmc_jsetconstraint_t &jsetconstraint,
bool& formaterror)
2499 const char *t = fromstring.c_str();
2501 eObool_t usecompactstring = eobool_false;
2502 jsetconstraint = eomc_string2jsetconstraint(t, usecompactstring);
2504 if(eomc_jsetconstraint_unknown == jsetconstraint)
2506 usecompactstring = eobool_true;
2507 jsetconstraint = eomc_string2jsetconstraint(t, usecompactstring);
2510 if(eomc_jsetconstraint_unknown == jsetconstraint)
2512 yError() <<
"embObjMC BOARD " << _boardname <<
"String" << t <<
"cannot be converted into a proper eOmc_jsetconstraint_t";
2520bool Parser::convert(Bottle &bottle, vector<double> &matrix,
bool &formaterror,
int targetsize)
2524 int tmp = bottle.size();
2525 int sizeofmatrix = tmp - 1;
2528 if(targetsize != sizeofmatrix)
2530 yError() <<
"embObjMC BOARD " << _boardname <<
" in converting string do matrix.In the matrix there are not" << targetsize <<
"elements";
2534 formaterror =
false;
2535 for(
int i=0; i<sizeofmatrix; i++)
2540 item = bottle.get(i+1).asFloat64();
2541 matrix.push_back(item);
2612 switch(
cfg.constraints.type)
2614 case eomc_jsetconstraint_none:
2615 cout <<
"constraint is " <<
"eomc_jsetconstraint_none";
2617 case eomc_jsetconstraint_cerhand:
2618 cout <<
"constraint is " <<
"eomc_jsetconstraint_cerhand";
2620 case eomc_jsetconstraint_trifid:
2621 cout <<
"constraint is " <<
"eomc_jsetconstraint_trifid";
2624 cout <<
". constraint is " <<
"unknown";
2627 cout <<
" param1="<<
cfg.constraints.param1 <<
" param2=" <<
cfg.constraints.param2 << endl;
2703 _optionalParametersUsed.push_back(param_info);
2708 if(_optionalParametersUsed.empty())
2716 line +=
"╔═══════════════════════════════════════════════════════════════════╗\n";
2717 size_t pad = (_boardname.length() < 16) ? (16 - _boardname.length()) : 0;
2718 line +=
"║ OPTIONAL PARAMETERS SUMMARY FOR BOARD: " + _boardname + std::string(pad,
' ') +
"║\n";
2719 line +=
"╠═══════════════════════════════════════════════════════════════════╣\n";
2720 line +=
"║ Parameter Name │ Used │ Default Value │\n";
2721 line +=
"╟───────────────────────────────┼──────┼────────────────────────────╢\n";
2724 for(
const auto ¶m : _optionalParametersUsed)
2727 std::string param_name = param.parameterName;
2728 if(param_name.length() > 31) param_name = param_name.substr(0, 28) +
"...";
2729 std::string param_name_padded = param_name + std::string(31 - param_name.length(),
' ');
2732 std::string used_str = param.wasUsed ?
"YES" :
"NO";
2733 std::string used_padded = used_str + std::string(4 - used_str.length(),
' ');
2736 std::string default_val = param.defaultValue;
2737 if(default_val.length() > 27) default_val = default_val.substr(0, 24) +
"...";
2738 std::string default_val_padded = default_val + std::string(27 - default_val.length(),
' ');
2740 line +=
"║ " + param_name_padded +
"│ " + used_padded +
" │ " + default_val_padded +
"│\n";
2744 line +=
"╚═══════════════════════════════════════════════════════════════════╝\n";
2747 yWarning() << line.c_str();
2753 _optionalParametersUsed.clear();
eOmc_jointset_configuration_t cfg
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 parseUseMotorSpeedFbkFlags(yarp::os::Searchable &config, int useMotorSpeedFbk[])
bool parseMaintenanceModeGroup(yarp::os::Searchable &config, bool &skipRecalibrationEnabled)
bool parseAmpsToSensor(yarp::os::Searchable &config, double ampsToSensor[])
bool parseFocGroup(yarp::os::Searchable &config, std::vector< focBasedSpecificInfo_t > &foc_based_info, std::string groupName, std::vector< std::unique_ptr< eomc::ITemperatureSensor > > &temperatureSensorsVector)
Parser(int numofjoints, std::string boardname)
bool parseMotioncontrolVersion(yarp::os::Searchable &config, int &version)
bool parseLugreGroup(yarp::os::Searchable &config, std::vector< lugreParameters_t > &lugre)
bool parseAxisInfo(yarp::os::Searchable &config, int axisMap[], std::vector< axisInfo_t > &axisInfo)
void registerOptionalParameter(std::string_view paramName, std::string_view defaultValue, bool wasUsed)
bool parseTimeoutsGroup(yarp::os::Searchable &config, std::vector< timeouts_t > &timeouts)
bool parseCouplingInfo(yarp::os::Searchable &config, couplingInfo_t &couplingInfo)
bool parseTemperatureLimits(yarp::os::Searchable &config, std::vector< temperatureLimits_t > &temperatureLimits)
bool parsePids(yarp::os::Searchable &config, PidControllers_t &pids, bool lowLevPidisMandatory)
bool parseDeadzoneValue(yarp::os::Searchable &config, double deadzone[], bool *found)
bool isVerboseEnabled(yarp::os::Searchable &config)
void clearOptionalParametersTrack()
bool parseCurrentLimits(yarp::os::Searchable &config, std::vector< motorCurrentLimits_t > &currLimits)
bool parseEncoderFactor(yarp::os::Searchable &config, double encoderFactor[])
void printOptionalParametersTable()
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)
void loadStrings(std::vector< std::string > &dest, const yarp::os::Bottle &source)
bool getCtrlOutTypeFromConfig(const std::string &configName, eOmc_ctrl_out_type_t &outType, std::string &description)
A map of control output types from configuration strings to their enum values and descriptions.
static const std::map< std::string, CtrlOutTypeInfo > ctrlOutTypeConfigMap
static constexpr std::string_view revolute
static constexpr std::string_view prismatic
static constexpr std::string_view direct
static constexpr std::string_view trajectory
static constexpr std::string_view current
static constexpr std::string_view torque
static constexpr std::string_view current
static constexpr std::string_view positionDirect
static constexpr std::string_view mixed
static constexpr std::string_view velocity
static constexpr std::string_view velocityDirect
static constexpr std::string_view torque
static constexpr std::string_view position
static constexpr std::string_view machine
static constexpr std::string_view metric
static constexpr std::string_view metric
static constexpr std::string_view machine
static constexpr std::string_view vel_cur
static constexpr std::string_view pwm
static constexpr std::string_view n_a
static constexpr std::string_view current
static constexpr std::string_view velocity
static constexpr std::string_view PT100
static constexpr std::string_view PT1000
static constexpr std::string_view NONE
static constexpr std::string_view NONE_STR
Default (fallback) values for embObjMotionControl configuration parameters.
eOmc_ctrl_out_type_t enumValue
std::string parameterName
std::vector< PidInfo > cur
std::vector< PidInfo > vel
std::vector< PidInfo > mix
std::vector< PidInfo > trj
std::vector< PidInfo > dir_pos
std::vector< PidInfo > dir_vel
std::vector< TrqPidInfo > trq
std::vector< double > matrixM2J
std::vector< double > matrixE2J
std::vector< double > matrixJ2M