17 #include <yarp/os/Time.h>
18 #include <yarp/os/Log.h>
19 #include <yarp/os/LogStream.h>
22 #include <yarp/dev/PolyDriver.h>
23 #include <ace/config.h>
24 #include <ace/Log_Msg.h>
30 #include <yarp/os/LogStream.h>
31 #include "EoAnalogSensors.h"
33 #include "EoProtocol.h"
34 #include "EoProtocolMN.h"
35 #include "EoProtocolAS.h"
37 #include <yarp/os/NetType.h>
40 #pragma warning(once:4355)
46 using namespace yarp::os;
56 as_service.type = eomn_serv_NONE;
58 as_service.properties.canboards.resize(0);
59 as_service.properties.sensors.resize(0);
61 as_service.settings.acquisitionrate = 0;
62 as_service.settings.enabledsensors.resize(0);
67 const char *t = fromstring.c_str();
69 toservicetype = eomn_string2servicetype(t);
71 if(eomn_serv_UNKNOWN == toservicetype)
73 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eOmn_serv_type_t";
84 const char *t = fromstring.c_str();
86 todiagnmode = eomn_string2servicediagnmode(t);
88 if(eomn_serv_diagn_mode_UNKNOWN == todiagnmode)
90 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eOmn_serv_diagn_mode_t";
124 const char *t = fromstring.c_str();
126 tosensortype = eoas_string2sensor(t);
128 if(eoas_unknown == tosensortype)
130 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eOas_sensor_t";
141 const char *t = fromstring.c_str();
143 eObool_t usecompactstring = eobool_false;
144 tobrdtype = eoboards_string2type2(t, usecompactstring);
146 if(eobrd_unknown == tobrdtype)
148 usecompactstring = eobool_true;
149 tobrdtype = eoboards_string2type2(t, usecompactstring);
152 if(eobrd_unknown == tobrdtype)
154 yWarning() <<
"ServiceParser::convert(): string" << t <<
"cannot be converted into a proper eObrd_type_t";
165 const char *t = fromstring.c_str();
167 eObool_t usecompactstring = eobool_false;
168 pidoutputtype = eomc_string2pidoutputtype(t, usecompactstring);
170 if(eomc_pidoutputtype_unknown == pidoutputtype)
172 usecompactstring = eobool_true;
173 pidoutputtype = eomc_string2pidoutputtype(t, usecompactstring);
176 if(eomc_pidoutputtype_unknown == pidoutputtype)
178 yWarning() <<
"ServiceParser::convert(): string" << t <<
"cannot be converted into a proper eOmc_pidoutputtype_t";
188 const char *t = fromstring.c_str();
190 eObool_t usecompactstring = eobool_false;
191 jsetconstraint = eomc_string2jsetconstraint(t, usecompactstring);
193 if(eomc_jsetconstraint_unknown == jsetconstraint)
195 usecompactstring = eobool_true;
196 jsetconstraint = eomc_string2jsetconstraint(t, usecompactstring);
199 if(eomc_jsetconstraint_unknown == jsetconstraint)
201 yWarning() <<
"ServiceParser::convert(): string" << t <<
"cannot be converted into a proper eOmc_jsetconstraint_t";
211 const char *t = fromstring.c_str();
213 eObool_t usecompactstring = eobool_false;
214 eObrd_type_t type = eoboards_string2type2(t, usecompactstring);
216 if(eobrd_unknown == type)
218 usecompactstring = eobool_true;
219 type = eoboards_string2type2(t, usecompactstring);
222 if(eobrd_unknown == type)
224 yWarning() <<
"ServiceParser::convert(): string" << t <<
"cannot be converted into a proper eObrd_type_t";
229 tobrdcantype = eoboards_type2cantype(type);
230 if(eobrd_cantype_unknown == tobrdcantype)
232 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eObrd_cantype_t";
242 const char *t = fromstring.c_str();
244 eObool_t usecompactstring = eobool_false;
245 eObrd_type_t type = eoboards_string2type2(t, usecompactstring);
247 if(eobrd_unknown == type)
249 usecompactstring = eobool_true;
250 type = eoboards_string2type2(t, usecompactstring);
253 if(eobrd_unknown == type)
255 yWarning() <<
"ServiceParser::convert(): string" << t <<
"cannot be converted into a proper eObrd_type_t";
260 tobrdethtype = eoboards_type2ethtype(type);
261 if(eobrd_ethtype_unknown == tobrdethtype)
263 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eObrd_ethtype_t";
274 const char *t = fromstring.c_str();
276 if(0 == strcmp(t,
"true"))
280 else if(0 == strcmp(t,
"false"))
284 else if(0 == strcmp(t,
"TRUE"))
288 else if(0 == strcmp(t,
"FALSE"))
292 else if(0 == strcmp(t,
"1"))
296 else if(0 == strcmp(t,
"0"))
302 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for bool";
314 if((number >= 0) && (number < 256))
320 yWarning() <<
"ServiceParser::convert():" << number <<
"is not a legal value for uint8_t";
331 if((number >= 0) && (number < (64*1024)))
337 yWarning() <<
"ServiceParser::convert():" << number <<
"is not a legal value for uint16_t";
350 const char *t = fromstring.c_str();
352 if((NULL == str) || (0 == strsize))
354 yWarning() <<
"ServiceParser::convert(): there is an attempt to convert string" << t <<
"into a NULL or zero-sized char *str: len = " << strsize;
359 if(strsize >= strlen(t))
361 snprintf(str, strsize,
"%s", t);
365 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a char[] of max size" << strsize;
376 const char *t = fromstring.c_str();
384 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string";
399 const char *t = fromstring.c_str();
404 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eObrd_location_t because it is too long with size = " << len;
409 char prefix[16] = {0};
410 sscanf(t,
"%3c", prefix);
411 if(0 == strcmp(prefix,
"ETH"))
414 sscanf(t,
"%3c:%d", prefix, &adr);
415 location.any.place = eobrd_place_eth;
416 location.eth.id = adr;
418 else if(0 == strcmp(prefix,
"CAN"))
424 int numberofreaditems = sscanf(t,
"%3c%d:%d%c%d", prefix, &bus, &adr, &cc, &
sub);
426 if((3 != numberofreaditems) && (5 != numberofreaditems))
428 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eObrd_location_t because we dont have correct number of sections separated by :";
434 if((1 != bus) && (2 != bus))
436 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eObrd_location_t because we can have either CAN1 or CAN2";
440 if((0 == adr) || (adr > 14))
442 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eObrd_location_t because CAN address is in range [1, 14]";
447 location.any.place = (3 == numberofreaditems) ? (eobrd_place_can) : (eobrd_place_extcan);
448 if(eobrd_place_can == location.any.place)
450 location.can.port = (1 == bus) ? (eOcanport1) : (eOcanport2);
451 location.can.addr = adr;
452 location.can.ffu = 0;
456 location.extcan.port = (1 == bus) ? (eOcanport1) : (eOcanport2);
457 location.extcan.addr = adr;
458 if((eobrd_caninsideindex_first !=
sub) && (eobrd_caninsideindex_second !=
sub) && (eobrd_caninsideindex_third !=
sub) && (eobrd_caninsideindex_fourth !=
sub))
460 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eObrd_location_t because in CANx:adr:SUB, SUB address must be in range [0, 3]";
464 location.extcan.index =
sub;
468 else if(0 == strcmp(prefix,
"LOC"))
476 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eObrd_location_t because it does not begin with ETH or CAN";
486 if((NULL == str) || (0 == len))
491 if(eobrd_place_can == loc.any.place)
493 snprintf(str, len,
"CAN%d:%d", (eOcanport1 == loc.can.port) ? 1 : 2, loc.can.addr);
495 else if(eobrd_place_extcan == loc.any.place)
497 snprintf(str, len,
"CAN%d:%d:%d", (eOcanport1 == loc.extcan.port) ? 1 : 2, loc.extcan.addr, loc.extcan.index);
499 else if(eobrd_place_eth == loc.any.place)
501 snprintf(str, len,
"ETH:%d", loc.eth.id);
515 const char *t = fromstring.c_str();
520 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eOlocation_t because it is too long with size = " << len;
525 char prefix[16] = {0};
526 sscanf(t,
"%3c", prefix);
527 if(0 == strcmp(prefix,
"LOC"))
530 sscanf(t,
"%3c:%d", prefix, &adr);
531 location.bus = eobus_local;
535 else if((0 == strcmp(prefix,
"CAN")) || (0 == strcmp(prefix,
"ICC")))
539 int numberofreaditems = sscanf(t,
"%3c%d:%d", prefix, &bus, &adr);
541 if(3 != numberofreaditems)
543 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eOlocation_t because we dont have correct number of sections separated by :";
549 if((1 != bus) && (2 != bus))
551 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eOlocation_t because we can have either ---1 or ---2";
556 if((0 == adr) || (adr > 14))
558 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eOlocation_t because address is not in range [1, 14]";
564 if(0 == strcmp(prefix,
"CAN"))
566 location.bus = (1 == bus) ? eobus_can1 : eobus_can2;
568 else if(0 == strcmp(prefix,
"ICC"))
570 location.bus = (1 == bus) ? eobus_icc1 : eobus_icc2;
578 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for a eOlocation_t because it does not begin with LOC, CAN, ICC";
588 if((NULL == str) || (0 == len))
593 if(eobus_can1 == loc.bus)
595 snprintf(str, len,
"CAN1:%d", loc.adr);
597 else if(eobus_can2 == loc.bus)
599 snprintf(str, len,
"CAN2:%d", loc.adr);
601 else if(eobus_local == loc.bus)
603 snprintf(str, len,
"LOC:%d", loc.adr);
605 else if(eobus_icc1 == loc.bus)
607 snprintf(str, len,
"ICC1:%d", loc.adr);
609 else if(eobus_icc2 == loc.bus)
611 snprintf(str, len,
"ICC2:%d", loc.adr);
623 if((NULL == str) || (0 == len))
628 if(eobrd_caninsideindex_none == canloc.insideindex)
630 snprintf(str, len,
"CAN%d:%d", (eOcanport1 == canloc.port) ? 1 : 2, canloc.addr);
634 snprintf(str, len,
"CAN%d:%d:%d", (eOcanport1 == canloc.port) ? 1 : 2, canloc.addr, canloc.insideindex);
642 if((NULL == str) || (0 == len))
647 snprintf(str, len,
"(%d, %d, %d)", firm.major, firm.minor, firm.build);
654 if((NULL == str) || (0 == len))
659 snprintf(str, len,
"(%d, %d)", prot.major, prot.minor);
664 bool ServiceParser::check_analog(Searchable &config, eOmn_serv_type_t type)
666 bool formaterror =
false;
668 if((eomn_serv_AS_mais != type) && (eomn_serv_AS_strain != type) &&
669 (eomn_serv_AS_inertials3 != type) && (eomn_serv_AS_psc != type) && (eomn_serv_AS_pos != type))
671 yError() <<
"ServiceParser::check_analog() is called with wrong type";
679 Bottle b_SERVICE(config.findGroup(
"SERVICE"));
680 if(b_SERVICE.isNull())
682 yError() <<
"ServiceParser::check_analog() cannot find SERVICE group";
688 if(
false == b_SERVICE.check(
"type"))
690 yError() <<
"ServiceParser::check_analog() cannot find SERVICE.type";
695 Bottle b_type(b_SERVICE.find(
"type").asString());
696 if(
false ==
convert(b_type.toString(), as_service.type, formaterror))
698 yError() <<
"ServiceParser::check_analog() has found unknown SERVICE.type = " << b_type.toString();
701 if(type != as_service.type)
703 yError() <<
"ServiceParser::check_analog() has found wrong SERVICE.type = " << as_service.type <<
"it must be" <<
"TODO: tostring() function";
710 Bottle b_PROPERTIES = Bottle(b_SERVICE.findGroup(
"PROPERTIES"));
711 if(b_PROPERTIES.isNull())
713 yError() <<
"ServiceParser::check_analog() cannot find PROPERTIES";
718 Bottle b_PROPERTIES_CANBOARDS = Bottle(b_PROPERTIES.findGroup(
"CANBOARDS"));
719 if(b_PROPERTIES_CANBOARDS.isNull())
721 yError() <<
"ServiceParser::check() cannot find PROPERTIES.CANBOARDS";
729 Bottle b_PROPERTIES_CANBOARDS_type = b_PROPERTIES_CANBOARDS.findGroup(
"type");
730 if(b_PROPERTIES_CANBOARDS_type.isNull())
732 yError() <<
"ServiceParser::check() cannot find PROPERTIES.CANBOARDS.type";
735 Bottle b_PROPERTIES_CANBOARDS_PROTOCOL = Bottle(b_PROPERTIES_CANBOARDS.findGroup(
"PROTOCOL"));
736 if(b_PROPERTIES_CANBOARDS_PROTOCOL.isNull())
738 yError() <<
"ServiceParser::check() cannot find PROPERTIES.CANBOARDS.PROTOCOL";
741 Bottle b_PROPERTIES_CANBOARDS_PROTOCOL_major = Bottle(b_PROPERTIES_CANBOARDS_PROTOCOL.findGroup(
"major"));
742 if(b_PROPERTIES_CANBOARDS_PROTOCOL_major.isNull())
744 yError() <<
"ServiceParser::check() cannot find PROPERTIES.CANBOARDS.PROTOCOL.major";
747 Bottle b_PROPERTIES_CANBOARDS_PROTOCOL_minor = Bottle(b_PROPERTIES_CANBOARDS_PROTOCOL.findGroup(
"minor"));
748 if(b_PROPERTIES_CANBOARDS_PROTOCOL_minor.isNull())
750 yError() <<
"ServiceParser::check() cannot find PROPERTIES.CANBOARDS.PROTOCOL.minor";
753 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE = Bottle(b_PROPERTIES_CANBOARDS.findGroup(
"FIRMWARE"));
754 if(b_PROPERTIES_CANBOARDS_FIRMWARE.isNull())
756 yError() <<
"ServiceParser::check() cannot find PROPERTIES.CANBOARDS.FIRMWARE";
759 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE_major = Bottle(b_PROPERTIES_CANBOARDS_FIRMWARE.findGroup(
"major"));
760 if(b_PROPERTIES_CANBOARDS_FIRMWARE_major.isNull())
762 yError() <<
"ServiceParser::check() cannot find PROPERTIES.CANBOARDS.FIRMWARE.major";
765 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE_minor = Bottle(b_PROPERTIES_CANBOARDS_FIRMWARE.findGroup(
"minor"));
766 if(b_PROPERTIES_CANBOARDS_FIRMWARE_minor.isNull())
768 yError() <<
"ServiceParser::check() cannot find PROPERTIES.CANBOARDS.FIRMWARE.minor";
771 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE_build = Bottle(b_PROPERTIES_CANBOARDS_FIRMWARE.findGroup(
"build"));
772 if(b_PROPERTIES_CANBOARDS_FIRMWARE_build.isNull())
774 yError() <<
"ServiceParser::check() cannot find PROPERTIES.CANBOARDS.FIRMWARE.build";
778 size_t tmp = b_PROPERTIES_CANBOARDS_type.size();
779 int numboards =
tmp - 1;
782 if( (
tmp != b_PROPERTIES_CANBOARDS_PROTOCOL_major.size()) ||
783 (
tmp != b_PROPERTIES_CANBOARDS_PROTOCOL_minor.size()) ||
784 (
tmp != b_PROPERTIES_CANBOARDS_FIRMWARE_major.size()) ||
785 (
tmp != b_PROPERTIES_CANBOARDS_FIRMWARE_minor.size()) ||
786 (
tmp != b_PROPERTIES_CANBOARDS_FIRMWARE_build.size())
789 yError() <<
"ServiceParser::check_analog() in PROPERTIES.CANBOARDS some param has inconsistent length";
794 as_service.properties.canboards.resize(0);
797 for(
int i=0; i<numboards; i++)
801 convert(b_PROPERTIES_CANBOARDS_type.get(i+1).asString(), item.
type, formaterror);
802 convert(b_PROPERTIES_CANBOARDS_PROTOCOL_major.get(i+1).asInt32(), item.
protocol.major, formaterror);
803 convert(b_PROPERTIES_CANBOARDS_PROTOCOL_minor.get(i+1).asInt32(), item.
protocol.minor, formaterror);
805 convert(b_PROPERTIES_CANBOARDS_FIRMWARE_major.get(i+1).asInt32(), item.
firmware.major, formaterror);
806 convert(b_PROPERTIES_CANBOARDS_FIRMWARE_minor.get(i+1).asInt32(), item.
firmware.minor, formaterror);
807 convert(b_PROPERTIES_CANBOARDS_FIRMWARE_build.get(i+1).asInt32(), item.
firmware.build, formaterror);
809 as_service.properties.canboards.push_back(item);
815 if(
true == formaterror)
817 yError() <<
"ServiceParser::check_analog() has detected an illegal format for some of the params of PROPERTIES.CANBOARDS some param has inconsistent length";
822 Bottle b_PROPERTIES_SENSORS = Bottle(b_PROPERTIES.findGroup(
"SENSORS"));
823 if(b_PROPERTIES_SENSORS.isNull())
825 yError() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS";
831 Bottle b_PROPERTIES_SENSORS_id = Bottle(b_PROPERTIES_SENSORS.findGroup(
"id"));
832 if(b_PROPERTIES_SENSORS_id.isNull())
834 yError() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.id";
837 Bottle b_PROPERTIES_SENSORS_type = Bottle(b_PROPERTIES_SENSORS.findGroup(
"type"));
838 if(b_PROPERTIES_SENSORS_type.isNull())
840 yError() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.type";
843 Bottle b_PROPERTIES_SENSORS_location = Bottle(b_PROPERTIES_SENSORS.findGroup(
"location"));
844 if(b_PROPERTIES_SENSORS_location.isNull())
846 yError() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.location";
849 Bottle b_PROPERTIES_SENSORS_frameName = Bottle(b_PROPERTIES_SENSORS.findGroup(
"framename"));
850 if(b_PROPERTIES_SENSORS_frameName.isNull() && eoas_string2sensor(b_PROPERTIES_SENSORS_type.get(1).asString().c_str())==eoas_strain)
852 yWarning() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.framename";
854 Bottle b_PROPERTIES_SENSORS_sensorName = Bottle(b_PROPERTIES_SENSORS.findGroup(
"sensorName"));
855 if(b_PROPERTIES_SENSORS_sensorName.isNull())
857 yWarning() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.sensorName";
859 Bottle b_PROPERTIES_SENSORS_boardType;
860 if((eomn_serv_AS_inertials3 == type) || (eomn_serv_AS_pos == type))
863 b_PROPERTIES_SENSORS_boardType = Bottle(b_PROPERTIES_SENSORS.findGroup(
"boardType"));
864 if(b_PROPERTIES_SENSORS_boardType.isNull())
866 yError() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.boardType";
872 b_PROPERTIES_SENSORS_boardType.clear();
875 Bottle b_PROPERTIES_SENSORS_pos_port;
876 Bottle b_PROPERTIES_SENSORS_pos_connector;
877 Bottle b_PROPERTIES_SENSORS_pos_CALIBRATION;
878 Bottle b_PROPERTIES_SENSORS_pos_CALIBRATION_type;
879 Bottle b_PROPERTIES_SENSORS_pos_CALIBRATION_rotation;
880 Bottle b_PROPERTIES_SENSORS_pos_CALIBRATION_offset;
881 Bottle b_PROPERTIES_SENSORS_pos_CALIBRATION_invertDirection;
884 if(type == eomn_serv_AS_pos)
886 b_PROPERTIES_SENSORS_pos_port = Bottle(b_PROPERTIES_SENSORS.findGroup(
"port"));
887 if(b_PROPERTIES_SENSORS_pos_port.isNull())
889 yError() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.port";
893 b_PROPERTIES_SENSORS_pos_connector = Bottle(b_PROPERTIES_SENSORS.findGroup(
"connector"));
894 if(b_PROPERTIES_SENSORS_pos_connector.isNull())
896 yError() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.connector";
900 b_PROPERTIES_SENSORS_pos_CALIBRATION = Bottle(b_PROPERTIES_SENSORS.findGroup(
"CALIBRATION"));
901 if(b_PROPERTIES_SENSORS_pos_CALIBRATION.isNull())
903 yWarning() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.CALIBRATION. Using neutral values (ROT:zero, 0.0, false)";
907 b_PROPERTIES_SENSORS_pos_CALIBRATION_type = Bottle(b_PROPERTIES_SENSORS_pos_CALIBRATION.findGroup(
"type"));
908 if(b_PROPERTIES_SENSORS_pos_CALIBRATION_type.isNull())
910 yWarning() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.CALIBRATION.type. Using value TYPE::decideg";
913 b_PROPERTIES_SENSORS_pos_CALIBRATION_rotation = Bottle(b_PROPERTIES_SENSORS_pos_CALIBRATION.findGroup(
"rotation"));
914 if(b_PROPERTIES_SENSORS_pos_CALIBRATION_rotation.isNull())
916 yWarning() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.CALIBRATION.rotation. Using value ROT::zero";
918 b_PROPERTIES_SENSORS_pos_CALIBRATION_offset = Bottle(b_PROPERTIES_SENSORS_pos_CALIBRATION.findGroup(
"offset"));
919 if(b_PROPERTIES_SENSORS_pos_CALIBRATION_offset.isNull())
921 yWarning() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.CALIBRATION.offset. Using value 0.0";
923 b_PROPERTIES_SENSORS_pos_CALIBRATION_invertDirection = Bottle(b_PROPERTIES_SENSORS_pos_CALIBRATION.findGroup(
"invertDirection"));
924 if(b_PROPERTIES_SENSORS_pos_CALIBRATION_invertDirection.isNull())
926 yWarning() <<
"ServiceParser::check_analog() cannot find PROPERTIES.SENSORS.CALIBRATION.invertDirection. Using value false";
934 b_PROPERTIES_SENSORS_pos_port.clear();
935 b_PROPERTIES_SENSORS_pos_connector.clear();
936 b_PROPERTIES_SENSORS_pos_CALIBRATION.clear();
937 b_PROPERTIES_SENSORS_pos_CALIBRATION_type.clear();
938 b_PROPERTIES_SENSORS_pos_CALIBRATION_rotation.clear();
939 b_PROPERTIES_SENSORS_pos_CALIBRATION_offset.clear();
940 b_PROPERTIES_SENSORS_pos_CALIBRATION_invertDirection.clear();
943 size_t tmp = b_PROPERTIES_SENSORS_id.size();
944 int numsensors =
tmp - 1;
947 if( (
tmp != b_PROPERTIES_SENSORS_type.size()) ||
948 (
tmp != b_PROPERTIES_SENSORS_location.size()) ||
949 (((eomn_serv_AS_inertials3 == type) || (eomn_serv_AS_pos == type)) && (b_PROPERTIES_SENSORS_boardType.size() !=
tmp))
952 yError() <<
"ServiceParser::check_analog() xx in PROPERTIES.SENSORS some param has inconsistent length";
957 as_service.properties.sensors.resize(0);
960 for(
int i=0; i<numsensors; i++)
965 convert(b_PROPERTIES_SENSORS_id.get(i+1).asString(), item.id, formaterror);
966 convert(b_PROPERTIES_SENSORS_type.get(i+1).asString(), item.
type, formaterror);
967 convert(b_PROPERTIES_SENSORS_location.get(i+1).asString(), item.location, formaterror);
968 if(!b_PROPERTIES_SENSORS_frameName.isNull())
970 convert(b_PROPERTIES_SENSORS_frameName.get(i+1).asString(), item.frameName, formaterror);
972 if(!b_PROPERTIES_SENSORS_sensorName.isNull())
974 convert(b_PROPERTIES_SENSORS_sensorName.get(i+1).asString(), item.sensorName, formaterror);
976 if((eomn_serv_AS_inertials3 == type) || (eomn_serv_AS_pos == type))
978 convert(b_PROPERTIES_SENSORS_boardType.get(i+1).asString(), item.boardtype, formaterror);
981 if(eomn_serv_AS_pos == type)
984 parse_POS_port(b_PROPERTIES_SENSORS_pos_port.get(i+1).asString(), item.pos.port, formaterror);
985 parse_POS_connector(b_PROPERTIES_SENSORS_pos_connector.get(i+1).asString(), item.boardtype, item.pos.connector, formaterror);
987 bool wehaveCALIBRATION = b_PROPERTIES_SENSORS_pos_CALIBRATION.isNull() ? false :
true;
989 item.pos.calibration.
clear();
990 item.pos.calibration.
type = eoas_pos_TYPE_decideg;
992 if(wehaveCALIBRATION)
997 if(
false == b_PROPERTIES_SENSORS_pos_CALIBRATION_type.isNull())
999 parse_POS_CALIB_type(b_PROPERTIES_SENSORS_pos_CALIBRATION_type.get(i+1).asString(), item.pos.calibration.
type, formaterror);
1003 if(
false == b_PROPERTIES_SENSORS_pos_CALIBRATION_rotation.isNull())
1005 parse_POS_CALIB_rotation(b_PROPERTIES_SENSORS_pos_CALIBRATION_rotation.get(i+1).asString(), item.pos.calibration.rotation, formaterror);
1009 if(
false == b_PROPERTIES_SENSORS_pos_CALIBRATION_offset.isNull())
1011 item.pos.calibration.offset = b_PROPERTIES_SENSORS_pos_CALIBRATION_offset.get(i+1).asFloat32();
1015 if(
false == b_PROPERTIES_SENSORS_pos_CALIBRATION_invertDirection.isNull())
1017 item.pos.calibration.invertdirection = b_PROPERTIES_SENSORS_pos_CALIBRATION_invertDirection.get(i+1).asBool();
1024 as_service.properties.sensors.push_back(item);
1030 if(
true == formaterror)
1032 yError() <<
"ServiceParser::check_analog() has detected an illegal format for some of the params of PROPERTIES.SENSORS some param has inconsistent length";
1040 Bottle b_SETTINGS = Bottle(b_SERVICE.findGroup(
"SETTINGS"));
1041 if(b_SETTINGS.isNull())
1043 yError() <<
"ServiceParser::check_analog() cannot find SETTINGS";
1049 Bottle b_SETTINGS_acquisitionRate = Bottle(b_SETTINGS.findGroup(
"acquisitionRate"));
1050 if(b_SETTINGS_acquisitionRate.isNull())
1052 yError() <<
"ServiceParser::check_analog() cannot find SETTINGS.acquisitionRate";
1055 Bottle b_SETTINGS_enabledSensors = Bottle(b_SETTINGS.findGroup(
"enabledSensors"));
1056 if(b_SETTINGS_enabledSensors.isNull())
1058 yError() <<
"ServiceParser::check_analog() cannot find SETTINGS.enabledSensors";
1062 size_t s = b_SETTINGS_enabledSensors.size();
1063 size_t numenabledsensors = (0 == s) ? (0) : (s - 1) ;
1066 if( numenabledsensors > as_service.properties.sensors.size() )
1068 yError() <<
"ServiceParser::check_analog() in SETTINGS.enabledSensors there are too many items with respect to supported sensors:" << numenabledsensors <<
"vs." << as_service.properties.sensors.size();
1072 convert(b_SETTINGS_acquisitionRate.get(1).asInt32(), as_service.settings.acquisitionrate, formaterror);
1075 as_service.settings.enabledsensors.resize(0);
1077 for(
size_t i=0; i<numenabledsensors; i++)
1081 std::string s_enabled_id = b_SETTINGS_enabledSensors.get(i+1).asString();
1090 for(
size_t n=0;
n<as_service.properties.sensors.size();
n++)
1094 if(item.
id == s_enabled_id)
1104 as_service.settings.enabledsensors.push_back(founditem);
1111 if(0 == as_service.settings.enabledsensors.size())
1113 yError() <<
"ServiceParser::check_analog() could not find any item in SETTINGS.enabledSensors which matches what in PROPERTIES.SENSORS.id";
1123 if(eomn_serv_AS_strain == type)
1125 Bottle b_STRAIN_SETTINGS = Bottle(b_SERVICE.findGroup(
"STRAIN_SETTINGS"));
1126 if(b_STRAIN_SETTINGS.isNull())
1128 yError() <<
"ServiceParser::check_analog() cannot find STRAIN_SETTINGS";
1134 Bottle b_STRAIN_SETTINGS_useCalibration = Bottle(b_STRAIN_SETTINGS.findGroup(
"useCalibration"));
1135 if(b_STRAIN_SETTINGS_useCalibration.isNull())
1137 yError() <<
"ServiceParser::check_analog() cannot find STRAIN_SETTINGS.useCalibration";
1141 formaterror =
false;
1142 convert(b_STRAIN_SETTINGS_useCalibration.get(1).asString(), as_strain_settings.useCalibration, formaterror);
1144 if(
true == formaterror)
1146 yError() <<
"ServiceParser::check_analog() has detected an illegal format for paramf STRAIN_SETTINGS.useCalibration";
1161 bool ServiceParser::check_skin(Searchable &config)
1163 const eOmn_serv_type_t type = eomn_serv_SK_skin;
1164 bool formaterror =
false;
1173 Bottle b_SERVICE(config.findGroup(
"SERVICE"));
1174 if(b_SERVICE.isNull())
1182 if(
false == b_SERVICE.check(
"type"))
1189 Bottle b_type(b_SERVICE.find(
"type").asString());
1190 if(
false ==
convert(b_type.toString(), sk_service.type, formaterror))
1192 yWarning() <<
"ServiceParser::check_skin() has found unknown SERVICE.type = " << b_type.toString();
1195 if(type != sk_service.type)
1197 yWarning() <<
"ServiceParser::check_skin() has found wrong SERVICE.type = " << sk_service.type <<
"it must be" <<
"TODO: tostring() function";
1204 Bottle b_PROPERTIES = Bottle(b_SERVICE.findGroup(
"PROPERTIES"));
1205 if(b_PROPERTIES.isNull())
1207 yWarning() <<
"ServiceParser::check_skin() cannot find PROPERTIES";
1212 Bottle b_PROPERTIES_CANBOARDS = Bottle(b_PROPERTIES.findGroup(
"CANBOARDS"));
1213 if(b_PROPERTIES_CANBOARDS.isNull())
1215 yWarning() <<
"ServiceParser::check() cannot find PROPERTIES.CANBOARDS";
1223 Bottle b_PROPERTIES_CANBOARDS_type = b_PROPERTIES_CANBOARDS.findGroup(
"type");
1224 if(b_PROPERTIES_CANBOARDS_type.isNull())
1226 yError() <<
"ServiceParser::check_skin() cannot find PROPERTIES.CANBOARDS.type";
1229 Bottle b_PROPERTIES_CANBOARDS_PROTOCOL = Bottle(b_PROPERTIES_CANBOARDS.findGroup(
"PROTOCOL"));
1230 if(b_PROPERTIES_CANBOARDS_PROTOCOL.isNull())
1232 yError() <<
"ServiceParser::check_skin() cannot find PROPERTIES.CANBOARDS.PROTOCOL";
1235 Bottle b_PROPERTIES_CANBOARDS_PROTOCOL_major = Bottle(b_PROPERTIES_CANBOARDS_PROTOCOL.findGroup(
"major"));
1236 if(b_PROPERTIES_CANBOARDS_PROTOCOL_major.isNull())
1238 yError() <<
"ServiceParser::check_skin() cannot find PROPERTIES.CANBOARDS.PROTOCOL.major";
1241 Bottle b_PROPERTIES_CANBOARDS_PROTOCOL_minor = Bottle(b_PROPERTIES_CANBOARDS_PROTOCOL.findGroup(
"minor"));
1242 if(b_PROPERTIES_CANBOARDS_PROTOCOL_minor.isNull())
1244 yError() <<
"ServiceParser::check_skin() cannot find PROPERTIES.CANBOARDS.PROTOCOL.minor";
1247 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE = Bottle(b_PROPERTIES_CANBOARDS.findGroup(
"FIRMWARE"));
1248 if(b_PROPERTIES_CANBOARDS_FIRMWARE.isNull())
1250 yError() <<
"ServiceParser::check_skin() cannot find PROPERTIES.CANBOARDS.FIRMWARE";
1253 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE_major = Bottle(b_PROPERTIES_CANBOARDS_FIRMWARE.findGroup(
"major"));
1254 if(b_PROPERTIES_CANBOARDS_FIRMWARE_major.isNull())
1256 yError() <<
"ServiceParser::check_skin() cannot find PROPERTIES.CANBOARDS.FIRMWARE.major";
1259 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE_minor = Bottle(b_PROPERTIES_CANBOARDS_FIRMWARE.findGroup(
"minor"));
1260 if(b_PROPERTIES_CANBOARDS_FIRMWARE_minor.isNull())
1262 yError() <<
"ServiceParser::check_skin() cannot find PROPERTIES.CANBOARDS.FIRMWARE.minor";
1265 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE_build = Bottle(b_PROPERTIES_CANBOARDS_FIRMWARE.findGroup(
"build"));
1266 if(b_PROPERTIES_CANBOARDS_FIRMWARE_build.isNull())
1268 yError() <<
"ServiceParser::check_skin() cannot find PROPERTIES.CANBOARDS.FIRMWARE.build";
1272 size_t tmp = b_PROPERTIES_CANBOARDS_type.size();
1273 size_t numboards = (0 ==
tmp) ? 0 : (
tmp - 1);
1276 if( (
tmp != b_PROPERTIES_CANBOARDS_PROTOCOL_major.size()) ||
1277 (
tmp != b_PROPERTIES_CANBOARDS_PROTOCOL_minor.size()) ||
1278 (
tmp != b_PROPERTIES_CANBOARDS_FIRMWARE_major.size()) ||
1279 (
tmp != b_PROPERTIES_CANBOARDS_FIRMWARE_minor.size()) ||
1280 (
tmp != b_PROPERTIES_CANBOARDS_FIRMWARE_build.size())
1283 yError() <<
"ServiceParser::check_skin() in PROPERTIES.CANBOARDS some param has inconsistent length";
1289 yError() <<
"ServiceParser::check_skin() in PROPERTIES.CANBOARDS has found more than one board";
1293 formaterror =
false;
1295 sk_service.properties.canboard.clear();
1297 convert(b_PROPERTIES_CANBOARDS_type.get(1).asString(), sk_service.properties.canboard.type, formaterror);
1298 convert(b_PROPERTIES_CANBOARDS_PROTOCOL_major.get(1).asInt32(), sk_service.properties.canboard.protocol.major, formaterror);
1299 convert(b_PROPERTIES_CANBOARDS_PROTOCOL_minor.get(1).asInt32(), sk_service.properties.canboard.protocol.minor, formaterror);
1301 convert(b_PROPERTIES_CANBOARDS_FIRMWARE_major.get(1).asInt32(), sk_service.properties.canboard.firmware.major, formaterror);
1302 convert(b_PROPERTIES_CANBOARDS_FIRMWARE_minor.get(1).asInt32(), sk_service.properties.canboard.firmware.minor, formaterror);
1303 convert(b_PROPERTIES_CANBOARDS_FIRMWARE_build.get(1).asInt32(), sk_service.properties.canboard.firmware.build, formaterror);
1310 if(
true == formaterror)
1312 yError() <<
"ServiceParser::check_skin() has detected an illegal format for some of the params of PROPERTIES.CANBOARDS some param has inconsistent length";
1320 Bottle b_PROPERTIES_SENSORS = Bottle(b_PROPERTIES.findGroup(
"SENSORS"));
1321 if(b_PROPERTIES_SENSORS.isNull())
1323 yError() <<
"ServiceParser::check() cannot find PROPERTIES.SENSORS";
1329 Bottle b_PROPERTIES_SENSORS_id = Bottle(b_PROPERTIES_SENSORS.findGroup(
"id"));
1330 if(b_PROPERTIES_SENSORS_id.isNull())
1332 yError() <<
"ServiceParser::check() cannot find PROPERTIES.SENSORS.id";
1335 Bottle b_PROPERTIES_SENSORS_type = Bottle(b_PROPERTIES_SENSORS.findGroup(
"type"));
1336 if(b_PROPERTIES_SENSORS_type.isNull())
1338 yError() <<
"ServiceParser::check() cannot find PROPERTIES.SENSORS.type";
1341 Bottle b_PROPERTIES_SENSORS_location = Bottle(b_PROPERTIES_SENSORS.findGroup(
"location"));
1342 if(b_PROPERTIES_SENSORS_location.isNull())
1344 yError() <<
"ServiceParser::check() cannot find PROPERTIES.SENSORS.location";
1347 Bottle b_PROPERTIES_SENSORS_boardtype;
1348 if(type == eomn_serv_AS_inertials3)
1351 b_PROPERTIES_SENSORS_boardtype = Bottle(b_PROPERTIES_SENSORS.findGroup(
"boardType"));
1352 if(b_PROPERTIES_SENSORS_boardtype.isNull())
1354 yError() <<
"ServiceParser::check() cannot find PROPERTIES.SENSORS.boardType";
1360 b_PROPERTIES_SENSORS_boardtype.clear();
1363 int tmp = b_PROPERTIES_SENSORS_id.size();
1364 int numsensors =
tmp - 1;
1367 if( (
tmp != b_PROPERTIES_SENSORS_type.size()) ||
1368 (
tmp != b_PROPERTIES_SENSORS_location.size()) ||
1369 ((type == eomn_serv_AS_inertials3) && (b_PROPERTIES_SENSORS_boardtype.size() !=
tmp))
1372 yError() <<
"ServiceParser::check() in PROPERTIES.SENSORS some param has inconsistent length";
1377 sk_service.properties.sensors.resize(0);
1379 formaterror =
false;
1380 for(
int i=0; i<numsensors; i++)
1383 item.
type = eoas_none;
1384 item.
location.any.place = eobrd_place_none;
1386 convert(b_PROPERTIES_SENSORS_id.get(i+1).asString(), item.
id, formaterror);
1387 convert(b_PROPERTIES_SENSORS_type.get(i+1).asString(), item.
type, formaterror);
1388 convert(b_PROPERTIES_SENSORS_location.get(i+1).asString(), item.
location, formaterror);
1389 if(type == eomn_serv_AS_inertials3)
1391 convert(b_PROPERTIES_SENSORS_boardtype.get(i+1).asString(), item.
boardtype, formaterror);
1398 sk_service.properties.sensors.push_back(item);
1404 if(
true == formaterror)
1406 yError() <<
"ServiceParser::check() has detected an illegal format for some of the params of PROPERTIES.SENSORS some param has inconsistent length";
1420 Bottle b_SETTINGS = Bottle(b_SERVICE.findGroup(
"SETTINGS"));
1421 if(b_SETTINGS.isNull())
1423 yError() <<
"ServiceParser::check() cannot find SETTINGS";
1429 Bottle b_SETTINGS_acquisitionRate = Bottle(b_SETTINGS.findGroup(
"acquisitionRate"));
1430 if(b_SETTINGS_acquisitionRate.isNull())
1432 yError() <<
"ServiceParser::check() cannot find SETTINGS.acquisitionRate";
1435 Bottle b_SETTINGS_enabledSensors = Bottle(b_SETTINGS.findGroup(
"enabledSensors"));
1436 if(b_SETTINGS_enabledSensors.isNull())
1438 yError() <<
"ServiceParser::check() cannot find SETTINGS.enabledSensors";
1442 int numenabledsensors = b_SETTINGS_enabledSensors.size() - 1;
1445 if( numenabledsensors > sk_service.properties.sensors.size() )
1447 yError() <<
"ServiceParser::check() in SETTINGS.enabledSensors there are too many items with respect to supported sensors:" << numenabledsensors <<
"vs." << sk_service.properties.sensors.size();
1451 convert(b_SETTINGS_acquisitionRate.get(1).asInt32(), sk_service.settings.acquisitionrate, formaterror);
1454 sk_service.settings.enabledsensors.resize(0);
1456 for(
int i=0; i<numenabledsensors; i++)
1460 std::string s_enabled_id = b_SETTINGS_enabledSensors.get(i+1).asString();
1469 for(
size_t n=0;
n<sk_service.properties.sensors.size();
n++)
1473 if(item.
id == s_enabled_id)
1483 sk_service.settings.enabledsensors.push_back(founditem);
1490 if(0 == sk_service.settings.enabledsensors.size())
1492 yError() <<
"ServiceParser::check() could not find any item in SETTINGS.enabledSensors which matches what in PROPERTIES.SENSORS.id";
1507 if(eomn_serv_AS_strain == type)
1509 Bottle b_STRAIN_SETTINGS = Bottle(b_SERVICE.findGroup(
"STRAIN_SETTINGS"));
1510 if(b_STRAIN_SETTINGS.isNull())
1512 yError() <<
"ServiceParser::check() cannot find STRAIN_SETTINGS";
1518 Bottle b_STRAIN_SETTINGS_useCalibration = Bottle(b_STRAIN_SETTINGS.findGroup(
"useCalibration"));
1519 if(b_STRAIN_SETTINGS_useCalibration.isNull())
1521 yError() <<
"ServiceParser::check() cannot find STRAIN_SETTINGS.useCalibration";
1525 formaterror =
false;
1526 convert(b_STRAIN_SETTINGS_useCalibration.get(1).asString(), sk_skin_settings.useCalibration, formaterror);
1528 if(
true == formaterror)
1530 yError() <<
"ServiceParser::check() has detected an illegal format for paramf STRAIN_SETTINGS.useCalibration";
1549 if(
false == check_analog(config, eomn_serv_AS_mais))
1551 yError() <<
"ServiceParser::parseService() has received an invalid SERVICE group for mais";
1556 servCanBoard_t themais_props = as_service.properties.canboards.at(0);
1561 if(eobrd_cantype_mais != themais_props.
type)
1563 yError() <<
"ServiceParser::parseService() has detected an invalid type of board. it should be a eobrd_mais but is a:" << eoboards_type2string2(eoboards_cantype2type(themais_props.
type), eobool_false);
1573 maisconfig.
ethservice.configuration.type = eomn_serv_AS_mais;
1574 memcpy(&maisconfig.
ethservice.configuration.data.as.mais.version.protocol, &themais_props.
protocol,
sizeof(eObrd_protocolversion_t));
1575 memcpy(&maisconfig.
ethservice.configuration.data.as.mais.version.firmware, &themais_props.
firmware,
sizeof(eObrd_firmwareversion_t));
1578 if(eobrd_place_can != themais_sensor.
location.any.place)
1580 yError() <<
"ServiceParser::parseService() has received an invalid location for its mais. it is not a CANx:adr location";
1583 maisconfig.
ethservice.configuration.data.as.mais.canloc.port = themais_sensor.
location.can.port;
1584 maisconfig.
ethservice.configuration.data.as.mais.canloc.addr = themais_sensor.
location.can.addr;
1585 maisconfig.
ethservice.configuration.data.as.mais.canloc.insideindex = eobrd_caninsideindex_none;
1594 if(
false == check_analog(config, eomn_serv_AS_strain))
1596 yError() <<
"ServiceParser::parseService() has received an invalid SERVICE group for strain";
1601 servCanBoard_t thestrain_props = as_service.properties.canboards.at(0);
1605 if((eobrd_cantype_strain != thestrain_props.
type) && (eobrd_cantype_strain2 != thestrain_props.
type) && (eobrd_cantype_strain2c != thestrain_props.
type))
1607 yError() <<
"ServiceParser::parseService() has detected an invalid type of board. it should be a eobrd_strain, eobrd_strain2 or eobrd_strain2c but is a:" << eoboards_type2string2(eoboards_cantype2type(thestrain_props.
type), eobool_false);
1615 memset(&strainconfig.
ethservice.configuration, 0,
sizeof(strainconfig.
ethservice.configuration));
1617 strainconfig.
ethservice.configuration.type = eomn_serv_AS_strain;
1618 strainconfig.
ethservice.configuration.data.as.strain.boardtype.type = thestrain_props.
type;
1619 memcpy(&strainconfig.
ethservice.configuration.data.as.strain.boardtype.protocol, &thestrain_props.
protocol,
sizeof(eObrd_protocolversion_t));
1620 memcpy(&strainconfig.
ethservice.configuration.data.as.strain.boardtype.firmware, &thestrain_props.
firmware,
sizeof(eObrd_firmwareversion_t));
1623 if(eobrd_place_can != thestrain_sensor.
location.any.place)
1625 yError() <<
"ServiceParser::parseService() has received an invalid location for strain. it is not a CANx:adr location";
1628 strainconfig.
ethservice.configuration.data.as.strain.canloc.port = thestrain_sensor.
location.can.port;
1629 strainconfig.
ethservice.configuration.data.as.strain.canloc.addr = thestrain_sensor.
location.can.addr;
1630 strainconfig.
ethservice.configuration.data.as.strain.canloc.insideindex = eobrd_caninsideindex_none;
1639 if(
false == check_analog(config, eomn_serv_AS_strain))
1641 yError() <<
"ServiceParser::parseService() has received an invalid SERVICE group for strain";
1646 servCanBoard_t thestrain_props = as_service.properties.canboards.at(0);
1650 if( (eobrd_cantype_strain != thestrain_props.
type) && (eobrd_cantype_strain2 != thestrain_props.
type) && (eobrd_cantype_strain2c != thestrain_props.
type))
1652 yError() <<
"ServiceParser::parseService() for embObjFTsensor has detected an invalid type of board. it should be a eobrd_strain2 or a eobrd_strain2c but is a:" << eoboards_type2string2(eoboards_cantype2type(thestrain_props.
type), eobool_false);
1663 ftconfig.
ethservice.configuration.type = eomn_serv_AS_strain;
1664 ftconfig.
ethservice.configuration.data.as.strain.boardtype.type = thestrain_props.
type;
1665 memcpy(&ftconfig.
ethservice.configuration.data.as.strain.boardtype.protocol, &thestrain_props.
protocol,
sizeof(eObrd_protocolversion_t));
1666 memcpy(&ftconfig.
ethservice.configuration.data.as.strain.boardtype.firmware, &thestrain_props.
firmware,
sizeof(eObrd_firmwareversion_t));
1669 if(eobrd_place_can != thestrain_sensor.
location.any.place)
1671 yError() <<
"ServiceParser::parseService() has received an invalid location for strain. it is not a CANx:adr location";
1674 ftconfig.
ethservice.configuration.data.as.strain.canloc.port = thestrain_sensor.
location.can.port;
1675 ftconfig.
ethservice.configuration.data.as.strain.canloc.addr = thestrain_sensor.
location.can.addr;
1676 ftconfig.
ethservice.configuration.data.as.strain.canloc.insideindex = eobrd_caninsideindex_none;
1680 Bottle b_SERVICE(config.findGroup(
"SERVICE"));
1681 Bottle b_SETTINGS = Bottle(b_SERVICE.findGroup(
"SETTINGS"));
1682 Bottle b_SETTINGS_temp = Bottle(b_SETTINGS.findGroup(
"temperature-acquisitionRate"));
1684 if(b_SETTINGS_temp.isNull())
1686 if (eobrd_cantype_strain != thestrain_props.
type) {
1687 yError() <<
"ServiceParser::parseService() for embObjFTsensor device cannot find SETTINGS.temperature-acquisitionRate";
1706 if(
false == check_analog(config, eomn_serv_AS_inertials3))
1708 yError() <<
"ServiceParser::parseService(IMU) has received an invalid SERVICE group for IMU";
1715 if(as_service.properties.canboards.size() > eOas_inertials3_boardinfos_maxnumber)
1717 yError() <<
"ServiceParser::parseService(IMU): too many type board info are configured. The max num is " << eOas_inertials3_boardinfos_maxnumber;
1725 imuconfig.
ethservice.configuration.type = eomn_serv_AS_inertials3;
1735 eOas_inertial3_setof_boardinfos_t * boardInfoSet_ptr = &imuconfig.
ethservice.configuration.data.as.inertial3.setofboardinfos;
1736 eOresult_t res = eoas_inertial3_setof_boardinfos_clear(boardInfoSet_ptr);
1739 yError() <<
"ServiceParser::parseService(IMU). Error in eoas_inertial3_setof_boardinfos_clear()";
1743 EOarray* array = eo_array_New(eOas_inertials3_descriptors_maxnumber,
sizeof(eOas_inertial3_descriptor_t), &imuconfig.
ethservice.configuration.data.as.inertial3.arrayofdescriptor);
1744 for(
size_t i=0; i<as_service.settings.enabledsensors.size(); i++)
1747 eOas_sensor_t type = sensor.
type;
1750 if( (eoas_imu_acc != type) && (eoas_imu_mag != type) && (eoas_imu_gyr != type) && (eoas_imu_eul != type) &&
1751 (eoas_imu_qua != type) && (eoas_imu_lia != type) && (eoas_imu_grv != type) && (eoas_imu_status != type) &&
1752 (eoas_accel_mtb_int != type) && (eoas_accel_mtb_ext != type) && (eoas_gyros_mtb_ext != type) &&
1753 (eoas_gyros_st_l3g4200d != type))
1755 yWarning() <<
"ServiceParser::parseService() has detected a wrong inertial sensor:" << eoas_sensor2string(type) <<
" ... we drop it";
1760 eOas_inertial3_descriptor_t des = {};
1761 des.typeofsensor = type;
1762 memcpy(&des.on, &sensor.
location,
sizeof(eObrd_location_t));
1764 const eObrd_info_t *boardInfo_ptr = eoas_inertial3_setof_boardinfos_find(boardInfoSet_ptr, eoboards_type2cantype(sensor.
boardtype));
1765 if(
nullptr == boardInfo_ptr && sensor.
boardtype != eobrd_ems4)
1771 for(b=0; b<as_service.properties.canboards.size(); b++)
1773 if(as_service.properties.canboards.at(b).type == eoboards_type2cantype(sensor.
boardtype))
1781 yError() <<
"ServiceParser::parseService(IMU). The sensor " << sensor.
boardtype <<
"with type "<< eoas_sensor2string(
static_cast<eOas_sensor_t
> (des.typeofsensor)) <<
"has borad type " << eoboards_type2string2(sensor.
boardtype,
false) <<
" that is not declared in the SERVICE.PROPERTIES.CANBOARDS tag";
1784 eObrd_info_t boardInfo = {};
1785 boardInfo.type = as_service.properties.canboards.at(b).type;
1786 memcpy(&boardInfo.protocol , &as_service.properties.canboards.at(b).protocol,
sizeof(eObrd_protocolversion_t));
1787 memcpy(&boardInfo.firmware, &as_service.properties.canboards.at(b).firmware,
sizeof(eObrd_firmwareversion_t));
1788 res = eoas_inertial3_setof_boardinfos_add(boardInfoSet_ptr, &boardInfo);
1791 yError() <<
"ServiceParser::parseService(IMU). Error in eoas_inertial3_setof_boardinfos_add()";
1797 eo_array_PushBack(array, &des);
1799 imuconfig.
id.push_back(sensor.
id);
1819 if(
false == check_skin(config))
1821 yWarning() <<
"ServiceParser::parseService(SKIN) has received an invalid SERVICE group: using defaults";
1828 if((eobrd_cantype_mtb != sk_service.properties.canboard.type) && (eobrd_cantype_mtb4 != sk_service.properties.canboard.type) && (eobrd_cantype_psc != sk_service.properties.canboard.type) && (eobrd_cantype_mtb4c != sk_service.properties.canboard.type))
1830 yError() <<
"ServiceParser::parseService(SK): only mtb / mtb4 / mtb4c / psc boards are allowed: using defaults";
1836 skinconfig.
canboard.
type = sk_service.properties.canboard.type;
1837 skinconfig.
canboard.
firmware.major = sk_service.properties.canboard.firmware.major;
1838 skinconfig.
canboard.
firmware.minor = sk_service.properties.canboard.firmware.minor;
1839 skinconfig.
canboard.
firmware.build = sk_service.properties.canboard.firmware.build;
1840 skinconfig.
canboard.
protocol.major = sk_service.properties.canboard.protocol.major;
1841 skinconfig.
canboard.
protocol.minor = sk_service.properties.canboard.protocol.minor;
1849 if(
false == check_analog(config, eomn_serv_AS_psc))
1851 yError() <<
"ServiceParser::parseService(PSC) has received an invalid SERVICE group for PSC";
1858 if(as_service.properties.canboards.size() > 1)
1860 yError() <<
"ServiceParser::parseService(PSC): too many type board info are configured. The max num is " << 1;
1864 if(as_service.settings.enabledsensors.size() > eOas_psc_boards_maxnumber)
1866 yError() <<
"ServiceParser::parseService(PSC): too many enabled sensors are configured. The max num is " << eOas_psc_boards_maxnumber;
1874 pscconfig.
ethservice.configuration.type = eomn_serv_AS_psc;
1880 servCanBoard_t *asServBoardInfo_ptr = &as_service.properties.canboards[0];
1881 eOmn_serv_config_data_as_psc_t *pscBoardConfig_ptr = &pscconfig.
ethservice.configuration.data.as.psc;
1884 pscBoardConfig_ptr->version.firmware.major = asServBoardInfo_ptr->
firmware.major;
1885 pscBoardConfig_ptr->version.firmware.minor = asServBoardInfo_ptr->
firmware.minor;
1886 pscBoardConfig_ptr->version.firmware.build = asServBoardInfo_ptr->
firmware.build;
1887 pscBoardConfig_ptr->version.protocol.major = asServBoardInfo_ptr->
protocol.major;
1888 pscBoardConfig_ptr->version.protocol.minor = asServBoardInfo_ptr->
protocol.minor;
1890 for(
size_t i=0; i<as_service.settings.enabledsensors.size(); i++)
1894 if(eoas_psc_angle != sensor.
type)
1896 yWarning() <<
"ServiceParser::parseService() has detected a wrong psc sensor:" << eoas_sensor2string(sensor.
type) <<
" ... we drop it";
1901 pscBoardConfig_ptr->boardInfo.canloc[i].addr= sensor.
location.can.addr;
1902 pscBoardConfig_ptr->boardInfo.canloc[i].port= sensor.
location.can.port;
1912 if(
false == check_analog(config, eomn_serv_AS_pos))
1914 yError() <<
"ServiceParser::parseService(POS) has received an invalid SERVICE group for POS";
1919 if(as_service.settings.enabledsensors.size() > eOas_pos_sensorsinboard_maxnumber)
1921 yError() <<
"ServiceParser::parseService(POS): too many enabled sensors are configured. The max num is " << eOas_pos_sensorsinboard_maxnumber;
1927 eObrd_type_t boardtype = eobrd_none;
1928 eObrd_location_t location = {};
1929 for(
size_t i=0; i<as_service.settings.enabledsensors.size(); i++)
1931 if(eobrd_none == boardtype)
1933 boardtype = as_service.settings.enabledsensors[i].boardtype;
1934 location = as_service.settings.enabledsensors[i].location;
1935 bool validBoardForPOS = (eobrd_mtb4 == boardtype) || (eobrd_mtb4c == boardtype) || (eobrd_pmc == boardtype);
1936 if(validBoardForPOS)
1942 yError() <<
"ServiceParser::parseService(POS): sensors must have the correct boardtype (mtb4, mtb4c or pmc).";
1948 if(boardtype != as_service.settings.enabledsensors[i].boardtype)
1950 yError() <<
"ServiceParser::parseService(POS): all sensors must have the same boardtype. See SENSORS::boardType values";
1954 if((location.can.port != as_service.settings.enabledsensors[i].location.can.port) || (location.can.addr != as_service.settings.enabledsensors[i].location.can.addr))
1956 yError() <<
"ServiceParser::parseService(POS): all sensors must have the same can location. See SENSORS::location values";
1963 for(
size_t i=0; i<as_service.properties.canboards.size(); i++)
1965 if(
static_cast<eObrd_cantype_t
>(boardtype) == as_service.properties.canboards[i].type)
1967 board = &as_service.properties.canboards[0];
1971 if(
nullptr ==
board)
1973 yError() <<
"ServiceParser::parseService(POS): cannot find the boardtype " << eoboards_type2string2(boardtype, eobool_true) <<
" of SENSORS::boardType inside CANBOARDS::type";
1981 posconfig.
ethservice.configuration.type = eomn_serv_AS_pos;
1989 eOmn_serv_config_data_as_pos_t *pos = &posconfig.
ethservice.configuration.data.as.pos;
1990 for(
size_t b=0; b<eOas_pos_boards_maxnumber; b++)
1992 pos->config.boardconfig[b].boardinfo.type = boardtype;
1993 pos->config.boardconfig[b].boardinfo.firmware.major =
board->firmware.major;
1994 pos->config.boardconfig[b].boardinfo.firmware.minor =
board->firmware.minor;
1995 pos->config.boardconfig[b].boardinfo.firmware.build =
board->firmware.build;
1996 pos->config.boardconfig[b].boardinfo.protocol.major =
board->protocol.major;
1997 pos->config.boardconfig[b].boardinfo.protocol.minor =
board->protocol.minor;
1999 pos->config.boardconfig[b].canloc.addr = location.can.addr;
2000 pos->config.boardconfig[b].canloc.port = location.can.port;
2002 for(
size_t s=0; s<as_service.settings.enabledsensors.size(); s++)
2005 pos->config.boardconfig[b].sensors[s].connector = snsr.
pos.
connector;
2007 pos->config.boardconfig[b].sensors[s].port = snsr.
pos.
port;
2008 pos->config.boardconfig[b].sensors[s].enabled = 1;
2011 pos->config.boardconfig[b].sensors[s].offset =
static_cast<int16_t
>(10 * snsr.
pos.
calibration.
offset);
2019 #if defined(SERVICE_PARSER_USE_MC)
2024 const char *t = fromstring.c_str();
2028 case eomc_enc_unknown:
2030 yWarning() <<
"ServiceParser::parse_encoder_port():" << t <<
"cannot be converted into a port because argument type is" << eomc_encoder2string(type, eobool_false);
2031 toport = eobrd_port_none;
2038 toport = eobrd_port_none;
2044 case eomc_enc_aksim2:
2047 case eomc_enc_spichainof2:
2048 case eomc_enc_absanalog:
2049 case eomc_enc_spichainof3:
2051 uint8_t toport1 = eobrd_port_unknown;
2052 bool result = parse_port_conn(fromstring,
static_cast<eObrd_type_t
>(ethboard), toport1, formaterror);
2056 yWarning() <<
"ServiceParser::parse_encoder_port():" << t <<
"is not a legal string for an encoder connector port";
2071 uint8_t toport1 = eobrd_port_unknown;
2072 bool result = parse_port_mais(fromstring, toport1, formaterror);
2076 yWarning() <<
"ServiceParser::parse_encoder_port():" << t <<
"is not a legal string for an encoder connector port";
2090 uint8_t toport1 = eobrd_port_unknown;
2091 bool result = parse_port_psc(fromstring, toport1, formaterror);
2095 yWarning() <<
"ServiceParser::parse_encoder_port():" << t <<
"is not a legal string for an encoder connector port";
2109 uint8_t toport1 = eobrd_port_unknown;
2110 bool result = parse_port_pos(fromstring, toport1, formaterror);
2114 yWarning() <<
"ServiceParser::parse_encoder_port():" << t <<
"is not a legal string for an encoder connector port";
2128 int len = strlen(t);
2132 yWarning() <<
"ServiceParser::parse_encoder_port():" << t <<
"is not a legal string for a encoder port because it is too long with size =" << len;
2136 char prefix[16] = {0};
2137 sscanf(t,
"%3c", prefix);
2138 if(0 == strcmp(prefix,
"CAN"))
2140 toport = eobrd_port_nolocal;
2145 toport = eobrd_port_none;
2146 yWarning() <<
"ServiceParser::parse_encoder_port():" << t <<
"is not a legal string for a encoder port!";
2158 const char *t = fromstring.c_str();
2162 eObrd_connector_t conn = eobrd_conn_unknown;
2163 bool result = parse_connector(fromstring, conn, formaterror);
2167 yWarning() <<
"ServiceParser::parse_port_conn():" << t <<
"is not a legal string for a eObrd_connector_t";
2173 eObrd_port_t port = eoboards_connector2port(conn,
board);
2174 if(eobrd_port_unknown == port)
2176 yWarning() <<
"ServiceParser::parse_port_conn():" << t <<
"does not convert to a legal port for connector" << eoboards_connector2string(conn, eobool_false) <<
"and parsed board";
2194 const char *t = fromstring.c_str();
2198 eObrd_portmais_t pmais = eobrd_portmais_unknown;
2199 bool result = parse_mais(fromstring, pmais, formaterror);
2203 yWarning() <<
"ServiceParser::parse_port_mais():" << t <<
"is not a legal string for a port mais";
2219 const char *t = fromstring.c_str();
2223 eObrd_portpsc_t ppsc = eobrd_portpsc_unknown;
2224 bool result = parse_psc(fromstring, ppsc, formaterror);
2228 yWarning() <<
"ServiceParser::parse_port_psc():" << t <<
"is not a legal string for a port psc";
2248 eObrd_portpos_t ppos = eobrd_portpos_unknown;
2249 bool result = parse_POS_port(fromstring, ppos, formaterror);
2253 yWarning() <<
"ServiceParser::parse_port_pos():" << fromstring <<
"is not a legal string for a port pos";
2311 bool ServiceParser::parse_actuator_port(std::string
const &fromstring, eObrd_ethtype_t
const ethboard, eOmc_actuator_t
const type, eOmc_actuator_descriptor_t &todes,
bool &formaterror)
2313 const char *t = fromstring.c_str();
2319 case eomc_act_unknown:
2321 yWarning() <<
"ServiceParser::parse_actuator_port():" << t <<
"cannot be converted into a eObrd_location_t because argument type is" << eomc_actuator2string(type, eobool_false);
2322 todes.none.port = eobrd_port_none;
2330 todes.none.port = eobrd_port_none;
2337 uint8_t toport = eobrd_port_unknown;
2338 bool result = parse_port_conn(fromstring,
static_cast<eObrd_type_t
>(ethboard), toport, formaterror);
2342 yWarning() <<
"ServiceParser::parse_actuator_port():" << t <<
"is not a legal string for a pwm connector port";
2348 todes.pwm.port = toport;
2358 eObrd_location_t loc;
2359 bool result =
convert(fromstring, loc, formaterror);
2363 yWarning() <<
"ServiceParser::parse_actuator_port():" << t <<
"is not a legal string for a eObrd_location_t";
2367 else if((eomc_act_mc4 == type) && (eobrd_place_extcan != loc.any.place))
2369 yWarning() <<
"ServiceParser::parse_actuator_port():" << t <<
"is not a legal string for a eomc_act_mc4 location because it is not a eobrd_place_extcan";
2373 else if(eomc_act_foc == type)
2375 if((eobrd_place_can != loc.any.place) && (eobrd_place_extcan != loc.any.place))
2377 yWarning() <<
"ServiceParser::parse_actuator_port():" << t <<
"is not a legal string for a eomc_act_foc location because it is not a eobrd_place_extcan or eobrd_place_can";
2388 if(eomc_act_foc == type)
2391 if(eobrd_place_can == loc.any.place)
2393 todes.foc.canloc.port = loc.can.port;
2394 todes.foc.canloc.addr = loc.can.addr;
2395 todes.foc.canloc.insideindex = eobrd_caninsideindex_first;
2401 todes.foc.canloc.port = loc.extcan.port;
2402 todes.foc.canloc.addr = loc.extcan.addr;
2403 todes.foc.canloc.insideindex = loc.extcan.index;
2404 if(eobrd_caninsideindex_first != todes.foc.canloc.insideindex)
2406 yWarning() <<
"ServiceParser::parse_actuator_port():" <<
"in eomc_act_foc the location has an index different from eobrd_caninsideindex_first. For now we force to it, but correct xml file.";
2407 todes.foc.canloc.insideindex = eobrd_caninsideindex_first;
2417 else if(eomc_act_mc4 == type)
2420 todes.mc4.canloc.port = loc.extcan.port;
2421 todes.mc4.canloc.addr = loc.extcan.addr;
2422 todes.mc4.canloc.insideindex = loc.extcan.index;
2424 if(eobrd_caninsideindex_none == todes.foc.canloc.insideindex)
2426 yWarning() <<
"ServiceParser::parse_actuator_port():" <<
"in eomc_act_mc4 the location has an eobrd_caninsideindex_none. Correct xml file.";
2438 case eomc_act_advfoc:
2441 eOlocation_t loc {eobus_none, 0, 0};
2442 bool result =
convert(fromstring, loc, formaterror);
2446 yWarning() <<
"ServiceParser::parse_actuator_port():" << t <<
"is not a legal string for a eOlocation_t required by eomc_act_advfoc";
2457 todes.gen.location = loc;
2468 bool ServiceParser::convert(std::string
const &fromstring, eOmc_actuator_t &toactuatortype,
bool &formaterror)
2470 const char *t = fromstring.c_str();
2471 eObool_t usecompactstring = eobool_false;
2472 toactuatortype = eomc_string2actuator(t, usecompactstring);
2474 if(eomc_act_unknown == toactuatortype)
2476 usecompactstring = eobool_true;
2477 toactuatortype = eomc_string2actuator(t, usecompactstring);
2480 if(eomc_act_unknown == toactuatortype)
2482 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eOmc_actuator_t";
2491 bool ServiceParser::convert(std::string
const &fromstring, eOmc_position_t &toposition,
bool &formaterror)
2493 const char *t = fromstring.c_str();
2494 eObool_t usecompactstring = eobool_false;
2495 toposition = eomc_string2position(t, usecompactstring);
2497 if(eomc_pos_unknown == toposition)
2499 usecompactstring = eobool_true;
2500 toposition = eomc_string2position(t, usecompactstring);
2503 if(eomc_pos_unknown == toposition)
2505 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eOmc_position_t";
2517 const char *tt = fromstring.c_str();
2518 char prefix[16] = {0};
2519 sscanf(tt,
"%5c", prefix);
2521 if(0 != strcmp(prefix,
"CONN:"))
2523 yWarning() <<
"ServiceParser::convert():" << tt <<
"is not a legal string for eObrd_connector_t because it must begin with CONN:";
2529 const char *t = &tt[5];
2531 eObool_t usecompactstring = eobool_false;
2532 toconnector = eoboards_string2connector(t, usecompactstring);
2534 if(eobrd_conn_unknown == toconnector)
2536 usecompactstring = eobool_true;
2537 toconnector = eoboards_string2connector(t, usecompactstring);
2540 if(eobrd_conn_unknown == toconnector)
2542 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eObrd_connector_t";
2554 const char *tt = fromstring.c_str();
2555 char prefix[16] = {0};
2556 sscanf(tt,
"%5c", prefix);
2558 if(0 != strcmp(prefix,
"MAIS:"))
2560 yWarning() <<
"ServiceParser::parse_mais():" << tt <<
"is not a legal string for eObrd_portmais_t because it must begin with MAIS:";
2566 const char *t = &tt[5];
2568 eObool_t usecompactstring = eobool_false;
2569 toportmais = eoboards_string2portmais(t, usecompactstring);
2571 if(eobrd_portmais_unknown == toportmais)
2573 usecompactstring = eobool_true;
2574 toportmais = eoboards_string2portmais(t, usecompactstring);
2577 if(eobrd_portmais_unknown == toportmais)
2579 yWarning() <<
"ServiceParser::parse_mais():" << t <<
"is not a legal string for eObrd_portmais_t";
2592 const char *tt = fromstring.c_str();
2593 char prefix[16] = {0};
2594 sscanf(tt,
"%4c", prefix);
2596 const char *t=
nullptr;
2598 if(0 != strcmp(prefix,
"PSC:"))
2603 eObool_t usecompactstring = eobool_false;
2604 toportpsc = eoboards_string2portpsc(t, usecompactstring);
2606 if(eobrd_portpsc_unknown == toportpsc)
2608 usecompactstring = eobool_true;
2609 toportpsc = eoboards_string2portpsc(t, usecompactstring);
2612 if(eobrd_portpsc_unknown == toportpsc)
2614 yWarning() <<
"ServiceParser::parse_psc(): " << t <<
" is not a legal string for eObrd_portpsc_t";
2626 const char *tt = fromstring.c_str();
2627 char prefix[16] = {0};
2628 sscanf(tt,
"%4c", prefix);
2630 const char *t=
nullptr;
2632 if(0 != strcmp(prefix,
"POS:"))
2637 eObool_t usecompactstring = eobool_false;
2638 toportpos = eoboards_string2portpos(t, usecompactstring);
2640 if(eobrd_portpos_unknown == toportpos)
2642 usecompactstring = eobool_true;
2643 toportpos = eoboards_string2portpos(t, usecompactstring);
2646 if(eobrd_portpos_unknown == toportpos)
2648 yWarning() <<
"ServiceParser::parse_POS_port(): " << t <<
" is not a legal string for eObrd_portpos_t";
2660 const char *tt = fromstring.c_str();
2661 char prefix[16] = {0};
2662 sscanf(tt,
"%5c", prefix);
2664 if(0 != strcmp(prefix,
"TYPE:"))
2666 yWarning() <<
"ServiceParser::convert():" << tt <<
"is not a legal string for eoas_pos_TYPE_t because it must begin with TYPE:";
2672 const char *t = &tt[5];
2674 eObool_t usecompactstring = eobool_false;
2675 type = eoas_string2postype(t, usecompactstring);
2677 if(eoas_pos_TYPE_unknown == type)
2679 usecompactstring = eobool_true;
2680 type = eoas_string2postype(t, usecompactstring);
2683 if(eoas_pos_TYPE_unknown == type)
2685 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eoas_pos_TYPE_t";
2695 const char *tt = fromstring.c_str();
2696 char prefix[16] = {0};
2697 sscanf(tt,
"%4c", prefix);
2699 if(0 != strcmp(prefix,
"ROT:"))
2701 yWarning() <<
"ServiceParser::convert():" << tt <<
"is not a legal string for eoas_pos_ROT_t because it must begin with ROT:";
2707 const char *t = &tt[4];
2709 eObool_t usecompactstring = eobool_false;
2710 rot = eoas_string2posrot(t, usecompactstring);
2712 yDebug() << t <<
" yyyyyyyyyyyyyyyyyyy " << rot;
2715 if(eoas_pos_ROT_unknown == rot)
2717 usecompactstring = eobool_true;
2718 rot = eoas_string2posrot(t, usecompactstring);
2719 yDebug() << t <<
" xxxxxxxxxxxxxxxxxxx " << rot;
2722 if(eoas_pos_ROT_unknown == rot)
2724 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eoas_pos_ROT_t";
2735 bool r = parse_port_conn(fromstring, brd,
tmp, formaterror);
2736 conn = r ?
static_cast<eObrd_connector_t
>(
tmp) : eobrd_conn_unknown;
2740 bool ServiceParser::convert(std::string
const &fromstring, eOmc_encoder_t &toencodertype,
bool &formaterror)
2742 const char *t = fromstring.c_str();
2743 eObool_t usecompactstring = eobool_false;
2744 toencodertype = eomc_string2encoder(t, usecompactstring);
2746 if(eomc_enc_unknown == toencodertype)
2748 usecompactstring = eobool_true;
2749 toencodertype = eomc_string2encoder(t, usecompactstring);
2752 if(eomc_enc_unknown == toencodertype)
2754 yWarning() <<
"ServiceParser::convert():" << t <<
"is not a legal string for eOmc_encoder_t";
2763 bool ServiceParser::check_motion(Searchable &config)
2765 bool formaterror =
false;
2777 const bool itisOKifwedontfindtheXMLgroup =
true;
2779 Bottle b_SERVICE(config.findGroup(
"SERVICE"));
2780 if(b_SERVICE.isNull())
2782 if(
false == itisOKifwedontfindtheXMLgroup)
2784 yError() <<
"ServiceParser::check_motion() cannot find SERVICE group";
2789 yWarning() <<
"ServiceParser::check_motion() cannot find SERVICE group, but we are in permissive mode, hence we ask the ETH board to config itself according to its IP address";
2790 mc_service.type = eomn_serv_MC_generic;
2797 if(
false == b_SERVICE.check(
"type"))
2799 if(
false == itisOKifwedontfindtheXMLgroup)
2801 yError() <<
"ServiceParser::check_motion() cannot find SERVICE.type";
2806 yWarning() <<
"ServiceParser::check_motion() cannot find SERVICE.type, but we are in permissive mode, hence we ask the ETH board to config itself according to its IP address";
2807 mc_service.type = eomn_serv_MC_generic;
2812 Bottle b_type(b_SERVICE.find(
"type").asString());
2813 if(
false ==
convert(b_type.toString(), mc_service.type, formaterror))
2815 yError() <<
"ServiceParser::check_motion() has found unknown SERVICE.type = " << b_type.toString();
2819 if(eomn_serv_MC_generic == mc_service.type)
2821 yWarning() <<
"ServiceParser::check_motion() detects SERVICE.type = eomn_serv_MC_generic.. hence we ask the ETH board to config itself according to its IP address";
2827 Bottle b_PROPERTIES = Bottle(b_SERVICE.findGroup(
"PROPERTIES"));
2828 if(b_PROPERTIES.isNull())
2830 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES";
2837 Bottle b_PROPERTIES_ETHBOARD = Bottle(b_PROPERTIES.findGroup(
"ETHBOARD"));
2838 bool has_PROPERTIES_ETHBOARD = !b_PROPERTIES_ETHBOARD.isNull();
2840 Bottle b_PROPERTIES_MAIS = Bottle(b_PROPERTIES.findGroup(
"MAIS"));
2841 bool has_PROPERTIES_MAIS = !b_PROPERTIES_MAIS.isNull();
2843 Bottle b_PROPERTIES_PSC = Bottle(b_PROPERTIES.findGroup(
"PSC"));
2844 bool has_PROPERTIES_PSC = !b_PROPERTIES_PSC.isNull();
2846 Bottle b_PROPERTIES_POS = Bottle(b_PROPERTIES.findGroup(
"POS"));
2847 bool has_PROPERTIES_POS = !b_PROPERTIES_POS.isNull();
2849 Bottle b_PROPERTIES_MC4 = Bottle(b_PROPERTIES.findGroup(
"MC4"));
2850 bool has_PROPERTIES_MC4 = !b_PROPERTIES_MC4.isNull();
2852 Bottle b_PROPERTIES_CANBOARDS = Bottle(b_PROPERTIES.findGroup(
"CANBOARDS"));
2853 bool has_PROPERTIES_CANBOARDS = !b_PROPERTIES_CANBOARDS.isNull();
2855 Bottle b_PROPERTIES_JOINTMAPPING = Bottle(b_PROPERTIES.findGroup(
"JOINTMAPPING"));
2856 bool has_PROPERTIES_JOINTMAPPING = !b_PROPERTIES_JOINTMAPPING.isNull();
2858 Bottle b_PROPERTIES_DIAGNOSTICS = Bottle(b_PROPERTIES.findGroup(
"DIAGNOSTICS"));
2859 bool has_PROPERTIES_DIAGNOSTICS = !b_PROPERTIES_DIAGNOSTICS.isNull();
2865 bool itisoksofar =
false;
2866 switch(mc_service.type)
2868 case eomn_serv_MC_foc:
2873 if(
false == has_PROPERTIES_ETHBOARD)
2875 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.ETHBOARD for type" << eomn_servicetype2string(mc_service.type);
2876 itisoksofar =
false;
2879 if(
false == has_PROPERTIES_CANBOARDS)
2881 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS for type" << eomn_servicetype2string(mc_service.type);
2882 itisoksofar =
false;
2885 if(
false == has_PROPERTIES_JOINTMAPPING)
2887 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING for type" << eomn_servicetype2string(mc_service.type);
2888 itisoksofar =
false;
2894 case eomn_serv_MC_mc4plus:
2900 if(
false == has_PROPERTIES_ETHBOARD)
2902 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.ETHBOARD for type" << eomn_servicetype2string(mc_service.type);
2903 itisoksofar =
false;
2906 if(
false == has_PROPERTIES_JOINTMAPPING)
2908 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING for type" << eomn_servicetype2string(mc_service.type);
2909 itisoksofar =
false;
2915 case eomn_serv_MC_mc4plusmais:
2921 if(
false == has_PROPERTIES_ETHBOARD)
2923 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.ETHBOARD for type" << eomn_servicetype2string(mc_service.type);
2924 itisoksofar =
false;
2927 if(
false == has_PROPERTIES_CANBOARDS)
2929 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS for type" << eomn_servicetype2string(mc_service.type);
2930 itisoksofar =
false;
2933 if(
false == has_PROPERTIES_MAIS)
2935 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MAIS for type" << eomn_servicetype2string(mc_service.type);
2936 itisoksofar =
false;
2939 if(
false == has_PROPERTIES_JOINTMAPPING)
2941 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING for type" << eomn_servicetype2string(mc_service.type);
2942 itisoksofar =
false;
2948 case eomn_serv_MC_mc4:
2954 if(
false == has_PROPERTIES_ETHBOARD)
2956 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.ETHBOARD for type" << eomn_servicetype2string(mc_service.type);
2957 itisoksofar =
false;
2960 if(
false == has_PROPERTIES_CANBOARDS)
2962 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS for type" << eomn_servicetype2string(mc_service.type);
2963 itisoksofar =
false;
2966 if(
false == has_PROPERTIES_MC4)
2968 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MC4 for type" << eomn_servicetype2string(mc_service.type);
2969 itisoksofar =
false;
2972 if(
false == has_PROPERTIES_MAIS)
2974 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MAIS for type" << eomn_servicetype2string(mc_service.type);
2975 itisoksofar =
false;
2980 case eomn_serv_MC_mc2pluspsc:
2986 if(
false == has_PROPERTIES_ETHBOARD)
2988 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.ETHBOARD for type" << eomn_servicetype2string(mc_service.type);
2989 itisoksofar =
false;
2992 if(
false == has_PROPERTIES_CANBOARDS)
2994 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS for type" << eomn_servicetype2string(mc_service.type);
2995 itisoksofar =
false;
2998 if(
false == has_PROPERTIES_PSC)
3000 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.PSC for type" << eomn_servicetype2string(mc_service.type);
3001 itisoksofar =
false;
3004 if(
false == has_PROPERTIES_JOINTMAPPING)
3006 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING for type" << eomn_servicetype2string(mc_service.type);
3007 itisoksofar =
false;
3014 case eomn_serv_MC_mc4plusfaps:
3020 if(
false == has_PROPERTIES_ETHBOARD)
3022 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.ETHBOARD for type" << eomn_servicetype2string(mc_service.type);
3023 itisoksofar =
false;
3026 if(
false == has_PROPERTIES_CANBOARDS)
3028 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS for type" << eomn_servicetype2string(mc_service.type);
3029 itisoksofar =
false;
3032 if(
false == has_PROPERTIES_POS)
3034 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.POS for type" << eomn_servicetype2string(mc_service.type);
3035 itisoksofar =
false;
3038 if(
false == has_PROPERTIES_JOINTMAPPING)
3040 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING for type" << eomn_servicetype2string(mc_service.type);
3041 itisoksofar =
false;
3047 case eomn_serv_MC_advfoc:
3053 if(
false == has_PROPERTIES_ETHBOARD)
3055 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.ETHBOARD for type" << eomn_servicetype2string(mc_service.type);
3056 itisoksofar =
false;
3059 if(
false == has_PROPERTIES_CANBOARDS)
3061 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS for type" << eomn_servicetype2string(mc_service.type);
3062 itisoksofar =
false;
3065 if(
false == has_PROPERTIES_JOINTMAPPING)
3067 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING for type" << eomn_servicetype2string(mc_service.type);
3068 itisoksofar =
false;
3075 yError() <<
"ServiceParser::check_motion() has found an unknown type" << eomn_servicetype2string(mc_service.type);
3076 itisoksofar =
false;
3080 if(
false == itisoksofar)
3082 yError() <<
"ServiceParser::check_motion() detected missing groups in PROPERTIES";
3088 if(
true == has_PROPERTIES_ETHBOARD)
3092 Bottle b_PROPERTIES_ETHBOARD_type = b_PROPERTIES_ETHBOARD.findGroup(
"type");
3093 if(b_PROPERTIES_ETHBOARD_type.isNull())
3095 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.ETHBOARD.type";
3100 int numofethboards = b_PROPERTIES_ETHBOARD_type.size() - 1;
3101 if(1 != numofethboards)
3103 yError() <<
"ServiceParser::check_motion() PROPERTIES.ETHBOARD.type must have one board only";
3106 if(
false ==
convert(b_PROPERTIES_ETHBOARD_type.get(1).asString(), mc_service.properties.ethboardtype, formaterror))
3108 yError() <<
"ServiceParser::check_motion() has found unknown SERVICE.PROPERTIES.ETHBOARD.type = " << b_PROPERTIES_ETHBOARD_type.get(1).asString();
3115 if(
true == has_PROPERTIES_CANBOARDS)
3119 Bottle b_PROPERTIES_CANBOARDS_type = b_PROPERTIES_CANBOARDS.findGroup(
"type");
3120 if(b_PROPERTIES_CANBOARDS_type.isNull())
3122 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS.type";
3125 Bottle b_PROPERTIES_CANBOARDS_PROTOCOL = Bottle(b_PROPERTIES_CANBOARDS.findGroup(
"PROTOCOL"));
3126 if(b_PROPERTIES_CANBOARDS_PROTOCOL.isNull())
3128 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS.PROTOCOL";
3131 Bottle b_PROPERTIES_CANBOARDS_PROTOCOL_major = Bottle(b_PROPERTIES_CANBOARDS_PROTOCOL.findGroup(
"major"));
3132 if(b_PROPERTIES_CANBOARDS_PROTOCOL_major.isNull())
3134 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS.PROTOCOL.major";
3137 Bottle b_PROPERTIES_CANBOARDS_PROTOCOL_minor = Bottle(b_PROPERTIES_CANBOARDS_PROTOCOL.findGroup(
"minor"));
3138 if(b_PROPERTIES_CANBOARDS_PROTOCOL_minor.isNull())
3140 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS.PROTOCOL.minor";
3143 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE = Bottle(b_PROPERTIES_CANBOARDS.findGroup(
"FIRMWARE"));
3144 if(b_PROPERTIES_CANBOARDS_FIRMWARE.isNull())
3146 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS.FIRMWARE";
3149 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE_major = Bottle(b_PROPERTIES_CANBOARDS_FIRMWARE.findGroup(
"major"));
3150 if(b_PROPERTIES_CANBOARDS_FIRMWARE_major.isNull())
3152 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS.FIRMWARE.major";
3155 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE_minor = Bottle(b_PROPERTIES_CANBOARDS_FIRMWARE.findGroup(
"minor"));
3156 if(b_PROPERTIES_CANBOARDS_FIRMWARE_minor.isNull())
3158 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS.FIRMWARE.minor";
3161 Bottle b_PROPERTIES_CANBOARDS_FIRMWARE_build = Bottle(b_PROPERTIES_CANBOARDS_FIRMWARE.findGroup(
"build"));
3162 if(b_PROPERTIES_CANBOARDS_FIRMWARE_build.isNull())
3164 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.CANBOARDS.FIRMWARE.build";
3168 size_t tmp = b_PROPERTIES_CANBOARDS_type.size();
3169 size_t numboards = (0 ==
tmp) ? 0 : (
tmp - 1);
3172 if( (
tmp != b_PROPERTIES_CANBOARDS_PROTOCOL_major.size()) ||
3173 (
tmp != b_PROPERTIES_CANBOARDS_PROTOCOL_minor.size()) ||
3174 (
tmp != b_PROPERTIES_CANBOARDS_FIRMWARE_major.size()) ||
3175 (
tmp != b_PROPERTIES_CANBOARDS_FIRMWARE_minor.size()) ||
3176 (
tmp != b_PROPERTIES_CANBOARDS_FIRMWARE_build.size())
3179 yError() <<
"ServiceParser::check_motion() in PROPERTIES.CANBOARDS some params have inconsistent lengths";
3184 mc_service.properties.canboards.resize(0);
3186 formaterror =
false;
3187 for(
size_t i=0; i<numboards; i++)
3191 convert(b_PROPERTIES_CANBOARDS_type.get(i+1).asString(), item.
type, formaterror);
3192 convert(b_PROPERTIES_CANBOARDS_PROTOCOL_major.get(i+1).asInt32(), item.
protocol.major, formaterror);
3193 convert(b_PROPERTIES_CANBOARDS_PROTOCOL_minor.get(i+1).asInt32(), item.
protocol.minor, formaterror);
3195 convert(b_PROPERTIES_CANBOARDS_FIRMWARE_major.get(i+1).asInt32(), item.
firmware.major, formaterror);
3196 convert(b_PROPERTIES_CANBOARDS_FIRMWARE_minor.get(i+1).asInt32(), item.
firmware.minor, formaterror);
3197 convert(b_PROPERTIES_CANBOARDS_FIRMWARE_build.get(i+1).asInt32(), item.
firmware.build, formaterror);
3199 mc_service.properties.canboards.push_back(item);
3205 if(
true == formaterror)
3207 yError() <<
"ServiceParser::check_motion() has detected an illegal format for some of the params of PROPERTIES.CANBOARDS some param has inconsistent length";
3214 if(
true == has_PROPERTIES_MAIS)
3218 Bottle b_PROPERTIES_MAIS_location = b_PROPERTIES_MAIS.findGroup(
"location");
3219 if(b_PROPERTIES_MAIS_location.isNull())
3221 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MAIS.location";
3225 int tmp = b_PROPERTIES_MAIS_location.size();
3226 int numboards =
tmp - 1;
3231 yError() <<
"ServiceParser::check_motion() in PROPERTIES.MAIS.location must contain one item only and it has:" << numboards;
3235 formaterror =
false;
3236 eObrd_location_t loc;
3237 if(
false ==
convert(b_PROPERTIES_MAIS_location.get(1).asString(), loc, formaterror))
3239 yError() <<
"ServiceParser::check_motion() has detected an illegal format for SERVICE.PROPERTIES.MAIS.location";
3243 if(eobrd_place_can == loc.any.place)
3245 mc_service.properties.maislocation.port = loc.can.port;
3246 mc_service.properties.maislocation.addr = loc.can.addr;
3247 mc_service.properties.maislocation.insideindex = eobrd_caninsideindex_none;
3249 else if(eobrd_place_extcan == loc.any.place)
3251 mc_service.properties.maislocation.port = loc.extcan.port;
3252 mc_service.properties.maislocation.addr = loc.extcan.addr;
3253 mc_service.properties.maislocation.insideindex = eobrd_caninsideindex_none;
3257 yError() <<
"ServiceParser::check_motion() has detected an illegal format for SERVICE.PROPERTIES.MAIS.location. it must be either can or extcan";
3264 if(
true == has_PROPERTIES_MC4)
3270 Bottle b_PROPERTIES_MC4_SHIFTS = Bottle(b_PROPERTIES_MC4.findGroup(
"SHIFTS"));
3271 if(b_PROPERTIES_MC4_SHIFTS.isNull())
3273 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MC4.SHIFTS";
3277 Bottle b_PROPERTIES_MC4_SHIFTS_velocity = Bottle(b_PROPERTIES_MC4_SHIFTS.findGroup(
"velocity"));
3278 if(b_PROPERTIES_MC4_SHIFTS_velocity.isNull())
3280 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MC4.SHIFTS.velocity";
3283 Bottle b_PROPERTIES_MC4_SHIFTS_estimJointVelocity = Bottle(b_PROPERTIES_MC4_SHIFTS.findGroup(
"estimJointVelocity"));
3284 if(b_PROPERTIES_MC4_SHIFTS_estimJointVelocity.isNull())
3286 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MC4.SHIFTS.estimJointVelocity";
3289 Bottle b_PROPERTIES_MC4_SHIFTS_estimJointAcceleration = Bottle(b_PROPERTIES_MC4_SHIFTS.findGroup(
"estimJointAcceleration"));
3290 if(b_PROPERTIES_MC4_SHIFTS_estimJointAcceleration.isNull())
3292 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MC4.SHIFTS.estimJointAcceleration";
3295 Bottle b_PROPERTIES_MC4_SHIFTS_estimMotorVelocity = Bottle(b_PROPERTIES_MC4_SHIFTS.findGroup(
"estimMotorVelocity"));
3296 if(b_PROPERTIES_MC4_SHIFTS_estimMotorVelocity.isNull())
3298 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MC4.SHIFTS.estimMotorVelocity";
3301 Bottle b_PROPERTIES_MC4_SHIFTS_estimMotorAcceleration = Bottle(b_PROPERTIES_MC4_SHIFTS.findGroup(
"estimMotorAcceleration"));
3302 if(b_PROPERTIES_MC4_SHIFTS_estimMotorAcceleration.isNull())
3304 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MC4.SHIFTS.estimMotorAcceleration";
3308 Bottle b_PROPERTIES_MC4_BROADCASTPOLICY = Bottle(b_PROPERTIES_MC4.findGroup(
"BROADCASTPOLICY"));
3309 if(b_PROPERTIES_MC4_BROADCASTPOLICY.isNull())
3311 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MC4.BROADCASTPOLICY";
3315 Bottle b_PROPERTIES_MC4_BROADCASTPOLICY_enable = Bottle(b_PROPERTIES_MC4_BROADCASTPOLICY.findGroup(
"enable"));
3316 if(b_PROPERTIES_MC4_BROADCASTPOLICY_enable.isNull())
3318 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.MC4.BROADCASTPOLICY.enable";
3339 if(
true ==
convert(b_PROPERTIES_MC4_SHIFTS_velocity.get(1).asInt32(), value, formaterror))
3341 mc_service.properties.mc4shifts.velocity = value;
3343 if(
true ==
convert(b_PROPERTIES_MC4_SHIFTS_estimJointVelocity.get(1).asInt32(), value, formaterror))
3347 yError() <<
"ServiceParser::check_motion() manages values of PROPERTIES.MC4.SHIFTS.estim* only in range [0, 15]. read value =" << value;
3350 mc_service.properties.mc4shifts.estimJointVelocity = value;
3352 if(
true ==
convert(b_PROPERTIES_MC4_SHIFTS_estimJointAcceleration.get(1).asInt32(), value, formaterror))
3356 yError() <<
"ServiceParser::check_motion() manages values of PROPERTIES.MC4.SHIFTS.estim* only in range [0, 15]. read value =" << value;
3359 mc_service.properties.mc4shifts.estimJointAcceleration = value;
3361 if(
true ==
convert(b_PROPERTIES_MC4_SHIFTS_estimMotorVelocity.get(1).asInt32(), value, formaterror))
3365 yError() <<
"ServiceParser::check_motion() manages values of PROPERTIES.MC4.SHIFTS.estim* only in range [0, 15]. read value =" << value;
3368 mc_service.properties.mc4shifts.estimMotorVelocity = value;
3370 if(
true ==
convert(b_PROPERTIES_MC4_SHIFTS_estimMotorAcceleration.get(1).asInt32(), value, formaterror))
3374 yError() <<
"ServiceParser::check_motion() manages values of PROPERTIES.MC4.SHIFTS.estim* only in range [0, 15]. read value =" << value;
3377 mc_service.properties.mc4shifts.estimMotorAcceleration = value;
3382 int tmp = b_PROPERTIES_MC4_BROADCASTPOLICY_enable.size();
3383 int numofenables =
tmp - 1;
3385 mc_service.properties.mc4broadcasts.resize(0);
3386 for(
int i=0; i<numofenables; i++)
3389 eOmc_mc4broadcast_t item = eomc_mc4broadcast_unknown;
3390 const char *str = b_PROPERTIES_MC4_BROADCASTPOLICY_enable.get(i+1).asString().c_str();
3393 if(eomc_mc4broadcast_unknown == (item = eomc_string2mc4broadcast(str, eobool_true)))
3395 item = eomc_string2mc4broadcast(str, eobool_false);
3398 if((eomc_mc4broadcast_unknown != item) && (eomc_mc4broadcast_none != item))
3400 mc_service.properties.mc4broadcasts.push_back(item);
3449 if(
true == has_PROPERTIES_PSC)
3453 Bottle b_PROPERTIES_PSC_location = b_PROPERTIES_PSC.findGroup(
"location");
3454 if(b_PROPERTIES_PSC_location.isNull())
3456 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.PSC.location";
3460 int tmp = b_PROPERTIES_PSC_location.size();
3461 int numboards =
tmp - 1;
3464 if(eOas_psc_boards_maxnumber != numboards)
3466 yError() <<
"ServiceParser::check_motion() in PROPERTIES.PSC.location must contain three items and it has:" << numboards;
3470 mc_service.properties.psclocations.resize(3);
3471 for(
int i=0; i<3; i++)
3473 eObrd_location_t loc;
3474 formaterror =
false;
3475 if(
false ==
convert(b_PROPERTIES_PSC_location.get(1+i).asString(), loc, formaterror))
3477 yError() <<
"ServiceParser::check_motion() has detected an illegal format for SERVICE.PROPERTIES.PSC.location";
3481 if(eobrd_place_can == loc.any.place)
3483 mc_service.properties.psclocations[i].port = loc.can.port;
3484 mc_service.properties.psclocations[i].addr = loc.can.addr;
3485 mc_service.properties.psclocations[i].insideindex = eobrd_caninsideindex_none;
3488 else if(eobrd_place_extcan == loc.any.place)
3490 mc_service.properties.psclocations[i].port = loc.extcan.port;
3491 mc_service.properties.psclocations[i].addr = loc.extcan.addr;
3492 mc_service.properties.psclocations[i].insideindex = eobrd_caninsideindex_none;
3496 yError() <<
"ServiceParser::check_motion() has detected an illegal format for SERVICE.PROPERTIES.PSC.location. it must be either can or extcan";
3504 if(
true == has_PROPERTIES_POS)
3508 Bottle b_PROPERTIES_POS_location = b_PROPERTIES_POS.findGroup(
"location");
3509 if(b_PROPERTIES_POS_location.isNull())
3511 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.POS.location";
3515 int tmp = b_PROPERTIES_POS_location.size();
3516 int numboards =
tmp - 1;
3519 constexpr uint8_t wantedboards = 1;
3520 if(wantedboards != numboards)
3522 yError() <<
"ServiceParser::check_motion() in PROPERTIES.POS.location must contain " << wantedboards <<
" items and it has:" << numboards;
3526 mc_service.properties.poslocations.resize(wantedboards);
3527 for(
int i=0; i<wantedboards; i++)
3529 eObrd_location_t loc;
3530 formaterror =
false;
3531 if(
false ==
convert(b_PROPERTIES_POS_location.get(1+i).asString(), loc, formaterror))
3533 yError() <<
"ServiceParser::check_motion() has detected an illegal format for SERVICE.PROPERTIES.POS.location";
3537 if(eobrd_place_can == loc.any.place)
3539 mc_service.properties.poslocations[i].port = loc.can.port;
3540 mc_service.properties.poslocations[i].addr = loc.can.addr;
3541 mc_service.properties.poslocations[i].insideindex = eobrd_caninsideindex_none;
3544 else if(eobrd_place_extcan == loc.any.place)
3546 yError() <<
"ServiceParser::check_motion() has detected an incorrect format for SERVICE.PROPERTIES.POS.location. it must be either can, not extcan";
3547 mc_service.properties.poslocations[i].port = loc.extcan.port;
3548 mc_service.properties.poslocations[i].addr = loc.extcan.addr;
3549 mc_service.properties.poslocations[i].insideindex = eobrd_caninsideindex_none;
3553 yError() <<
"ServiceParser::check_motion() has detected an illegal format for SERVICE.PROPERTIES.POS.location. it must be can";
3560 if(
true == has_PROPERTIES_JOINTMAPPING)
3565 Bottle b_PROPERTIES_JOINTMAPPING_ACTUATOR = Bottle(b_PROPERTIES_JOINTMAPPING.findGroup(
"ACTUATOR"));
3566 if(b_PROPERTIES_JOINTMAPPING_ACTUATOR.isNull())
3568 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ACTUATOR";
3572 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER1 = Bottle(b_PROPERTIES_JOINTMAPPING.findGroup(
"ENCODER1"));
3573 if(b_PROPERTIES_JOINTMAPPING_ENCODER1.isNull())
3575 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER1";
3579 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER2 = Bottle(b_PROPERTIES_JOINTMAPPING.findGroup(
"ENCODER2"));
3580 if(b_PROPERTIES_JOINTMAPPING_ENCODER2.isNull())
3582 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER2";
3588 Bottle b_PROPERTIES_JOINTMAPPING_ACTUATOR_type = Bottle(b_PROPERTIES_JOINTMAPPING_ACTUATOR.findGroup(
"type"));
3589 if(b_PROPERTIES_JOINTMAPPING_ACTUATOR_type.isNull())
3591 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ACTUATOR.type";
3595 Bottle b_PROPERTIES_JOINTMAPPING_ACTUATOR_onboard = Bottle(b_PROPERTIES_JOINTMAPPING_ACTUATOR.findGroup(
"onboard"));
3598 Bottle b_PROPERTIES_JOINTMAPPING_ACTUATOR_port = Bottle(b_PROPERTIES_JOINTMAPPING_ACTUATOR.findGroup(
"port"));
3599 if(b_PROPERTIES_JOINTMAPPING_ACTUATOR_port.isNull())
3601 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ACTUATOR.port";
3605 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER1_type = Bottle(b_PROPERTIES_JOINTMAPPING_ENCODER1.findGroup(
"type"));
3606 if(b_PROPERTIES_JOINTMAPPING_ENCODER1_type.isNull())
3608 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER1.type";
3611 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER1_port = Bottle(b_PROPERTIES_JOINTMAPPING_ENCODER1.findGroup(
"port"));
3612 if(b_PROPERTIES_JOINTMAPPING_ENCODER1_port.isNull())
3614 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER1.port";
3617 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER1_position = Bottle(b_PROPERTIES_JOINTMAPPING_ENCODER1.findGroup(
"position"));
3618 if(b_PROPERTIES_JOINTMAPPING_ENCODER1_position.isNull())
3620 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER1.position";
3623 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER1_resolution = Bottle(b_PROPERTIES_JOINTMAPPING_ENCODER1.findGroup(
"resolution"));
3624 if(b_PROPERTIES_JOINTMAPPING_ENCODER1_resolution.isNull())
3626 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER1.resolution";
3629 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER1_tolerance = Bottle(b_PROPERTIES_JOINTMAPPING_ENCODER1.findGroup(
"tolerance"));
3630 if(b_PROPERTIES_JOINTMAPPING_ENCODER1_tolerance.isNull())
3632 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER1.tolerance";
3638 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER2_type = Bottle(b_PROPERTIES_JOINTMAPPING_ENCODER2.findGroup(
"type"));
3639 if(b_PROPERTIES_JOINTMAPPING_ENCODER2_type.isNull())
3641 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER2.type";
3644 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER2_port = Bottle(b_PROPERTIES_JOINTMAPPING_ENCODER2.findGroup(
"port"));
3645 if(b_PROPERTIES_JOINTMAPPING_ENCODER2_port.isNull())
3647 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER2.port";
3650 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER2_position = Bottle(b_PROPERTIES_JOINTMAPPING_ENCODER2.findGroup(
"position"));
3651 if(b_PROPERTIES_JOINTMAPPING_ENCODER2_position.isNull())
3653 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER2.position";
3656 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER2_resolution = Bottle(b_PROPERTIES_JOINTMAPPING_ENCODER2.findGroup(
"resolution"));
3657 if(b_PROPERTIES_JOINTMAPPING_ENCODER2_resolution.isNull())
3659 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER2.resolution";
3662 Bottle b_PROPERTIES_JOINTMAPPING_ENCODER2_tolerance = Bottle(b_PROPERTIES_JOINTMAPPING_ENCODER2.findGroup(
"tolerance"));
3663 if(b_PROPERTIES_JOINTMAPPING_ENCODER2_tolerance.isNull())
3665 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ENCODER2.tolerance";
3670 size_t tmp = b_PROPERTIES_JOINTMAPPING_ACTUATOR_type.size();
3671 if( (
tmp != b_PROPERTIES_JOINTMAPPING_ACTUATOR_port.size()) ||
3672 (
tmp != b_PROPERTIES_JOINTMAPPING_ENCODER1_type.size()) ||
3673 (
tmp != b_PROPERTIES_JOINTMAPPING_ENCODER1_port.size()) ||
3674 (
tmp != b_PROPERTIES_JOINTMAPPING_ENCODER1_position.size()) ||
3675 (
tmp != b_PROPERTIES_JOINTMAPPING_ENCODER1_resolution.size())||
3676 (
tmp != b_PROPERTIES_JOINTMAPPING_ENCODER1_tolerance.size()) ||
3677 (
tmp != b_PROPERTIES_JOINTMAPPING_ENCODER2_type.size()) ||
3678 (
tmp != b_PROPERTIES_JOINTMAPPING_ENCODER2_port.size()) ||
3679 (
tmp != b_PROPERTIES_JOINTMAPPING_ENCODER2_position.size()) ||
3680 (
tmp != b_PROPERTIES_JOINTMAPPING_ENCODER2_resolution.size()) ||
3681 (
tmp != b_PROPERTIES_JOINTMAPPING_ENCODER2_tolerance.size())
3684 yError() <<
"ServiceParser::check_motion() detected wrong number of columns somewhere inside PROPERTIES.JOINTMAPPING";
3689 mc_service.properties.numofjoints = (0 ==
tmp ) ? (0) : (
tmp-1);
3693 mc_service.properties.actuators.resize(0);
3694 mc_service.properties.encoder1s.resize(0);
3695 mc_service.properties.encoder2s.resize(0);
3697 if(eomn_serv_MC_mc4 == mc_service.type)
3699 mc_service.properties.mc4joints.resize(0);
3703 for(
int i=0; i<mc_service.properties.numofjoints; i++)
3708 bool formaterror =
false;
3710 eOmc_encoder_t enctype = eomc_enc_unknown;
3711 uint8_t encport = eobrd_port_unknown;
3712 eOmc_position_t encposition = eomc_pos_unknown;
3715 act.
type = eomc_act_unknown;
3716 act.
desc.pwm.port = eobrd_port_unknown;
3718 if(
false ==
convert(b_PROPERTIES_JOINTMAPPING_ACTUATOR_type.get(i+1).asString(), act.
type, formaterror))
3720 yError() <<
"ServiceParser::check_motion() PROPERTIES.JOINTMAPPING.actuator.type not valid for item" << i;
3724 if((eomn_serv_MC_mc4 == mc_service.type) && (eomc_act_mc4 != act.
type))
3726 yError() <<
"ServiceParser::check_motion() PROPERTIES.JOINTMAPPING.actuator.type should be mc4 with mc service of type eomn_serv_MC_mc4. Error in item" << i;
3730 if(
false == parse_actuator_port(b_PROPERTIES_JOINTMAPPING_ACTUATOR_port.get(i+1).asString(), mc_service.properties.ethboardtype, act.
type, act.
desc, formaterror))
3732 yError() <<
"ServiceParser::check_motion() PROPERTIES.JOINTMAPPING.actuator.port not valid for item" << i;
3736 if(eomn_serv_MC_mc4 == mc_service.type)
3738 eObrd_canlocation_t item;
3739 item.port = act.
desc.mc4.canloc.port;
3740 item.addr = act.
desc.mc4.canloc.addr;
3741 item.insideindex = act.
desc.mc4.canloc.insideindex;
3743 mc_service.properties.mc4joints.push_back(item);
3746 if(eomn_serv_MC_advfoc == mc_service.type)
3748 if(b_PROPERTIES_JOINTMAPPING_ACTUATOR_onboard.isNull())
3750 yError() <<
"ServiceParser::check_motion() cannot find PROPERTIES.JOINTMAPPING.ACTUATOR.onboard for eomn_serv_MC_advfoc";
3754 if(act.
type != eomc_act_advfoc)
3756 yError() <<
"ServiceParser::check_motion() detectde that PROPERTIES.JOINTMAPPING.ACTUATOR.type for eomn_serv_MC_advfoc id not advfoc";
3760 act.
advdescr.type = eomc_act_advfoc;
3762 eObrd_cantype_t bb {};
3763 convert(b_PROPERTIES_JOINTMAPPING_ACTUATOR_onboard.get(i+1).asString(), bb, formaterror);
3770 enc1.
desc.type = eomc_enc_unknown;
3771 enc1.
desc.port = eobrd_port_unknown;
3772 enc1.
desc.pos = eomc_pos_unknown;
3774 enctype = eomc_enc_unknown;
3775 if(
false ==
convert(b_PROPERTIES_JOINTMAPPING_ENCODER1_type.get(i+1).asString(), enctype, formaterror))
3777 yError() <<
"ServiceParser::check_motion() PROPERTIES.JOINTMAPPING.encoder1.type not valid for item" << i;
3780 enc1.
desc.type = enctype;
3788 encport = eobrd_port_unknown;
3789 if(
false == parse_encoder_port(b_PROPERTIES_JOINTMAPPING_ENCODER1_port.get(i+1).asString(), mc_service.properties.ethboardtype, enctype, encport, formaterror))
3791 yError() <<
"ServiceParser::check_motion() PROPERTIES.JOINTMAPPING.encoder1.port not valid for item" << i;
3794 enc1.
desc.port = encport;
3796 encposition = eomc_pos_unknown;
3797 if(
false ==
convert(b_PROPERTIES_JOINTMAPPING_ENCODER1_position.get(i+1).asString(), encposition, formaterror))
3799 yError() <<
"ServiceParser::check_motion() PROPERTIES.JOINTMAPPING.encoder1.position not valid for item" << i;
3802 enc1.
desc.pos = encposition;
3804 enc1.
resolution = b_PROPERTIES_JOINTMAPPING_ENCODER1_resolution.get(i+1).asInt32();
3806 enc1.
tolerance = b_PROPERTIES_JOINTMAPPING_ENCODER1_tolerance.get(i+1).asFloat64();
3812 enc2.
desc.type = eomc_enc_unknown;
3813 enc2.
desc.port = eobrd_port_unknown;
3814 enc2.
desc.pos = eomc_pos_unknown;
3816 enctype = eomc_enc_unknown;
3817 if(
false ==
convert(b_PROPERTIES_JOINTMAPPING_ENCODER2_type.get(i+1).asString(), enctype, formaterror))
3819 yError() <<
"ServiceParser::check_motion() PROPERTIES.JOINTMAPPING.encoder2.type not valid for item" << i;
3823 enc2.
desc.type = enctype;
3826 encport = eobrd_port_unknown;
3827 if(
false == parse_encoder_port(b_PROPERTIES_JOINTMAPPING_ENCODER2_port.get(i+1).asString(), mc_service.properties.ethboardtype, enctype, encport, formaterror))
3829 yError() <<
"ServiceParser::check_motion() PROPERTIES.JOINTMAPPING.encoder2.port not valid for item" << i;
3832 enc2.
desc.port = encport;
3834 encposition = eomc_pos_unknown;
3835 if(
false ==
convert(b_PROPERTIES_JOINTMAPPING_ENCODER2_position.get(i+1).asString(), encposition, formaterror))
3837 yError() <<
"ServiceParser::check_motion() PROPERTIES.JOINTMAPPING.encoder2.position not valid for item" << i;
3841 enc2.
desc.pos = encposition;
3843 enc2.
resolution = b_PROPERTIES_JOINTMAPPING_ENCODER2_resolution.get(i+1).asInt32();
3844 enc2.
tolerance = b_PROPERTIES_JOINTMAPPING_ENCODER2_tolerance.get(i+1).asFloat64();
3849 mc_service.properties.actuators.push_back(act);
3850 mc_service.properties.encoder1s.push_back(enc1);
3851 mc_service.properties.encoder2s.push_back(enc2);
3859 mc_service.diagconfig.mode = eomn_serv_diagn_mode_NONE;
3860 mc_service.diagconfig.par16 = 0;
3862 if(
true == has_PROPERTIES_DIAGNOSTICS)
3864 Bottle b_PROPERTIES_DIAGNOSTICS_mode = b_PROPERTIES_DIAGNOSTICS.findGroup(
"mode");
3865 Bottle b_PROPERTIES_DIAGNOSTICS_par16 = b_PROPERTIES_DIAGNOSTICS.findGroup(
"par16");
3866 if(!b_PROPERTIES_DIAGNOSTICS_mode.isNull() && !b_PROPERTIES_DIAGNOSTICS_par16.isNull())
3869 int n_type = b_PROPERTIES_DIAGNOSTICS_mode.size() - 1;
3870 int n_par16 = b_PROPERTIES_DIAGNOSTICS_par16.size() - 1;
3871 if((1 == n_type) && (1 == n_par16))
3873 eOmn_serv_diagn_mode_t dm = eomn_serv_diagn_mode_NONE;
3875 if(
false ==
convert(b_PROPERTIES_DIAGNOSTICS_mode.get(1).asString(), dm, formaterror))
3877 yWarning() <<
"ServiceParser::check_motion() has detected an illegal format for SERVICE.PROPERTIES.DIAGNOSTICS.mode. Using {eOmn_serv_diagn_mode_NONE, 0}";
3879 else if(!b_PROPERTIES_DIAGNOSTICS_par16.get(1).isInt32())
3881 yWarning() <<
"ServiceParser::check_motion() has detected an illegal format for SERVICE.PROPERTIES.DIAGNOSTICS.par16. Using {eOmn_serv_diagn_mode_NONE, 0}";
3885 par16 = b_PROPERTIES_DIAGNOSTICS_par16.get(1).asInt32();
3888 mc_service.diagconfig.mode = dm;
3889 mc_service.diagconfig.par16 =
static_cast<uint16_t
>(par16);
3891 yWarning() <<
"ServiceParser::check_motion() has detected some DIAGNOSTICS config for this MC service: mode = " << eomn_servicediagnmode2string(dm) <<
", par16 = " << mc_service.diagconfig.par16;
4031 if(
false == check_motion(config))
4033 yError() <<
"ServiceParser::parseService() gets same errors parsing SERVICE MC group";
4041 mcconfig.
ethservice.configuration.type = mc_service.type;
4042 mcconfig.
ethservice.configuration.diagnosticsmode = mc_service.diagconfig.mode;
4043 mcconfig.
ethservice.configuration.diagnosticsparam = mc_service.diagconfig.par16;
4045 switch(mc_service.type)
4047 case eomn_serv_MC_foc:
4049 eOmn_serv_config_data_mc_foc_t *data_mc = &(mcconfig.
ethservice.configuration.data.mc.foc_based);
4052 data_mc->version.firmware.major = mc_service.properties.canboards.at(0).firmware.major;
4053 data_mc->version.firmware.minor = mc_service.properties.canboards.at(0).firmware.minor;
4054 data_mc->version.firmware.build = mc_service.properties.canboards.at(0).firmware.build;
4055 data_mc->version.protocol.major = mc_service.properties.canboards.at(0).protocol.major;
4056 data_mc->version.protocol.minor = mc_service.properties.canboards.at(0).protocol.minor;
4059 data_mc->type = mc_service.properties.canboards.at(0).type;
4062 EOarray *arrayofjomos = eo_array_New(4,
sizeof(eOmc_jomo_descriptor_t), &data_mc->arrayofjomodescriptors);
4063 int numofjomos = mc_service.properties.numofjoints;
4065 for(
int i=0; i<numofjomos; i++)
4067 eOmc_jomo_descriptor_t jomodes = {};
4070 jomodes.actuator.foc.canloc.port = mc_service.properties.actuators[i].desc.foc.canloc.port;
4071 jomodes.actuator.foc.canloc.addr = mc_service.properties.actuators[i].desc.foc.canloc.addr;
4072 jomodes.actuator.foc.canloc.insideindex = eobrd_caninsideindex_first;
4075 jomodes.encoder1.type = mc_service.properties.encoder1s[i].desc.type;
4076 jomodes.encoder1.port = mc_service.properties.encoder1s[i].desc.port;
4077 jomodes.encoder1.pos = mc_service.properties.encoder1s[i].desc.pos;
4080 jomodes.encoder2.type = mc_service.properties.encoder2s[i].desc.type;
4081 jomodes.encoder2.port = mc_service.properties.encoder2s[i].desc.port;
4082 jomodes.encoder2.pos = mc_service.properties.encoder2s[i].desc.pos;
4084 eo_array_PushBack(arrayofjomos, &jomodes);
4099 case eomn_serv_MC_mc4:
4101 eOmn_serv_config_data_mc_mc4_t *data_mc = &(mcconfig.
ethservice.configuration.data.mc.mc4_based);
4104 bool mc4boardFound =
false;
4105 bool maisboardFound =
false;
4106 for(
size_t i=0; i<mc_service.properties.canboards.size(); i++)
4108 if(eobrd_cantype_mc4 == mc_service.properties.canboards[i].type)
4110 data_mc->mc4version.protocol = mc_service.properties.canboards[i].protocol;
4111 data_mc->mc4version.firmware = mc_service.properties.canboards[i].firmware;
4112 mc4boardFound =
true;
4114 else if(eobrd_cantype_mais == mc_service.properties.canboards[i].type)
4116 data_mc->mais.version.protocol = mc_service.properties.canboards[i].protocol;
4117 data_mc->mais.version.firmware = mc_service.properties.canboards[i].firmware;
4118 maisboardFound =
true;
4122 if((
false == maisboardFound) || (
false == mc4boardFound))
4124 yError() <<
"ServiceParser::parseService() gets same errors parsing SERVICE MC group for mc4: cannot find description of mc4 or mais board";
4134 data_mc->mc4shifts = mc_service.properties.mc4shifts;
4137 for(
int i=0; i<12; i++)
4139 data_mc->mc4joints[i] = mc_service.properties.mc4joints[i];
4144 data_mc->mais.canloc = mc_service.properties.maislocation;
4147 data_mc->broadcastflags = 0;
4148 for(
size_t i=0; i<mc_service.properties.mc4broadcasts.size(); i++)
4150 eOmc_mc4broadcast_t item = mc_service.properties.mc4broadcasts[i];
4151 if((eomc_mc4broadcast_none != item) && (eomc_mc4broadcast_unknown != item))
4153 eo_common_hlfword_bitset(&data_mc->broadcastflags, item);
4162 case eomn_serv_MC_mc4plus:
4164 eOmn_serv_config_data_mc_mc4plus_t *data_mc = &(mcconfig.
ethservice.configuration.data.mc.mc4plus_based);
4167 EOarray *arrayofjomos = eo_array_New(4,
sizeof(eOmc_jomo_descriptor_t), &data_mc->arrayofjomodescriptors);
4168 int numofjomos = mc_service.properties.numofjoints;
4170 for(
int i=0; i<numofjomos; i++)
4172 eOmc_jomo_descriptor_t jomodes = {};
4175 jomodes.actuator.pwm.port = mc_service.properties.actuators[i].desc.pwm.port;
4178 jomodes.encoder1.type = mc_service.properties.encoder1s[i].desc.type;
4179 jomodes.encoder1.port = mc_service.properties.encoder1s[i].desc.port;
4180 jomodes.encoder1.pos = mc_service.properties.encoder1s[i].desc.pos;
4183 jomodes.encoder2.type = mc_service.properties.encoder2s[i].desc.type;
4184 jomodes.encoder2.port = mc_service.properties.encoder2s[i].desc.port;
4185 jomodes.encoder2.pos = mc_service.properties.encoder2s[i].desc.pos;
4187 eo_array_PushBack(arrayofjomos, &jomodes);
4201 case eomn_serv_MC_mc4plusmais:
4203 eOmn_serv_config_data_mc_mc4plusmais_t *data_mc = &(mcconfig.
ethservice.configuration.data.mc.mc4plusmais_based);
4206 eOmn_serv_config_data_as_mais_t *mais = &data_mc->mais;
4208 mais->canloc.port = mc_service.properties.maislocation.port;
4209 mais->canloc.addr = mc_service.properties.maislocation.addr;
4210 mais->canloc.insideindex = mc_service.properties.maislocation.insideindex;
4212 mais->version.firmware.major = mc_service.properties.canboards.at(0).firmware.major;
4213 mais->version.firmware.minor = mc_service.properties.canboards.at(0).firmware.minor;
4214 mais->version.firmware.build = mc_service.properties.canboards.at(0).firmware.build;
4215 mais->version.protocol.major = mc_service.properties.canboards.at(0).protocol.major;
4216 mais->version.protocol.minor = mc_service.properties.canboards.at(0).protocol.minor;
4219 EOarray *arrayofjomos = eo_array_New(4,
sizeof(eOmc_jomo_descriptor_t), &data_mc->arrayofjomodescriptors);
4220 int numofjomos = mc_service.properties.numofjoints;
4222 for(
int i=0; i<numofjomos; i++)
4224 eOmc_jomo_descriptor_t jomodes = {};
4227 jomodes.actuator.pwm.port = mc_service.properties.actuators[i].desc.pwm.port;
4230 jomodes.encoder1.type = mc_service.properties.encoder1s[i].desc.type;
4231 jomodes.encoder1.port = mc_service.properties.encoder1s[i].desc.port;
4232 jomodes.encoder1.pos = mc_service.properties.encoder1s[i].desc.pos;
4235 jomodes.encoder2.type = mc_service.properties.encoder2s[i].desc.type;
4236 jomodes.encoder2.port = mc_service.properties.encoder2s[i].desc.port;
4237 jomodes.encoder2.pos = mc_service.properties.encoder2s[i].desc.pos;
4239 eo_array_PushBack(arrayofjomos, &jomodes);
4254 case eomn_serv_MC_mc2pluspsc:
4256 eOmn_serv_config_data_mc_mc2pluspsc_t *data_mc = &(mcconfig.
ethservice.configuration.data.mc.mc2pluspsc);
4259 eOmn_serv_config_data_as_psc_t *psc = &data_mc->psc;
4262 for(
size_t i=0; i<mc_service.properties.psclocations.size(); i++)
4264 psc->boardInfo.canloc[i].port=mc_service.properties.psclocations[i].port;
4265 psc->boardInfo.canloc[i].addr=mc_service.properties.psclocations[i].addr;
4266 psc->boardInfo.canloc[i].insideindex=mc_service.properties.psclocations[i].insideindex;
4270 psc->version.firmware.major = mc_service.properties.canboards.at(0).firmware.major;
4271 psc->version.firmware.minor = mc_service.properties.canboards.at(0).firmware.minor;
4272 psc->version.firmware.build = mc_service.properties.canboards.at(0).firmware.build;
4273 psc->version.protocol.major = mc_service.properties.canboards.at(0).protocol.major;
4274 psc->version.protocol.minor = mc_service.properties.canboards.at(0).protocol.minor;
4277 EOarray *arrayofjomos = eo_array_New(4,
sizeof(eOmc_jomo_descriptor_t), &data_mc->arrayofjomodescriptors);
4278 int numofjomos = mc_service.properties.numofjoints;
4280 for(
int i=0; i<numofjomos; i++)
4282 eOmc_jomo_descriptor_t jomodes = {};
4285 jomodes.actuator.pwm.port = mc_service.properties.actuators[i].desc.pwm.port;
4288 jomodes.encoder1.type = mc_service.properties.encoder1s[i].desc.type;
4289 jomodes.encoder1.port = mc_service.properties.encoder1s[i].desc.port;
4290 jomodes.encoder1.pos = mc_service.properties.encoder1s[i].desc.pos;
4293 jomodes.encoder2.type = mc_service.properties.encoder2s[i].desc.type;
4294 jomodes.encoder2.port = mc_service.properties.encoder2s[i].desc.port;
4295 jomodes.encoder2.pos = mc_service.properties.encoder2s[i].desc.pos;
4297 eo_array_PushBack(arrayofjomos, &jomodes);
4307 case eomn_serv_MC_mc4plusfaps:
4309 eOmn_serv_config_data_mc_mc4plusfaps_t *data_mc = &(mcconfig.
ethservice.configuration.data.mc.mc4plusfaps);
4312 eOmn_serv_config_data_as_pos_t *pos = &data_mc->pos;
4315 for(
size_t b=0; b<eOas_pos_boards_maxnumber; b++)
4317 pos->config.boardconfig[b].boardinfo.type = mc_service.properties.canboards[b].type;
4318 pos->config.boardconfig[b].boardinfo.firmware.major = mc_service.properties.canboards[b].firmware.major;
4319 pos->config.boardconfig[b].boardinfo.firmware.minor = mc_service.properties.canboards[b].firmware.minor;
4320 pos->config.boardconfig[b].boardinfo.firmware.build = mc_service.properties.canboards[b].firmware.build;
4321 pos->config.boardconfig[b].boardinfo.protocol.major = mc_service.properties.canboards[b].protocol.major;
4322 pos->config.boardconfig[b].boardinfo.protocol.minor = mc_service.properties.canboards[b].protocol.minor;
4324 pos->config.boardconfig[b].canloc.addr = mc_service.properties.poslocations[b].addr;
4325 pos->config.boardconfig[b].canloc.port = mc_service.properties.poslocations[b].port;
4327 for(
size_t s=0; s<eOas_pos_sensorsinboard_maxnumber; s++)
4329 pos->config.boardconfig[b].sensors[s].connector = s;
4330 pos->config.boardconfig[b].sensors[s].type = eoas_pos_TYPE_decideg;
4331 pos->config.boardconfig[b].sensors[s].port =
static_cast<eObrd_portpos_t
>(s);
4332 pos->config.boardconfig[b].sensors[s].enabled = 1;
4333 pos->config.boardconfig[b].sensors[s].invertdirection = 0;
4334 pos->config.boardconfig[b].sensors[s].rotation = eoas_pos_ROT_zero;
4335 pos->config.boardconfig[b].sensors[s].offset = 0;
4340 for(
size_t i=0; i<mc_service.properties.poslocations.size(); i++)
4342 pos->config.boardconfig[0].canloc.port = mc_service.properties.poslocations[i].port;
4343 pos->config.boardconfig[0].canloc.addr = mc_service.properties.poslocations[i].addr;
4344 pos->config.boardconfig[0].canloc.insideindex = mc_service.properties.poslocations[i].insideindex;
4348 pos->config.boardconfig[0].boardinfo.firmware.major = mc_service.properties.canboards.at(0).firmware.major;
4349 pos->config.boardconfig[0].boardinfo.firmware.minor = mc_service.properties.canboards.at(0).firmware.minor;
4350 pos->config.boardconfig[0].boardinfo.firmware.build = mc_service.properties.canboards.at(0).firmware.build;
4351 pos->config.boardconfig[0].boardinfo.protocol.major = mc_service.properties.canboards.at(0).protocol.major;
4352 pos->config.boardconfig[0].boardinfo.protocol.minor = mc_service.properties.canboards.at(0).protocol.minor;
4355 EOarray *arrayofjomos = eo_array_New(4,
sizeof(eOmc_jomo_descriptor_t), &data_mc->arrayofjomodescriptors);
4356 size_t numofjomos = mc_service.properties.numofjoints;
4358 for(
size_t i=0; i<numofjomos; i++)
4360 eOmc_jomo_descriptor_t jomodes = {};
4363 jomodes.actuator.pwm.port = mc_service.properties.actuators[i].desc.pwm.port;
4366 jomodes.encoder1.type = mc_service.properties.encoder1s[i].desc.type;
4367 jomodes.encoder1.port = mc_service.properties.encoder1s[i].desc.port;
4368 jomodes.encoder1.pos = mc_service.properties.encoder1s[i].desc.pos;
4371 jomodes.encoder2.type = mc_service.properties.encoder2s[i].desc.type;
4372 jomodes.encoder2.port = mc_service.properties.encoder2s[i].desc.port;
4373 jomodes.encoder2.pos = mc_service.properties.encoder2s[i].desc.pos;
4375 eo_array_PushBack(arrayofjomos, &jomodes);
4383 case eomn_serv_MC_advfoc:
4385 eOmn_serv_config_data_mc_advfoc_t *data_mc = &(mcconfig.
ethservice.configuration.data.mc.advfoc);
4390 EOarray *arrayofjomos = eo_array_New(4,
sizeof(eOmc_adv_jomo_descriptor_t), &data_mc->arrayof4advjomodescriptors);
4391 size_t numofjomos = mc_service.properties.numofjoints;
4393 for(
size_t i=0; i<numofjomos; i++)
4395 eOmc_adv_jomo_descriptor_t jomodes = {};
4398 if(mc_service.properties.actuators[i].type != eomc_act_advfoc)
4400 yError() <<
"ServiceParser::parseService() unknown actuator value for eomn_serv_MC_advfoc mode. we need eomc_act_advfoc";
4409 jomodes.actuator.type = eomc_act_advfoc;
4410 jomodes.actuator.location = mc_service.properties.actuators[i].advdescr.location;
4411 jomodes.actuator.board.type = mc_service.properties.actuators[i].advdescr.board.type;
4412 eObrd_firmwareversion_t fw {};
4413 eObrd_protocolversion_t pr {};
4416 for(
size_t i=0; i<mc_service.properties.canboards.size(); i++)
4418 if(mc_service.properties.canboards[i].type == jomodes.actuator.board.type)
4420 fw = mc_service.properties.canboards[i].firmware;
4421 pr = mc_service.properties.canboards[i].protocol;
4429 yError() <<
"ServiceParser::parseService() could not find the actuator board inside the mc_service.properties.canboards[] vector";
4433 jomodes.actuator.board.firmware = fw;
4434 jomodes.actuator.board.protocol = pr;
4437 jomodes.encoder1.type = mc_service.properties.encoder1s[i].desc.type;
4438 jomodes.encoder1.port = mc_service.properties.encoder1s[i].desc.port;
4439 jomodes.encoder1.pos = mc_service.properties.encoder1s[i].desc.pos;
4442 jomodes.encoder2.type = mc_service.properties.encoder2s[i].desc.type;
4443 jomodes.encoder2.port = mc_service.properties.encoder2s[i].desc.port;
4444 jomodes.encoder2.pos = mc_service.properties.encoder2s[i].desc.pos;
4446 eo_array_PushBack(arrayofjomos, &jomodes);
4454 case eomn_serv_MC_generic:
4456 yWarning() <<
"ServiceParser::parseService() eomn_serv_MC_generic detected. set type = eomn_serv_MC_generic to let the remote board configure itself according to its IP address";
4457 mcconfig.
ethservice.configuration.type = eomn_serv_MC_generic;
4463 yError() <<
"ServiceParser::parseService() unknown value in eOmn_serv_type_t field";
4475 if(mc_service.properties.encoder1s[index].desc.pos == eomc_pos_atjoint)
4477 return(&mc_service.properties.encoder1s[index]);
4479 else if(mc_service.properties.encoder2s[index].desc.pos == eomc_pos_atjoint)
4481 return(&mc_service.properties.encoder2s[index]);
4489 if(mc_service.properties.encoder1s[index].desc.pos == eomc_pos_atmotor)
4491 return(&mc_service.properties.encoder1s[index]);
4493 else if(mc_service.properties.encoder2s[index].desc.pos == eomc_pos_atmotor)
4495 return(&mc_service.properties.encoder2s[index]);
4994 static eOmn_serv_configuration_t s_serv_config_mc_v3_0B1 = {};
4998 eOmc_arrayof_4jomodescriptors_t *ja = &s_serv_config_mc_v3_0B1.data.mc.mc4plus_based.arrayofjomodescriptors;
4999 eOmc_4jomo_coupling_t *jc = &s_serv_config_mc_v3_0B1.data.mc.mc4plus_based.jomocoupling;
5002 eOq17_14_t m1[][4] =
5004 { EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) },
5005 { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) },
5006 { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(-1.0f) },
5007 { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f) }
5012 { EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) },
5013 { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) },
5014 { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f) },
5015 { EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(0.0f), EO_COMMON_FLOAT_TO_Q17_14(1.0f) }
5025 ja->head.capacity = 4;
5026 ja->head.itemsize =
sizeof(eOmc_jomo_descriptor_t);
5028 ja->head.internalmem = 0;
5030 ja->data[0].actuator.pwm.port = 0 ;
5031 ja->data[0].encoder1.type = eomc_enc_aea;
5032 ja->data[0].encoder1.port = 1;
5033 ja->data[0].encoder1.pos = eomc_pos_atjoint;
5035 ja->data[0].encoder2.type = eomc_enc_qenc;
5036 ja->data[0].encoder2.port = 0;
5037 ja->data[0].encoder2.pos = eomc_pos_atmotor;
5039 ja->data[1].actuator.pwm.port = 1;
5040 ja->data[1].encoder1.type = eomc_enc_aea;
5041 ja->data[1].encoder1.port = 0;
5042 ja->data[1].encoder1.pos = eomc_pos_atjoint;
5043 ja->data[1].encoder2.type = eomc_enc_qenc;
5044 ja->data[1].encoder2.port = 1;
5045 ja->data[1].encoder2.pos = eomc_pos_atmotor;
5047 ja->data[2].actuator.pwm.port = 3;
5048 ja->data[2].encoder1.type = eomc_enc_qenc;
5049 ja->data[2].encoder1.port = 3;
5050 ja->data[2].encoder1.pos = eomc_pos_atjoint;
5051 ja->data[2].encoder2.type = eomc_enc_qenc,
5052 ja->data[2].encoder2.port = 3,
5053 ja->data[2].encoder2.pos = eomc_pos_atmotor;
5055 ja->data[3].actuator.pwm.port = 2;
5057 ja->data[3].encoder1.type = eomc_enc_qenc;
5058 ja->data[3].encoder1.port = 2;
5059 ja->data[3].encoder1.pos = eomc_pos_atjoint;
5062 ja->data[3].encoder2.type = eomc_enc_qenc;
5063 ja->data[3].encoder2.port = 2;
5064 ja->data[3].encoder2.pos = eomc_pos_atmotor;
5067 jc->joint2set[0] = eomc_jointSetNum_zero;
5068 jc->joint2set[1] = eomc_jointSetNum_one;
5069 jc->joint2set[2] = eomc_jointSetNum_two;
5070 jc->joint2set[3] = eomc_jointSetNum_two;
5093 memcpy(&jc->joint2motor, &m1,
sizeof(m1));
5094 memcpy(&jc->encoder2joint, &m2,
sizeof(m2));
5096 yError() <<
"print first m ";
5097 for(
int r=0; r<4; r++)
5099 for(
int c=0; c<4; c++)
5101 yError() <<
"r=" <<r <<
"c=" << c <<
"val=" << m1[r][c];
5105 yError() <<
"print second m ";
5106 for(
int r=0; r<4; r++)
5108 for(
int c=0; c<4; c++)
5110 yError() <<
"r=" <<r <<
"c=" << c <<
"val=" << m2[r][c];
5118 yError() <<
" id scheda sbagliato " << mcconfig.
id;
5123 memcpy(&mcconfig.
ethservice, &s_serv_config_mc_v3_0B1,
sizeof(eOmn_serv_configuration_t));
bool parseService2(yarp::os::Searchable &config, servConfigMC_t &mcconfig)
bool parse_encoder_port(std::string const &fromstring, eObrd_ethtype_t const ethboard, eOmc_encoder_t type, uint8_t &toport, bool &formaterror)
bool parse_port_conn(std::string const &fromstring, eObrd_type_t const board, uint8_t &toport, bool &formaterror)
bool parse_actuator_port(std::string const &fromstring, eObrd_ethtype_t const ethboard, eOmc_actuator_t const type, eOmc_actuator_descriptor_t &todes, bool &formaterror)
bool parse_POS_CALIB_rotation(std::string const &fromstring, eoas_pos_ROT_t &rot, bool &formaterror)
bool convert(std::string const &fromstring, eOmc_actuator_t &toactuatortype, bool &formaterror)
bool parse_mais(std::string const &fromstring, eObrd_portmais_t &pmais, bool &formaterror)
bool parse_port_psc(std::string const &fromstring, uint8_t &toport, bool &formaterror)
bool parse_POS_CALIB_type(std::string const &fromstring, eoas_pos_TYPE_t &type, bool &formaterror)
bool parseService(yarp::os::Searchable &config, servConfigMais_t &maisconfig)
bool parse_port_pos(std::string const &fromstring, uint8_t &toport, bool &formaterror)
bool parse_POS_connector(std::string const &fromstring, const eObrd_type_t brd, eObrd_connector_t &conn, bool &formaterror)
bool parse_POS_port(std::string const &fromstring, eObrd_portpos_t &ppos, bool &formaterror)
servMC_encoder_t * getEncoderAtMotor(int index)
bool parse_connector(const std::string &fromstring, eObrd_connector_t &toconnector, bool &formaterror)
servMC_encoder_t * getEncoderAtJoint(int index)
bool parse_psc(std::string const &fromstring, eObrd_portpsc_t &ppsc, bool &formaterror)
bool parse_port_mais(std::string const &fromstring, uint8_t &toport, bool &formaterror)
Gain convert(const DiscreteGain dg)
Copyright (C) 2008 RobotCub Consortium.
servAnalogPOScalibration_t calibration
eObrd_connector_t connector
servAnalogPOSspecific_t pos
eObrd_location_t location
eObrd_protocolversion_t protocol
eObrd_firmwareversion_t firmware
int temperatureAcquisitionrate
eOmn_serv_parameter_t ethservice
eOmn_serv_parameter_t ethservice
std::vector< eOas_inertial3_descriptor_t > inertials
std::vector< std::string > id
std::vector< std::string > sensorName
eOmn_serv_parameter_t ethservice
eOmn_serv_parameter_t ethservice
eOmn_serv_parameter_t ethservice
eOmn_serv_parameter_t ethservice
eOmn_serv_parameter_t ethservice
eOmc_adv_actuator_descriptor_t advdescr
eOmc_actuator_descriptor_t desc
eOmc_encoder_descriptor_t desc