8 #include <VirtualRobot/XML/BaseIO.h>
9 #include <VirtualRobot/XML/RobotIO.h>
26 template <
typename... Ts>
29 using Ts::operator()...;
32 template <
typename... Ts>
41 if (!articulatedModel.has_value())
43 return "object '" + info.
idStr() +
44 "' does not have an articulated xml model but the specified frame isn't "
49 articulatedModel.value().relativePath);
50 const auto robot = VirtualRobot::RobotIO::loadRobot(modelPath.toSystemPath(),
51 VirtualRobot::BaseIO::eStructure);
54 return "articulated model of '" + info.
idStr() +
"couldn't be loaded";
59 const auto node = robot->getRobotNode(framedPose.frame);
62 return "unknown node '" + framedPose.frame +
"' of object '" + info.
idStr() +
"'";
65 const auto& global_T_node = node->getGlobalPose();
66 const auto& node_T_location = framedPose.
toEigen();
68 return Pose(global_T_node * node_T_location);
75 std::variant<Pose, ObjectID>
78 if (framedPose.agent.empty())
81 <<
"frame is not set as global frame even though agent is empty";
86 if (
id.instanceName().
empty())
88 id.setInstanceName(instanceID);
97 const std::string& instanceID)
105 const std::optional<objpose::ObjectPose> pose = client.
fetchObjectPose(
id);
106 if (!pose.has_value())
108 return "unknown object '" +
id.str() +
"'";
111 if (framedPose.frame ==
"root")
113 const auto& global_T_obj = pose.value().objectPoseGlobal;
114 const auto& obj_T_location = framedPose.
toEigen();
116 return Pose(global_T_obj * obj_T_location);
121 std::optional<ObjectInfo> info = finder.
findObject(
id);
122 if (!info.has_value())
124 return "can't find ObjectInfo for '" +
id.str() +
"'";
135 const std::vector<ObjectInfo>& info,
137 const std::string& instanceID)
146 const auto pose = objects.find(
id);
147 if (pose == objects.end())
149 return "unknown object '" +
id.str() +
"'";
152 if (framedPose.frame ==
"root")
154 const auto& global_T_obj = pose->second.objectPoseGlobal;
155 const auto& obj_T_location = framedPose.
toEigen();
157 return Pose(global_T_obj * obj_T_location);
163 if (i.id().equalClass(
id))
169 return "Can't find ObjectInfo for '" +
id.str() +
"'";