5 #include <VirtualRobot/XML/RobotIO.h>
13 template <
typename... Ts>
16 using Ts::operator()...;
19 template <
typename... Ts>
28 if (!articulatedModel.has_value())
30 return "object '" + info.
idStr() +
31 "' does not have an articulated xml model but the specified frame isn't "
36 articulatedModel.value().relativePath);
37 const auto robot = VirtualRobot::RobotIO::loadRobot(modelPath.toSystemPath(),
38 VirtualRobot::BaseIO::eStructure);
41 return "articulated model of '" + info.
idStr() +
"couldn't be loaded";
46 const auto node = robot->getRobotNode(framedPose.frame);
49 return "unknown node '" + framedPose.frame +
"' of object '" + info.
idStr() +
"'";
52 const auto& global_T_node = node->getGlobalPose();
53 const auto& node_T_location = framedPose.
toEigen();
55 return Pose(global_T_node * node_T_location);
62 std::variant<Pose, ObjectID>
65 if (framedPose.agent.empty())
68 <<
"frame is not set as global frame even though agent is empty";
73 if (
id.instanceName().
empty())
75 id.setInstanceName(instanceID);
84 const std::string& instanceID)
92 const std::optional<objpose::ObjectPose> pose = client.
fetchObjectPose(
id);
93 if (!pose.has_value())
95 return "unknown object '" +
id.str() +
"'";
98 if (framedPose.frame ==
"root")
100 const auto& global_T_obj = pose.value().objectPoseGlobal;
101 const auto& obj_T_location = framedPose.
toEigen();
103 return Pose(global_T_obj * obj_T_location);
108 std::optional<ObjectInfo> info = finder.
findObject(
id);
109 if (!info.has_value())
111 return "can't find ObjectInfo for '" +
id.str() +
"'";
122 const std::vector<ObjectInfo>& info,
124 const std::string& instanceID)
133 const auto pose = objects.find(
id);
134 if (pose == objects.end())
136 return "unknown object '" +
id.str() +
"'";
139 if (framedPose.frame ==
"root")
141 const auto& global_T_obj = pose->second.objectPoseGlobal;
142 const auto& obj_T_location = framedPose.
toEigen();
144 return Pose(global_T_obj * obj_T_location);
150 if (i.id().equalClass(
id))
156 return "Can't find ObjectInfo for '" +
id.str() +
"'";