diff --git a/robowflex_library/src/scene.cpp b/robowflex_library/src/scene.cpp index fbfd59e27..89d4ebe72 100644 --- a/robowflex_library/src/scene.cpp +++ b/robowflex_library/src/scene.cpp @@ -272,7 +272,13 @@ RobotPose Scene::getObjectPose(const std::string &name) const const auto &world = scene_->getWorldNonConst(); const auto &obj = world->getObject(name); if (obj) + { +#if ROBOWFLEX_MOVEIT_VERSION >= ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6) + return obj->pose_ * obj->shape_poses_[0]; +#else return obj->shape_poses_[0]; +#endif + } return RobotPose::Identity(); } diff --git a/robowflex_library/src/yaml.cpp b/robowflex_library/src/yaml.cpp index 87de19cc4..8877ae87a 100644 --- a/robowflex_library/src/yaml.cpp +++ b/robowflex_library/src/yaml.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -834,6 +835,10 @@ namespace YAML node["id"] = rhs.id; +#if ROBOWFLEX_MOVEIT_VERSION >= ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6) + node["pose"] = rhs.pose; +#endif + if (!rhs.type.key.empty()) node["type"] = rhs.type; @@ -877,6 +882,8 @@ namespace YAML bool convert::decode(const Node &node, moveit_msgs::CollisionObject &rhs) { + RobotPose pose = TF::identity(); + geometry_msgs::Pose pose_msg = TF::poseEigenToMsg(pose); rhs = moveit_msgs::CollisionObject(); if (IO::isNode(node["header"])) @@ -887,6 +894,16 @@ namespace YAML if (IO::isNode(node["id"])) rhs.id = node["id"].as(); + if (IO::isNode(node["pose"])) + { + pose_msg = node["pose"].as(); + pose = TF::poseMsgToEigen(pose_msg); + } + +#if ROBOWFLEX_MOVEIT_VERSION >= ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6) + rhs.pose = pose_msg; +#endif + if (IO::isNode(node["type"])) rhs.type = node["type"].as(); @@ -894,18 +911,36 @@ namespace YAML { rhs.primitives = node["primitives"].as>(); rhs.primitive_poses = node["primitive_poses"].as>(); + + // If loading a newer format, add pose to include offset +#if ROBOWFLEX_MOVEIT_VERSION < ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6) + for (auto &primitive_pose : rhs.primitive_poses) + primitive_pose = TF::poseEigenToMsg(pose * TF::poseMsgToEigen(primitive_pose)); +#endif } if (IO::isNode(node["meshes"])) { rhs.meshes = node["meshes"].as>(); rhs.mesh_poses = node["mesh_poses"].as>(); + + // If loading a newer format, add pose to include offset +#if ROBOWFLEX_MOVEIT_VERSION < ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6) + for (auto &mesh_pose : rhs.mesh_poses) + mesh_pose = TF::poseEigenToMsg(pose * TF::poseMsgToEigen(mesh_pose)); +#endif } if (IO::isNode(node["planes"])) { rhs.planes = node["planes"].as>(); rhs.plane_poses = node["plane_poses"].as>(); + + // If loading a newer format, add pose to include offset +#if ROBOWFLEX_MOVEIT_VERSION < ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6) + for (auto &plane_pose : rhs.plane_poses) + plane_pose = TF::poseEigenToMsg(pose * TF::poseMsgToEigen(plane_pose)); +#endif } if (IO::isNode(node["operation"]))