5 #include <SimoxUtility/algorithm/advanced.h>
6 #include <SimoxUtility/algorithm/get_map_keys_values.h>
8 #include <RobotAPI/interface/units/RobotUnit/RobotUnitInterface.h>
28 const RobotUnitDataStreaming::DataStreamingDescription& description)
30 arondto::Proprioception dto;
31 dto.iterationID =
data.iterationId;
33 for (
const auto& [dataEntryName, dataEntry] : description.entries)
42 const std::string& entryName,
47 const std::set<size_t> acceptedSizes{3, 4, 5};
49 <<
"Data entry name could not be parsed (exected 3 or 4 or 5 components between '.'): "
50 <<
"\n- split: '" <<
split <<
"'";
52 const std::string& category =
split.at(0);
53 const std::string& name =
split.at(1);
54 const std::string& field =
split.at(2);
57 if (name ==
"Platform")
60 processPlatformEntry(dto.platform, field,
value);
65 processForceTorqueEntry(dto.forceTorque,
split,
value);
70 bool processed = processJointEntry(dto.joints,
split,
value);
74 const std::vector<std::string> comps{simox::alg::advanced(
split.begin(), 1),
76 const std::string key = simox::alg::join(comps,
".");
78 switch (
value.entry.type)
80 case RobotUnitDataStreaming::NodeTypeFloat:
81 dto.extraFloats[key] = getValueAs<float>(
value);
83 case RobotUnitDataStreaming::NodeTypeLong:
84 dto.extraLongs[key] = getValueAs<long>(
value);
86 case RobotUnitDataStreaming::NodeTypeBool:
87 dto.extraBools[key] = getValueAs<bool>(
value);
89 case RobotUnitDataStreaming::NodeTypeInt:
90 dto.extraInts[key] = getValueAs<int>(
value);
92 case RobotUnitDataStreaming::NodeTypeShort:
93 dto.extraShorts[key] = getValueAs<Ice::Short>(
value);
95 case RobotUnitDataStreaming::NodeTypeByte:
96 dto.extraBytes[key] = getValueAs<Ice::Byte>(
value);
100 <<
"Cannot handle extra field '" << key <<
"' of type "
109 Armar6Converter::processPlatformEntry(prop::arondto::Platform& dto,
110 const std::string& fieldName,
117 else if (
auto getter =
findByPrefix(fieldName, tools->platformPoseGetters))
119 if (Eigen::Vector3f* dst = getter(dto))
121 if (
auto setter =
findBySuffix(fieldName, tools->vector3fSetters))
123 setter(*dst, getValueAs<float>(
value));
130 dto.extra[fieldName] = getValueAs<float>(
value);
135 Armar6Converter::processForceTorqueEntry(std::map<std::string, prop::arondto::ForceTorque>& fts,
136 const std::vector<std::string>&
split,
137 const ConverterValue&
value)
139 const std::string& name =
split.at(1);
144 auto it = tools->sidePrefixMap.find(splitName.at(1));
145 ARMARX_CHECK(it != tools->sidePrefixMap.end()) << splitName.at(1);
147 const std::string& side = it->second;
148 processForceTorqueEntry(fts[side],
split,
value);
152 Armar6Converter::processForceTorqueEntry(prop::arondto::ForceTorque& dto,
153 const std::vector<std::string>&
split,
154 const ConverterValue&
value)
156 const std::string& fieldName =
split.at(2);
157 if (
auto getter =
findByPrefix(fieldName, tools->ftGetters))
159 if (Eigen::Vector3f* dst = getter(dto))
161 if (
auto setter =
findBySuffix(fieldName, tools->vector3fSetters))
163 setter(*dst, getValueAs<float>(
value));
170 std::string key =
split.size() == 4 ? (fieldName +
"." +
split.at(3)) : fieldName;
172 switch (
value.entry.type)
174 case RobotUnitDataStreaming::NodeTypeFloat:
175 dto.extra[key] = getValueAs<float>(
value);
177 case RobotUnitDataStreaming::NodeTypeInt:
178 dto.extra[key] = getValueAs<int>(
value);
180 case RobotUnitDataStreaming::NodeTypeLong:
181 dto.extra[key] = getValueAs<long>(
value);
184 ARMARX_DEBUG <<
"Cannot handle extra field '" << key <<
"' of type "
194 const std::vector<std::string>&
split,
195 const ConverterValue&
value)
197 const std::string& jointName =
split.at(1);
198 const std::string& fieldName =
split.at(2);
202 if (
auto getter =
findByPrefix(fieldName, tools->jointGetters))
204 if (std::map<std::string, float>* map = getter(dto))
206 (*map)[jointName] = getValueAs<float>(
value);
211 const std::string tempSuffix =
"Temperature";
215 const std::string name =
split.at(2).substr(0,
split.at(2).size() - tempSuffix.size());
216 dto.temperature[
split.at(1)][name] = getValueAs<float>(
value);
219 else if (
auto it = tools->jointSetters.find(fieldName); it != tools->jointSetters.end())