6 #include <SimoxUtility/algorithm/advanced.h>
7 #include <SimoxUtility/algorithm/get_map_keys_values.h>
12 #include <RobotAPI/libraries/armem_robot_state/aron/Exteroception.aron.generated.h>
29 const RobotUnitDataStreaming::DataStreamingDescription& description)
31 arondto::Exteroception dto;
32 dto.iterationID =
data.iterationId;
35 const std::size_t singleDimSize =
static_cast<std::size_t
>(
std::sqrt(properties_.
tofSize));
40 dto.tof[
"Left"].depth.resize(singleDimSize, singleDimSize);
41 dto.tof[
"Left"].depth.setConstant(-1);
44 dto.tof[
"Left"].sigma.resize(singleDimSize, singleDimSize);
45 dto.tof[
"Left"].sigma.setConstant(-1);
48 dto.tof[
"Left"].targetDetected.resize(singleDimSize, singleDimSize);
49 dto.tof[
"Left"].targetDetected.setConstant(-1);
53 dto.tof[
"Right"].depth.resize(singleDimSize, singleDimSize);
54 dto.tof[
"Right"].depth.setConstant(-1);
57 dto.tof[
"Right"].sigma.resize(singleDimSize, singleDimSize);
58 dto.tof[
"Right"].sigma.setConstant(-1);
61 dto.tof[
"Right"].targetDetected.resize(singleDimSize, singleDimSize);
62 dto.tof[
"Right"].targetDetected.setConstant(-1);
64 for (
const auto& [dataEntryName, dataEntry] : description.entries)
87 const std::string& entryName,
92 const std::set<size_t> acceptedSizes{3, 4, 5};
94 <<
"Data entry name could not be parsed (exected 3 or 4 or 5 components between '.'): "
95 <<
"\n- split: '" <<
split <<
"'";
97 const std::string& category =
split.at(0);
99 const std::string& field =
split.at(2);
117 processToFTargetDetectedEntry(dto.tof,
split,
value);
122 ArmarDEConverter::processToFDepthEntry(
123 std::map<std::string, armarx::armem::exteroception::arondto::ToF>& tofs,
124 const std::vector<std::string>&
split,
132 const std::string& name =
split.at(1);
137 const std::map<std::string, std::string> sidePrefixMap{{
"LeftHand",
"Left"},
138 {
"RightHand",
"Right"}};
140 auto it = sidePrefixMap.find(name);
143 const std::string& side = it->second;
144 processToFDepthEntry(tofs[side],
split,
value);
148 ArmarDEConverter::processToFDepthEntry(armarx::armem::exteroception::arondto::ToF& tof,
149 const std::vector<std::string>&
split,
150 const ConverterValue&
value)
156 const int idx = std::stoi(elements.at(1));
166 tof.depth(idx) = getValueAs<float>(
value);
170 ArmarDEConverter::processToFSigmaEntry(
171 std::map<std::string, armarx::armem::exteroception::arondto::ToF>& tofs,
172 const std::vector<std::string>&
split,
173 const ConverterValue&
value)
180 const std::string& name =
split.at(1);
185 const std::map<std::string, std::string> sidePrefixMap{{
"LeftHand",
"Left"},
186 {
"RightHand",
"Right"}};
188 auto it = sidePrefixMap.find(name);
191 const std::string& side = it->second;
192 processToFSigmaEntry(tofs[side],
split,
value);
196 ArmarDEConverter::processToFSigmaEntry(armarx::armem::exteroception::arondto::ToF& tof,
197 const std::vector<std::string>&
split,
198 const ConverterValue&
value)
204 const int idx = std::stoi(elements.at(1));
214 tof.sigma(idx) = getValueAs<float>(
value);
218 ArmarDEConverter::processToFTargetDetectedEntry(
219 std::map<std::string, armarx::armem::exteroception::arondto::ToF>& tofs,
220 const std::vector<std::string>&
split,
221 const ConverterValue&
value)
228 const std::string& name =
split.at(1);
233 const std::map<std::string, std::string> sidePrefixMap{{
"LeftHand",
"Left"},
234 {
"RightHand",
"Right"}};
236 auto it = sidePrefixMap.find(name);
239 const std::string& side = it->second;
240 processToFTargetDetectedEntry(tofs[side],
split,
value);
244 ArmarDEConverter::processToFTargetDetectedEntry(armarx::armem::exteroception::arondto::ToF& tof,
245 const std::vector<std::string>&
split,
246 const ConverterValue&
value)
252 const int idx = std::stoi(elements.at(1));
262 tof.targetDetected(idx) = getValueAs<float>(
value);