8 #include <boost/algorithm/hex.hpp>
9 #include <boost/iostreams/device/back_inserter.hpp>
10 #include <boost/iostreams/filter/zlib.hpp>
11 #include <boost/iostreams/filtering_stream.hpp>
26 return b ?
"true" :
"false";
29 static bool nodeToBool(
const YAML::Node &n)
36 static bool isHeaderEmpty(
const std_msgs::Header &h)
38 return h.seq == 0 && h.stamp.isZero() && h.frame_id ==
"world";
41 static std_msgs::Header getDefaultHeader()
44 msg.frame_id =
"world";
48 static unsigned int nodeToCollisionObject(
const YAML::Node &n)
56 return moveit_msgs::CollisionObject::MOVE;
58 return moveit_msgs::CollisionObject::REMOVE;
60 return moveit_msgs::CollisionObject::APPEND;
62 return moveit_msgs::CollisionObject::ADD;
64 catch (
const YAML::BadConversion &e)
71 return moveit_msgs::CollisionObject::ADD;
73 return moveit_msgs::CollisionObject::REMOVE;
75 return moveit_msgs::CollisionObject::APPEND;
77 return moveit_msgs::CollisionObject::MOVE;
79 return moveit_msgs::CollisionObject::ADD;
84 static std::string primitiveTypeToString(
const shape_msgs::SolidPrimitive &shape)
88 case shape_msgs::SolidPrimitive::BOX:
91 case shape_msgs::SolidPrimitive::SPHERE:
94 case shape_msgs::SolidPrimitive::CYLINDER:
97 case shape_msgs::SolidPrimitive::CONE:
106 static void nodeToPrimitiveType(
const YAML::Node &n, shape_msgs::SolidPrimitive &shape)
112 shape.type = shape_msgs::SolidPrimitive::SPHERE;
113 else if (s ==
"cylinder")
114 shape.type = shape_msgs::SolidPrimitive::CYLINDER;
115 else if (s ==
"cone")
116 shape.type = shape_msgs::SolidPrimitive::CONE;
118 shape.type = shape_msgs::SolidPrimitive::BOX;
120 shape.type = n.as<
int>();
123 static bool isVector3Zero(
const geometry_msgs::Vector3 &v)
125 return v.x == 0 && v.y == 0 && v.z == 0;
128 static bool isConstraintEmpty(
const moveit_msgs::Constraints &c)
130 return c.joint_constraints.empty()
131 && c.position_constraints.empty()
132 && c.orientation_constraints.empty()
133 && c.visibility_constraints.empty();
140 boost::iostreams::filtering_ostream fos;
141 fos.push(boost::iostreams::zlib_compressor());
142 fos.push(boost::iostreams::back_inserter(compress));
144 for (
const auto &i : v)
161 boost::iostreams::filtering_ostream fos;
162 fos.push(boost::iostreams::zlib_decompressor());
163 fos.push(boost::iostreams::back_inserter(decompress));
165 for (
const auto &i : unhexed)
175 #if ROBOWFLEX_AT_LEAST_KINETIC
178 Node convert<signed char>::encode(
const signed char &rhs)
183 return Node(stream.
str());
186 bool convert<signed char>::decode(
const Node &node,
signed char &rhs)
188 if (node.Type() != NodeType::Scalar)
193 stream.
unsetf(std::ios::dec);
194 if ((stream >> rhs) && (stream >>
std::ws).eof())
198 if (conversion::IsInfinity(input))
203 else if (conversion::IsNegativeInfinity(input))
220 Node convert<moveit_msgs::PlanningScene>::encode(
const moveit_msgs::PlanningScene &rhs)
223 node[
"name"] = rhs.name;
224 node[
"robot_state"] = rhs.robot_state;
225 node[
"robot_model_name"] = rhs.robot_model_name;
226 node[
"fixed_frame_transforms"] = rhs.fixed_frame_transforms;
227 node[
"allowed_collision_matrix"] = rhs.allowed_collision_matrix;
237 if (!rhs.world.collision_objects.empty() || !rhs.world.octomap.octomap.data.empty())
238 node[
"world"] = rhs.world;
241 node[
"is_diff"] = boolToString(rhs.is_diff);
246 bool convert<moveit_msgs::PlanningScene>::decode(
const Node &node, moveit_msgs::PlanningScene &rhs)
248 rhs = moveit_msgs::PlanningScene();
254 rhs.robot_state = node[
"robot_state"].as<moveit_msgs::RobotState>();
257 rhs.robot_model_name = node[
"robot_model_name"].as<
std::string>();
259 if (
IO::isNode(node[
"fixed_frame_transforms"]))
260 rhs.fixed_frame_transforms =
263 if (
IO::isNode(node[
"allowed_collision_matrix"]))
264 rhs.allowed_collision_matrix =
265 node[
"allowed_collision_matrix"].as<moveit_msgs::AllowedCollisionMatrix>();
277 rhs.world = node[
"world"].as<moveit_msgs::PlanningSceneWorld>();
280 rhs.is_diff = nodeToBool(node[
"is_diff"]);
285 Node convert<moveit_msgs::RobotState>::encode(
const moveit_msgs::RobotState &rhs)
289 if (!rhs.joint_state.name.empty())
290 node[
"joint_state"] = rhs.joint_state;
292 if (!rhs.multi_dof_joint_state.joint_names.empty())
293 node[
"multi_dof_joint_state"] = rhs.multi_dof_joint_state;
295 if (!rhs.attached_collision_objects.empty())
296 node[
"attached_collision_objects"] = rhs.attached_collision_objects;
299 node[
"is_diff"] = boolToString(rhs.is_diff);
304 bool convert<moveit_msgs::RobotState>::decode(
const Node &node, moveit_msgs::RobotState &rhs)
306 rhs = moveit_msgs::RobotState();
309 rhs.joint_state = node[
"joint_state"].as<sensor_msgs::JointState>();
311 if (
IO::isNode(node[
"multi_dof_joint_state"]))
312 rhs.multi_dof_joint_state = node[
"multi_dof_joint_state"].as<sensor_msgs::MultiDOFJointState>();
314 if (
IO::isNode(node[
"attached_collision_objects"]))
315 rhs.attached_collision_objects =
319 rhs.is_diff = nodeToBool(node[
"is_diff"]);
324 Node convert<geometry_msgs::TransformStamped>::encode(
const geometry_msgs::TransformStamped &rhs)
328 if (!isHeaderEmpty(rhs.header))
329 node[
"header"] = rhs.header;
331 node[
"child_frame_id"] = rhs.child_frame_id;
332 node[
"transform"] = rhs.transform;
336 bool convert<geometry_msgs::TransformStamped>::decode(
const Node &node,
337 geometry_msgs::TransformStamped &rhs)
339 rhs = geometry_msgs::TransformStamped();
342 rhs.header = node[
"header"].as<std_msgs::Header>();
344 rhs.header = getDefaultHeader();
347 rhs.child_frame_id = node[
"child_frame_id"].as<
std::string>();
350 rhs.transform = node[
"transform"].as<geometry_msgs::Transform>();
355 Node convert<std_msgs::Header>::encode(
const std_msgs::Header &rhs)
359 node[
"seq"] = rhs.seq;
361 if (!rhs.stamp.isZero())
363 node[
"stamp"][
"secs"] = rhs.stamp.sec;
364 node[
"stamp"][
"nsecs"] = rhs.stamp.nsec;
367 if (rhs.frame_id !=
"world" && rhs.frame_id !=
"/world")
368 node[
"frame_id"] = rhs.frame_id;
373 bool convert<std_msgs::Header>::decode(
const Node &node, std_msgs::Header &rhs)
375 rhs = std_msgs::Header();
376 rhs.frame_id =
"world";
379 rhs.seq = node[
"seq"].as<
int>();
385 rhs.stamp.sec = node[
"stamp"][
"sec"].as<
int>();
386 rhs.stamp.nsec = node[
"stamp"][
"nsec"].as<
int>();
388 catch (YAML::InvalidNode &e)
390 rhs.stamp.sec = node[
"stamp"][
"secs"].as<
int>();
391 rhs.stamp.nsec = node[
"stamp"][
"nsecs"].as<
int>();
401 Node convert<geometry_msgs::Pose>::encode(
const geometry_msgs::Pose &rhs)
404 node[
"position"] = rhs.position;
405 node[
"orientation"] = rhs.orientation;
409 bool convert<geometry_msgs::Pose>::decode(
const Node &node, geometry_msgs::Pose &rhs)
411 rhs = geometry_msgs::Pose();
414 rhs.position = node[
"position"].as<geometry_msgs::Point>();
417 rhs.orientation = node[
"orientation"].as<geometry_msgs::Quaternion>();
422 Node convert<geometry_msgs::PoseStamped>::encode(
const geometry_msgs::PoseStamped &rhs)
425 if (!isHeaderEmpty(rhs.header))
426 node[
"header"] = rhs.header;
428 node[
"pose"] = rhs.pose;
433 bool convert<geometry_msgs::PoseStamped>::decode(
const Node &node, geometry_msgs::PoseStamped &rhs)
435 rhs = geometry_msgs::PoseStamped();
438 rhs.header = node[
"header"].as<std_msgs::Header>();
440 rhs.header = getDefaultHeader();
442 rhs.pose = node[
"pose"].as<geometry_msgs::Pose>();
447 Node convert<geometry_msgs::Transform>::encode(
const geometry_msgs::Transform &rhs)
450 node[
"translation"] = rhs.translation;
451 node[
"rotation"] = rhs.rotation;
455 bool convert<geometry_msgs::Transform>::decode(
const Node &node, geometry_msgs::Transform &rhs)
457 rhs = geometry_msgs::Transform();
460 rhs.translation = node[
"translation"].as<geometry_msgs::Vector3>();
463 rhs.rotation = node[
"rotation"].as<geometry_msgs::Quaternion>();
468 Node convert<geometry_msgs::Point>::encode(
const geometry_msgs::Point &rhs)
473 node.push_back(rhs.x);
474 node.push_back(rhs.y);
475 node.push_back(rhs.z);
479 bool convert<geometry_msgs::Point>::decode(
const Node &node, geometry_msgs::Point &rhs)
481 rhs = geometry_msgs::Point();
483 if (node.IsSequence())
485 rhs.x = node[0].as<
double>();
486 rhs.y = node[1].as<
double>();
487 rhs.z = node[2].as<
double>();
491 rhs.x = node[
"x"].as<
double>();
492 rhs.y = node[
"y"].as<
double>();
493 rhs.z = node[
"z"].as<
double>();
498 Node convert<geometry_msgs::Vector3>::encode(
const geometry_msgs::Vector3 &rhs)
503 node.push_back(rhs.x);
504 node.push_back(rhs.y);
505 node.push_back(rhs.z);
509 bool convert<geometry_msgs::Vector3>::decode(
const Node &node, geometry_msgs::Vector3 &rhs)
511 rhs = geometry_msgs::Vector3();
513 if (node.IsSequence())
515 rhs.x = node[0].as<
double>();
516 rhs.y = node[1].as<
double>();
517 rhs.z = node[2].as<
double>();
521 rhs.x = node[
"x"].as<
double>();
522 rhs.y = node[
"y"].as<
double>();
523 rhs.z = node[
"z"].as<
double>();
529 Node convert<geometry_msgs::Quaternion>::encode(
const geometry_msgs::Quaternion &rhs)
534 node.push_back(rhs.x);
535 node.push_back(rhs.y);
536 node.push_back(rhs.z);
537 node.push_back(rhs.w);
541 bool convert<geometry_msgs::Quaternion>::decode(
const Node &node, geometry_msgs::Quaternion &rhs)
543 rhs = geometry_msgs::Quaternion();
545 if (node.IsSequence())
547 rhs.x = node[0].as<
double>();
548 rhs.y = node[1].as<
double>();
549 rhs.z = node[2].as<
double>();
550 rhs.w = node[3].as<
double>();
554 rhs.x = node[
"x"].as<
double>();
555 rhs.y = node[
"y"].as<
double>();
556 rhs.z = node[
"z"].as<
double>();
557 rhs.w = node[
"w"].as<
double>();
562 Node convert<geometry_msgs::Twist>::encode(
const geometry_msgs::Twist &rhs)
565 node[
"linear"] = rhs.linear;
566 node[
"angular"] = rhs.angular;
570 bool convert<geometry_msgs::Twist>::decode(
const Node &node, geometry_msgs::Twist &rhs)
572 rhs = geometry_msgs::Twist();
574 rhs.linear = node[
"linear"].as<geometry_msgs::Vector3>();
575 rhs.angular = node[
"angular"].as<geometry_msgs::Vector3>();
580 Node convert<geometry_msgs::Wrench>::encode(
const geometry_msgs::Wrench &rhs)
583 node[
"force"] = rhs.force;
584 node[
"torque"] = rhs.torque;
588 bool convert<geometry_msgs::Wrench>::decode(
const Node &node, geometry_msgs::Wrench &rhs)
590 rhs = geometry_msgs::Wrench();
592 rhs.force = node[
"force"].as<geometry_msgs::Vector3>();
593 rhs.torque = node[
"torque"].as<geometry_msgs::Vector3>();
598 Node convert<sensor_msgs::JointState>::encode(
const sensor_msgs::JointState &rhs)
602 if (!isHeaderEmpty(rhs.header))
603 node[
"header"] = rhs.header;
605 if (!rhs.name.empty())
607 node[
"name"] = rhs.name;
611 if (!rhs.position.empty())
613 node[
"position"] = rhs.position;
617 if (!rhs.velocity.empty())
619 node[
"velocity"] = rhs.velocity;
623 if (!rhs.effort.empty())
625 node[
"effort"] = rhs.effort;
632 bool convert<sensor_msgs::JointState>::decode(
const Node &node, sensor_msgs::JointState &rhs)
634 rhs = sensor_msgs::JointState();
637 rhs.header = node[
"header"].as<std_msgs::Header>();
639 rhs.header = getDefaultHeader();
656 Node convert<sensor_msgs::MultiDOFJointState>::encode(
const sensor_msgs::MultiDOFJointState &rhs)
660 if (!isHeaderEmpty(rhs.header))
661 node[
"header"] = rhs.header;
663 node[
"joint_names"] = rhs.joint_names;
666 node[
"transforms"] = rhs.transforms;
669 node[
"twist"] = rhs.twist;
672 node[
"wrench"] = rhs.wrench;
677 bool convert<sensor_msgs::MultiDOFJointState>::decode(
const Node &node,
678 sensor_msgs::MultiDOFJointState &rhs)
680 rhs = sensor_msgs::MultiDOFJointState();
683 rhs.header = node[
"header"].as<std_msgs::Header>();
685 rhs.header = getDefaultHeader();
703 convert<moveit_msgs::AttachedCollisionObject>::encode(
const moveit_msgs::AttachedCollisionObject &rhs)
706 node[
"link_name"] = rhs.link_name;
707 node[
"object"] = rhs.object;
709 if (!rhs.touch_links.empty())
710 node[
"touch_links"] = rhs.touch_links;
712 if (!rhs.detach_posture.points.empty())
713 node[
"detach_posture"] = rhs.detach_posture;
715 node[
"weight"] = rhs.weight;
719 bool convert<moveit_msgs::AttachedCollisionObject>::decode(
const Node &node,
720 moveit_msgs::AttachedCollisionObject &rhs)
722 rhs = moveit_msgs::AttachedCollisionObject();
725 rhs.link_name = node[
"link_name"].as<
std::string>();
728 rhs.object = node[
"object"].as<moveit_msgs::CollisionObject>();
734 rhs.detach_posture = node[
"detach_posture"].as<trajectory_msgs::JointTrajectory>();
737 rhs.weight = node[
"weight"].as<
double>();
742 Node convert<trajectory_msgs::JointTrajectory>::encode(
const trajectory_msgs::JointTrajectory &rhs)
746 if (!isHeaderEmpty(rhs.header))
747 node[
"header"] = rhs.header;
749 node[
"joint_names"] = rhs.joint_names;
751 node[
"points"] = rhs.points;
755 bool convert<trajectory_msgs::JointTrajectory>::decode(
const Node &node,
756 trajectory_msgs::JointTrajectory &rhs)
758 rhs = trajectory_msgs::JointTrajectory();
761 rhs.header = node[
"header"].as<std_msgs::Header>();
763 rhs.header = getDefaultHeader();
775 convert<trajectory_msgs::JointTrajectoryPoint>::encode(
const trajectory_msgs::JointTrajectoryPoint &rhs)
779 if (!rhs.positions.empty())
781 node[
"positions"] = rhs.positions;
785 if (!rhs.velocities.empty())
787 node[
"velocities"] = rhs.velocities;
791 if (!rhs.accelerations.empty())
793 node[
"accelerations"] = rhs.accelerations;
797 if (!rhs.effort.empty())
799 node[
"effort"] = rhs.effort;
803 node[
"time_from_start"] = rhs.time_from_start;
808 bool convert<trajectory_msgs::JointTrajectoryPoint>::decode(
const Node &node,
809 trajectory_msgs::JointTrajectoryPoint &rhs)
824 rhs.time_from_start = node[
"time_from_start"].as<ros::Duration>();
829 Node convert<moveit_msgs::CollisionObject>::encode(
const moveit_msgs::CollisionObject &rhs)
833 if (!isHeaderEmpty(rhs.header))
834 node[
"header"] = rhs.header;
838 #if ROBOWFLEX_MOVEIT_VERSION >= ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6)
839 node[
"pose"] = rhs.pose;
842 if (!rhs.type.key.empty())
843 node[
"type"] = rhs.type;
845 if (!rhs.primitives.empty())
847 node[
"primitives"] = rhs.primitives;
848 node[
"primitive_poses"] = rhs.primitive_poses;
851 if (!rhs.meshes.empty())
853 node[
"meshes"] = rhs.meshes;
854 node[
"mesh_poses"] = rhs.mesh_poses;
857 if (!rhs.planes.empty())
859 node[
"planes"] = rhs.planes;
860 node[
"plane_poses"] = rhs.plane_poses;
864 switch (rhs.operation)
866 case moveit_msgs::CollisionObject::REMOVE:
869 case moveit_msgs::CollisionObject::APPEND:
872 case moveit_msgs::CollisionObject::MOVE:
879 node[
"operation"] = s;
883 bool convert<moveit_msgs::CollisionObject>::decode(
const Node &node, moveit_msgs::CollisionObject &rhs)
887 rhs = moveit_msgs::CollisionObject();
890 rhs.header = node[
"header"].as<std_msgs::Header>();
892 rhs.header = getDefaultHeader();
899 pose_msg = node[
"pose"].as<geometry_msgs::Pose>();
903 #if ROBOWFLEX_MOVEIT_VERSION >= ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6)
908 rhs.type = node[
"type"].as<object_recognition_msgs::ObjectType>();
916 #if ROBOWFLEX_MOVEIT_VERSION < ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6)
917 for (
auto &primitive_pose : rhs.primitive_poses)
928 #if ROBOWFLEX_MOVEIT_VERSION < ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6)
929 for (
auto &mesh_pose : rhs.mesh_poses)
940 #if ROBOWFLEX_MOVEIT_VERSION < ROBOWFLEX_MOVEIT_VERSION_COMPUTE(1, 1, 6)
941 for (
auto &plane_pose : rhs.plane_poses)
947 rhs.operation = nodeToCollisionObject(node[
"operation"]);
952 Node convert<object_recognition_msgs::ObjectType>::encode(
const object_recognition_msgs::ObjectType &rhs)
955 node[
"key"] = rhs.key;
960 bool convert<object_recognition_msgs::ObjectType>::decode(
const Node &node,
961 object_recognition_msgs::ObjectType &rhs)
963 rhs = object_recognition_msgs::ObjectType();
974 Node convert<moveit_msgs::LinkPadding>::encode(
const moveit_msgs::LinkPadding &rhs)
977 node[
"link_name"] = rhs.link_name;
978 node[
"padding"] = rhs.padding;
982 bool convert<moveit_msgs::LinkPadding>::decode(
const Node &node, moveit_msgs::LinkPadding &rhs)
984 rhs = moveit_msgs::LinkPadding();
987 rhs.link_name = node[
"link_name"].as<
std::string>();
990 rhs.padding = node[
"padding"].as<
double>();
995 Node convert<moveit_msgs::LinkScale>::encode(
const moveit_msgs::LinkScale &rhs)
998 node[
"link_name"] = rhs.link_name;
999 node[
"scale"] = rhs.scale;
1003 bool convert<moveit_msgs::LinkScale>::decode(
const Node &node, moveit_msgs::LinkScale &rhs)
1005 rhs = moveit_msgs::LinkScale();
1008 rhs.link_name = node[
"link_name"].as<
std::string>();
1011 rhs.scale = node[
"scale"].as<
double>();
1016 Node convert<moveit_msgs::ObjectColor>::encode(
const moveit_msgs::ObjectColor &rhs)
1019 node[
"id"] = rhs.id;
1020 node[
"color"] = rhs.color;
1024 bool convert<moveit_msgs::ObjectColor>::decode(
const Node &node, moveit_msgs::ObjectColor &rhs)
1026 rhs = moveit_msgs::ObjectColor();
1032 rhs.color = node[
"color"].as<std_msgs::ColorRGBA>();
1037 Node convert<std_msgs::ColorRGBA>::encode(
const std_msgs::ColorRGBA &rhs)
1042 node.push_back(rhs.r);
1043 node.push_back(rhs.g);
1044 node.push_back(rhs.b);
1045 node.push_back(rhs.a);
1049 bool convert<std_msgs::ColorRGBA>::decode(
const Node &node, std_msgs::ColorRGBA &rhs)
1051 rhs = std_msgs::ColorRGBA();
1053 rhs.r = node[0].as<
double>();
1054 rhs.g = node[1].as<
double>();
1055 rhs.b = node[2].as<
double>();
1056 rhs.a = node[3].as<
double>();
1060 Node convert<moveit_msgs::AllowedCollisionMatrix>::encode(
const moveit_msgs::AllowedCollisionMatrix &rhs)
1063 node[
"entry_names"] = rhs.entry_names;
1066 node[
"entry_values"] = rhs.entry_values;
1068 if (!rhs.default_entry_values.empty())
1070 node[
"default_entry_names"] = rhs.entry_names;
1074 for (
const auto &b : rhs.default_entry_values)
1077 node[
"default_entry_values"] = default_entry_values;
1084 bool convert<moveit_msgs::AllowedCollisionMatrix>::decode(
const Node &node,
1085 moveit_msgs::AllowedCollisionMatrix &rhs)
1087 rhs = moveit_msgs::AllowedCollisionMatrix();
1098 if (
IO::isNode(node[
"default_entry_values"]))
1100 const auto &dev = node[
"default_entry_values"];
1101 for (
const auto &b : dev)
1102 rhs.default_entry_values.
push_back(nodeToBool(b));
1108 Node convert<moveit_msgs::AllowedCollisionEntry>::encode(
const moveit_msgs::AllowedCollisionEntry &rhs)
1112 for (
const auto &b : rhs.enabled)
1120 bool convert<moveit_msgs::AllowedCollisionEntry>::decode(
const Node &node,
1121 moveit_msgs::AllowedCollisionEntry &rhs)
1123 rhs = moveit_msgs::AllowedCollisionEntry();
1125 for (
const auto &b : node)
1126 rhs.enabled.push_back(nodeToBool(b));
1131 Node convert<moveit_msgs::PlanningSceneWorld>::encode(
const moveit_msgs::PlanningSceneWorld &rhs)
1135 if (!rhs.collision_objects.empty())
1136 node[
"collision_objects"] = rhs.collision_objects;
1138 if (!rhs.octomap.octomap.data.empty())
1139 node[
"octomap"] = rhs.octomap;
1144 bool convert<moveit_msgs::PlanningSceneWorld>::decode(
const Node &node,
1145 moveit_msgs::PlanningSceneWorld &rhs)
1147 rhs = moveit_msgs::PlanningSceneWorld();
1153 rhs.octomap = node[
"octomap"].as<octomap_msgs::OctomapWithPose>();
1158 Node convert<octomap_msgs::Octomap>::encode(
const octomap_msgs::Octomap &rhs)
1162 if (!isHeaderEmpty(rhs.header))
1163 node[
"header"] = rhs.header;
1165 node[
"binary"] = boolToString(rhs.binary);
1166 node[
"id"] = rhs.id;
1167 node[
"resolution"] = rhs.resolution;
1168 node[
"data"] = compressHex(rhs.data);
1173 bool convert<octomap_msgs::Octomap>::decode(
const Node &node, octomap_msgs::Octomap &rhs)
1175 rhs = octomap_msgs::Octomap();
1178 rhs.header = node[
"header"].as<std_msgs::Header>();
1180 rhs.header = getDefaultHeader();
1183 rhs.binary = nodeToBool(node[
"binary"]);
1189 rhs.resolution = node[
"resolution"].as<
double>();
1194 if (node[
"data"].IsSequence())
1202 rhs.
data = decompressHex(temp);
1209 Node convert<octomap_msgs::OctomapWithPose>::encode(
const octomap_msgs::OctomapWithPose &rhs)
1213 if (!isHeaderEmpty(rhs.header))
1214 node[
"header"] = rhs.header;
1216 node[
"origin"] = rhs.origin;
1217 node[
"octomap"] = rhs.octomap;
1221 bool convert<octomap_msgs::OctomapWithPose>::decode(
const Node &node, octomap_msgs::OctomapWithPose &rhs)
1223 rhs = octomap_msgs::OctomapWithPose();
1226 rhs.header = node[
"header"].as<std_msgs::Header>();
1228 rhs.header = getDefaultHeader();
1231 rhs.origin = node[
"origin"].as<geometry_msgs::Pose>();
1234 rhs.octomap = node[
"octomap"].as<octomap_msgs::Octomap>();
1239 Node convert<ros::Time>::encode(
const ros::Time &rhs)
1246 bool convert<ros::Time>::decode(
const Node &node, ros::Time &rhs)
1248 rhs.fromSec(node.as<
double>());
1252 Node convert<ros::Duration>::encode(
const ros::Duration &rhs)
1259 bool convert<ros::Duration>::decode(
const Node &node, ros::Duration &rhs)
1261 if (node.Type() == NodeType::Scalar) {
1262 rhs.fromSec(node.as<
double>());
1267 rhs.sec = node[
"sec"].as<
int>();
1268 rhs.nsec = node[
"nsec"].as<
int>();
1270 catch (YAML::InvalidNode &e)
1272 rhs.sec = node[
"secs"].as<
int>();
1273 rhs.nsec = node[
"nsecs"].as<
int>();
1278 Node convert<shape_msgs::SolidPrimitive>::encode(
const shape_msgs::SolidPrimitive &rhs)
1281 node[
"type"] = primitiveTypeToString(rhs);
1282 node[
"dimensions"] = rhs.dimensions;
1287 bool convert<shape_msgs::SolidPrimitive>::decode(
const Node &node, shape_msgs::SolidPrimitive &rhs)
1289 rhs = shape_msgs::SolidPrimitive();
1291 nodeToPrimitiveType(node[
"type"], rhs);
1299 Node convert<shape_msgs::Mesh>::encode(
const shape_msgs::Mesh &rhs)
1302 node[
"triangles"] = rhs.triangles;
1303 node[
"vertices"] = rhs.vertices;
1308 bool convert<shape_msgs::Mesh>::decode(
const Node &node, shape_msgs::Mesh &rhs)
1310 rhs = shape_msgs::Mesh();
1314 Eigen::Vector3d dimensions{1, 1, 1};
1322 Geometry mesh(Geometry::ShapeType::Type::MESH, dimensions, resource);
1335 Node convert<shape_msgs::MeshTriangle>::encode(
const shape_msgs::MeshTriangle &rhs)
1339 node.push_back(rhs.vertex_indices[1]);
1340 node.push_back(rhs.vertex_indices[2]);
1345 bool convert<shape_msgs::MeshTriangle>::decode(
const Node &node, shape_msgs::MeshTriangle &rhs)
1347 rhs.vertex_indices[0] = node[0].as<
double>();
1348 rhs.vertex_indices[1] = node[1].as<
double>();
1349 rhs.vertex_indices[2] = node[2].as<
double>();
1353 Node convert<shape_msgs::Plane>::encode(
const shape_msgs::Plane &rhs)
1356 node[
"coef"].push_back(rhs.coef[0]);
1357 node[
"coef"].push_back(rhs.coef[1]);
1358 node[
"coef"].push_back(rhs.coef[2]);
1359 node[
"coef"].push_back(rhs.coef[3]);
1364 bool convert<shape_msgs::Plane>::decode(
const Node &node, shape_msgs::Plane &rhs)
1366 rhs.coef[0] = node[
"coef"][0].as<
double>();
1367 rhs.coef[1] = node[
"coef"][1].as<
double>();
1368 rhs.coef[2] = node[
"coef"][2].as<
double>();
1369 rhs.coef[3] = node[
"coef"][3].as<
double>();
1373 Node convert<moveit_msgs::WorkspaceParameters>::encode(
const moveit_msgs::WorkspaceParameters &rhs)
1376 if (!isHeaderEmpty(rhs.header))
1377 node[
"header"] = rhs.header;
1379 node[
"min_corner"] = rhs.min_corner;
1380 node[
"max_corner"] = rhs.max_corner;
1384 bool convert<moveit_msgs::WorkspaceParameters>::decode(
const Node &node,
1385 moveit_msgs::WorkspaceParameters &rhs)
1387 rhs = moveit_msgs::WorkspaceParameters();
1390 rhs.header = node[
"header"].as<std_msgs::Header>();
1392 rhs.header = getDefaultHeader();
1394 rhs.min_corner = node[
"min_corner"].as<geometry_msgs::Vector3>();
1395 rhs.max_corner = node[
"max_corner"].as<geometry_msgs::Vector3>();
1399 Node convert<moveit_msgs::Constraints>::encode(
const moveit_msgs::Constraints &rhs)
1403 if (!rhs.name.empty())
1404 node[
"name"] = rhs.name;
1406 if (!rhs.joint_constraints.empty())
1407 node[
"joint_constraints"] = rhs.joint_constraints;
1409 if (!rhs.position_constraints.empty())
1410 node[
"position_constraints"] = rhs.position_constraints;
1412 if (!rhs.orientation_constraints.empty())
1413 node[
"orientation_constraints"] = rhs.orientation_constraints;
1415 if (!rhs.visibility_constraints.empty())
1416 node[
"visibility_constraints"] = rhs.visibility_constraints;
1421 bool convert<moveit_msgs::Constraints>::decode(
const Node &node, moveit_msgs::Constraints &rhs)
1423 rhs = moveit_msgs::Constraints();
1431 if (
IO::isNode(node[
"position_constraints"]))
1432 rhs.position_constraints =
1435 if (
IO::isNode(node[
"orientation_constraints"]))
1436 rhs.orientation_constraints =
1439 if (
IO::isNode(node[
"visibility_constraints"]))
1440 rhs.visibility_constraints =
1446 Node convert<moveit_msgs::JointConstraint>::encode(
const moveit_msgs::JointConstraint &rhs)
1449 node[
"joint_name"] = rhs.joint_name;
1450 node[
"position"] = rhs.position;
1453 node[
"tolerance_above"] = rhs.tolerance_above;
1456 node[
"tolerance_below"] = rhs.tolerance_below;
1459 node[
"weight"] = rhs.weight;
1464 bool convert<moveit_msgs::JointConstraint>::decode(
const Node &node, moveit_msgs::JointConstraint &rhs)
1466 rhs.joint_name = node[
"joint_name"].as<
std::string>();
1467 rhs.position = node[
"position"].as<
double>();
1470 rhs.tolerance_above = node[
"tolerance_above"].as<
double>();
1475 rhs.tolerance_below = node[
"tolerance_below"].as<
double>();
1480 rhs.weight = node[
"weight"].as<
double>();
1487 Node convert<moveit_msgs::PositionConstraint>::encode(
const moveit_msgs::PositionConstraint &rhs)
1490 if (!isHeaderEmpty(rhs.header))
1491 node[
"header"] = rhs.header;
1493 node[
"link_name"] = rhs.link_name;
1495 if (!isVector3Zero(rhs.target_point_offset))
1496 node[
"target_point_offset"] = rhs.target_point_offset;
1498 node[
"constraint_region"] = rhs.constraint_region;
1501 node[
"weight"] = rhs.weight;
1506 bool convert<moveit_msgs::PositionConstraint>::decode(
const Node &node,
1507 moveit_msgs::PositionConstraint &rhs)
1509 rhs = moveit_msgs::PositionConstraint();
1513 rhs.header = node[
"header"].as<std_msgs::Header>();
1515 rhs.header = getDefaultHeader();
1517 rhs.link_name = node[
"link_name"].as<
std::string>();
1519 rhs.target_point_offset = node[
"target_point_offset"].as<geometry_msgs::Vector3>();
1521 rhs.constraint_region = node[
"constraint_region"].as<moveit_msgs::BoundingVolume>();
1523 rhs.weight = node[
"weight"].as<
double>();
1530 Node convert<moveit_msgs::OrientationConstraint>::encode(
const moveit_msgs::OrientationConstraint &rhs)
1534 if (!isHeaderEmpty(rhs.header))
1535 node[
"header"] = rhs.header;
1537 node[
"orientation"] = rhs.orientation;
1538 node[
"link_name"] = rhs.link_name;
1540 node[
"absolute_x_axis_tolerance"] = rhs.absolute_x_axis_tolerance;
1541 node[
"absolute_y_axis_tolerance"] = rhs.absolute_y_axis_tolerance;
1542 node[
"absolute_z_axis_tolerance"] = rhs.absolute_z_axis_tolerance;
1545 node[
"weight"] = rhs.weight;
1550 bool convert<moveit_msgs::OrientationConstraint>::decode(
const Node &node,
1551 moveit_msgs::OrientationConstraint &rhs)
1554 rhs.header = node[
"header"].as<std_msgs::Header>();
1556 rhs.header = getDefaultHeader();
1558 rhs.orientation = node[
"orientation"].as<geometry_msgs::Quaternion>();
1559 rhs.link_name = node[
"link_name"].as<
std::string>();
1561 rhs.absolute_x_axis_tolerance = node[
"absolute_x_axis_tolerance"].as<
double>();
1562 rhs.absolute_y_axis_tolerance = node[
"absolute_y_axis_tolerance"].as<
double>();
1563 rhs.absolute_z_axis_tolerance = node[
"absolute_z_axis_tolerance"].as<
double>();
1566 rhs.weight = node[
"weight"].as<
double>();
1573 Node convert<moveit_msgs::VisibilityConstraint>::encode(
const moveit_msgs::VisibilityConstraint &rhs)
1576 node[
"target_radius"] = rhs.target_radius;
1577 node[
"target_pose"] = rhs.target_pose;
1578 node[
"cone_sides"] = rhs.cone_sides;
1579 node[
"sensor_pose"] = rhs.sensor_pose;
1580 node[
"max_view_angle"] = rhs.max_view_angle;
1581 node[
"max_range_angle"] = rhs.max_range_angle;
1582 node[
"sensor_view_direction"] = rhs.sensor_view_direction;
1583 node[
"weight"] = rhs.weight;
1587 bool convert<moveit_msgs::VisibilityConstraint>::decode(
const Node &node,
1588 moveit_msgs::VisibilityConstraint &rhs)
1590 rhs = moveit_msgs::VisibilityConstraint();
1592 rhs.target_radius = node[
"target_radius"].as<
double>();
1593 rhs.target_pose = node[
"target_pose"].as<geometry_msgs::PoseStamped>();
1594 rhs.cone_sides = node[
"cone_sides"].as<
int>();
1595 rhs.sensor_pose = node[
"sensor_pose"].as<geometry_msgs::PoseStamped>();
1596 rhs.max_view_angle = node[
"max_view_angle"].as<
double>();
1597 rhs.max_range_angle = node[
"max_range_angle"].as<
double>();
1598 rhs.sensor_view_direction = node[
"sensor_view_direction"].as<
int>();
1599 rhs.weight = node[
"weight"].as<
double>();
1604 Node convert<moveit_msgs::BoundingVolume>::encode(
const moveit_msgs::BoundingVolume &rhs)
1608 if (!rhs.primitives.empty())
1610 node[
"primitives"] = rhs.primitives;
1611 node[
"primitive_poses"] = rhs.primitive_poses;
1614 if (!rhs.meshes.empty())
1616 node[
"meshes"] = rhs.meshes;
1617 node[
"mesh_poses"] = rhs.mesh_poses;
1623 bool convert<moveit_msgs::BoundingVolume>::decode(
const Node &node, moveit_msgs::BoundingVolume &rhs)
1625 rhs = moveit_msgs::BoundingVolume();
1642 Node convert<moveit_msgs::TrajectoryConstraints>::encode(
const moveit_msgs::TrajectoryConstraints &rhs)
1645 node[
"constraints"] = rhs.constraints;
1649 bool convert<moveit_msgs::TrajectoryConstraints>::decode(
const Node &node,
1650 moveit_msgs::TrajectoryConstraints &rhs)
1656 Node convert<moveit_msgs::MotionPlanRequest>::encode(
const moveit_msgs::MotionPlanRequest &rhs)
1660 if (!(isHeaderEmpty(rhs.workspace_parameters.header) &&
1661 isVector3Zero(rhs.workspace_parameters.min_corner) &&
1662 isVector3Zero(rhs.workspace_parameters.max_corner)))
1663 node[
"workspace_parameters"] = rhs.workspace_parameters;
1665 node[
"start_state"] = rhs.start_state;
1667 if (!rhs.goal_constraints.empty())
1668 node[
"goal_constraints"] = rhs.goal_constraints;
1670 if (!isConstraintEmpty(rhs.path_constraints))
1671 node[
"path_constraints"] = rhs.path_constraints;
1673 if (!rhs.trajectory_constraints.constraints.empty())
1674 node[
"trajectory_constraints"] = rhs.trajectory_constraints;
1676 if (!rhs.planner_id.empty())
1677 node[
"planner_id"] = rhs.planner_id;
1679 if (!rhs.group_name.empty())
1680 node[
"group_name"] = rhs.group_name;
1682 if (rhs.num_planning_attempts != 0)
1683 node[
"num_planning_attempts"] = rhs.num_planning_attempts;
1685 if (rhs.allowed_planning_time != 0)
1686 node[
"allowed_planning_time"] = rhs.allowed_planning_time;
1688 if (rhs.max_velocity_scaling_factor < 1)
1689 node[
"max_velocity_scaling_factor"] = rhs.max_velocity_scaling_factor;
1691 if (rhs.max_acceleration_scaling_factor < 1)
1692 node[
"max_acceleration_scaling_factor"] = rhs.max_acceleration_scaling_factor;
1697 bool convert<moveit_msgs::MotionPlanRequest>::decode(
const Node &node,
1698 moveit_msgs::MotionPlanRequest &rhs)
1700 rhs = moveit_msgs::MotionPlanRequest();
1702 if (
IO::isNode(node[
"workspace_parameters"]))
1703 rhs.workspace_parameters = node[
"workspace_parameters"].as<moveit_msgs::WorkspaceParameters>();
1706 rhs.start_state = node[
"start_state"].as<moveit_msgs::RobotState>();
1712 rhs.path_constraints = node[
"path_constraints"].as<moveit_msgs::Constraints>();
1714 if (
IO::isNode(node[
"trajectory_constraints"]))
1715 rhs.trajectory_constraints =
1716 node[
"trajectory_constraints"].as<moveit_msgs::TrajectoryConstraints>();
1719 rhs.planner_id = node[
"planner_id"].as<
std::string>();
1722 rhs.group_name = node[
"group_name"].as<
std::string>();
1724 if (
IO::isNode(node[
"num_planning_attempts"]))
1725 rhs.num_planning_attempts = node[
"num_planning_attempts"].as<
int>();
1727 rhs.num_planning_attempts = 0;
1729 if (
IO::isNode(node[
"allowed_planning_time"]))
1730 rhs.allowed_planning_time = node[
"allowed_planning_time"].as<
double>();
1732 rhs.allowed_planning_time = 0;
1734 if (
IO::isNode(node[
"max_velocity_scaling_factor"]))
1735 rhs.max_velocity_scaling_factor = node[
"max_velocity_scaling_factor"].as<
double>();
1737 rhs.max_velocity_scaling_factor = 1;
1739 if (
IO::isNode(node[
"max_acceleration_scaling_factor"]))
1740 rhs.max_acceleration_scaling_factor = node[
"max_acceleration_scaling_factor"].as<
double>();
1742 rhs.max_acceleration_scaling_factor = 1;
1747 Node convert<trajectory_msgs::MultiDOFJointTrajectory>::encode(
1748 const trajectory_msgs::MultiDOFJointTrajectory &rhs)
1752 if (!isHeaderEmpty(rhs.header))
1753 node[
"header"] = rhs.header;
1755 node[
"joint_names"] = rhs.joint_names;
1756 node[
"points"] = rhs.points;
1761 bool convert<trajectory_msgs::MultiDOFJointTrajectory>::decode(
1762 const Node &node, trajectory_msgs::MultiDOFJointTrajectory &rhs)
1764 rhs = trajectory_msgs::MultiDOFJointTrajectory();
1767 rhs.header = node[
"header"].as<std_msgs::Header>();
1778 Node convert<trajectory_msgs::MultiDOFJointTrajectoryPoint>::encode(
1779 const trajectory_msgs::MultiDOFJointTrajectoryPoint &rhs)
1783 if (!rhs.transforms.empty())
1784 node[
"transforms"] = rhs.transforms;
1786 if (!rhs.velocities.empty())
1787 node[
"velocities"] = rhs.velocities;
1789 if (!rhs.accelerations.empty())
1790 node[
"accelerations"] = rhs.accelerations;
1792 node[
"time_from_start"] = rhs.time_from_start;
1797 bool convert<trajectory_msgs::MultiDOFJointTrajectoryPoint>::decode(
1798 const Node &node, trajectory_msgs::MultiDOFJointTrajectoryPoint &rhs)
1800 rhs = trajectory_msgs::MultiDOFJointTrajectoryPoint();
1811 rhs.time_from_start = node[
"time_from_start"].as<ros::Duration>();
1815 Node convert<moveit_msgs::RobotTrajectory>::encode(
const moveit_msgs::RobotTrajectory &rhs)
1819 if (!rhs.joint_trajectory.points.empty())
1820 node[
"joint_trajectory"] = rhs.joint_trajectory;
1822 if (!rhs.multi_dof_joint_trajectory.points.empty())
1823 node[
"multi_dof_joint_trajectory"] = rhs.multi_dof_joint_trajectory;
1828 bool convert<moveit_msgs::RobotTrajectory>::decode(
const Node &node, moveit_msgs::RobotTrajectory &rhs)
1830 rhs = moveit_msgs::RobotTrajectory();
1833 rhs.joint_trajectory = node[
"joint_trajectory"].as<trajectory_msgs::JointTrajectory>();
1835 if (
IO::isNode(node[
"multi_dof_joint_trajectory"]))
1836 rhs.multi_dof_joint_trajectory =
1837 node[
"multi_dof_joint_trajectory"].as<trajectory_msgs::MultiDOFJointTrajectory>();
1851 bool r = node.IsDefined() and not node.IsNull();
1863 catch (YAML::InvalidNode &e)
1871 return node.as<moveit_msgs::RobotState>();
1874 YAML::Node
toNode(
const geometry_msgs::Pose &msg)
1883 return node.as<geometry_msgs::Pose>();
1886 YAML::Node
toNode(
const moveit_msgs::PlanningScene &msg)
1893 YAML::Node
toNode(
const moveit_msgs::MotionPlanRequest &msg)
1900 YAML::Node
toNode(
const moveit_msgs::RobotTrajectory &msg)
1907 YAML::Node
toNode(
const moveit_msgs::RobotState &msg)
T back_inserter(T... args)
A class that manages both solid and mesh geometry for various parts of the motion planning system.
const shape_msgs::Mesh getMeshMsg() const
Gets the message form of mesh geometry.
T emplace_back(T... args)
#define ROBOWFLEX_YAML_FLOW(n)
bool isNode(const YAML::Node &node)
Checks if a key exists within a YAML node.
bool fromYAMLFile(moveit_msgs::PlanningScene &msg, const std::string &file)
Loads a planning scene from a YAML file.
moveit_msgs::RobotState robotStateFromNode(const YAML::Node &node)
Converts a robot state YAML to a robot_state message.
geometry_msgs::Pose poseFromNode(const YAML::Node &node)
Converts a pose YAML to a goemetry message.
YAML::Node toNode(const geometry_msgs::Pose &msg)
Converts a pose message to YAML.
bool YAMLFileToMessage(T &msg, const std::string &file)
Load a message (or YAML convertable object) from a file.
RobotPose poseMsgToEigen(const geometry_msgs::Pose &msg)
Converts a pose message to RobotPose.
geometry_msgs::Pose poseEigenToMsg(const RobotPose &pose)
Converts an RobotPose to a pose message.
RobotPose identity()
Creates the Identity pose.
Main namespace. Contains all library classes and functions.
std::decay< decltype(std::declval< moveit::core::Transforms >().getTransform("")) >::type RobotPose
A pose (point in SE(3)) used in various functions. Defined from what MoveIt! uses.