13 #include <geometry_msgs/Pose.h>
14 #include <geometry_msgs/PoseWithCovariance.h>
15 #include <mrpt_msgs/NodeIDWithPose.h>
19 #include <mrpt/version.h>
20 #if MRPT_VERSION < 0x199
23 #include <mrpt/graphs/TNodeID.h>
24 using mrpt::graphs::TNodeID;
34 const mrpt::graphs::CNetworkOfPoses2DInf& mrpt_graph,
35 mrpt_msgs::NetworkOfPoses& ros_graph)
40 using namespace mrpt::graphs;
44 typedef typename mrpt::graphs::CNetworkOfPoses2DInf::global_poses_t::
45 const_iterator poses_cit_t;
47 const CNetworkOfPoses2DInf::BASE::edges_map_t& constraints =
48 mrpt_graph.BASE::edges;
51 ros_graph.root = mrpt_graph.root;
54 for (poses_cit_t poses_cit = mrpt_graph.nodes.begin();
55 poses_cit != mrpt_graph.nodes.end(); ++poses_cit)
57 mrpt_msgs::NodeIDWithPose ros_node;
60 ros_node.nodeID = poses_cit->first;
62 convert(poses_cit->second, ros_node.pose);
65 ros_node.str_ID.data =
"";
66 ros_node.nodeID_loc = 0;
68 ros_graph.nodes.vec.push_back(ros_node);
72 for (CNetworkOfPoses2DInf::const_iterator constr_it = constraints.begin();
73 constr_it != constraints.end(); ++constr_it)
75 mrpt_msgs::GraphConstraint ros_constr;
78 ros_constr.nodeID_from = constr_it->first.first;
79 ros_constr.nodeID_to = constr_it->first.second;
82 if (mrpt_graph.edges_store_inverse_poses)
84 CPosePDFGaussianInf constr_inv;
85 constr_it->second.inverse(constr_inv);
86 convert(constr_inv, ros_constr.constraint);
90 convert(constr_it->second, ros_constr.constraint);
93 ros_graph.constraints.push_back(ros_constr);
100 const mrpt::graphs::CNetworkOfPoses3DInf& mrpt_graph,
101 mrpt_msgs::NetworkOfPoses& ros_graph)
103 THROW_EXCEPTION(
"Conversion not implemented yet");
105 "Implement CNetworkOfPoses3DInf => mrpt_msgs::NetworkOfPoses "
110 const mrpt::graphs::CNetworkOfPoses2DInf_NA& mrpt_graph,
111 mrpt_msgs::NetworkOfPoses& ros_graph)
117 using namespace mrpt::graphs;
121 typedef typename mrpt::graphs::CNetworkOfPoses2DInf_NA::global_poses_t::
122 const_iterator poses_cit_t;
131 const CNetworkOfPoses2DInf_NA::BASE::edges_map_t& constraints =
132 mrpt_graph.BASE::edges;
135 ros_graph.root = mrpt_graph.root;
138 for (poses_cit_t poses_cit = mrpt_graph.nodes.begin();
139 poses_cit != mrpt_graph.nodes.end(); ++poses_cit)
141 mrpt_msgs::NodeIDWithPose ros_node;
144 ros_node.nodeID = poses_cit->first;
146 convert(poses_cit->second, ros_node.pose);
149 ros_node.str_ID.data = poses_cit->second.agent_ID_str;
150 ros_node.nodeID_loc = poses_cit->second.nodeID_loc;
152 ros_graph.nodes.vec.push_back(ros_node);
157 for (CNetworkOfPoses2DInf::const_iterator constr_it = constraints.begin();
158 constr_it != constraints.end(); ++constr_it)
160 mrpt_msgs::GraphConstraint ros_constr;
163 ros_constr.nodeID_from = constr_it->first.first;
164 ros_constr.nodeID_to = constr_it->first.second;
167 if (mrpt_graph.edges_store_inverse_poses)
169 CPosePDFGaussianInf constr_inv;
170 constr_it->second.inverse(constr_inv);
171 convert(constr_inv, ros_constr.constraint);
175 convert(constr_it->second, ros_constr.constraint);
178 ros_graph.constraints.push_back(ros_constr);
185 const mrpt::graphs::CNetworkOfPoses3DInf_NA& mrpt_graph,
186 mrpt_msgs::NetworkOfPoses& ros_graph)
188 THROW_EXCEPTION(
"Conversion not implemented yet");
196 const mrpt_msgs::NetworkOfPoses& ros_graph,
197 mrpt::graphs::CNetworkOfPoses2DInf& mrpt_graph)
204 typedef NetworkOfPoses::_nodes_type::_vec_type::const_iterator nodes_cit_t;
205 typedef NetworkOfPoses::_constraints_type::const_iterator constraints_cit_t;
208 mrpt_graph.root = ros_graph.root;
211 for (nodes_cit_t nodes_cit = ros_graph.nodes.vec.begin();
212 nodes_cit != ros_graph.nodes.vec.end(); ++nodes_cit)
216 convert(nodes_cit->pose, mrpt_pose);
218 mrpt_graph.nodes.insert(
219 make_pair(
static_cast<TNodeID
>(nodes_cit->nodeID), mrpt_pose));
223 for (constraints_cit_t constr_cit = ros_graph.constraints.begin();
224 constr_cit != ros_graph.constraints.end(); ++constr_cit)
227 auto constr_ends(make_pair(
228 static_cast<TNodeID
>(constr_cit->nodeID_from),
229 static_cast<TNodeID
>(constr_cit->nodeID_to)));
232 mrpt::poses::CPosePDFGaussianInf mrpt_constr;
233 convert(constr_cit->constraint, mrpt_constr);
235 mrpt_graph.edges.insert(make_pair(constr_ends, mrpt_constr));
238 mrpt_graph.edges_store_inverse_poses =
false;
244 const mrpt_msgs::NetworkOfPoses& ros_graph,
245 mrpt::graphs::CNetworkOfPoses3DInf& mrpt_graph)
247 THROW_EXCEPTION(
"Conversion not implemented yet");
249 "Implement mrpt_msgs::NetworkOfPoses => CNetworkOfPoses3DInf "
254 const mrpt_msgs::NetworkOfPoses& ros_graph,
255 mrpt::graphs::CNetworkOfPoses2DInf_NA& mrpt_graph)
262 typedef NetworkOfPoses::_nodes_type::_vec_type::const_iterator nodes_cit_t;
263 typedef NetworkOfPoses::_constraints_type::const_iterator constraints_cit_t;
265 typedef mrpt::graphs::CNetworkOfPoses2DInf_NA::global_pose_t
269 mrpt_graph.root = ros_graph.root;
272 for (nodes_cit_t nodes_cit = ros_graph.nodes.vec.begin();
273 nodes_cit != ros_graph.nodes.vec.end(); ++nodes_cit)
275 mrpt_graph_pose_t mrpt_node;
278 convert(nodes_cit->pose, mrpt_node);
281 mrpt_node.agent_ID_str = nodes_cit->str_ID.data;
282 mrpt_node.nodeID_loc = nodes_cit->nodeID_loc;
284 mrpt_graph.nodes.insert(
285 make_pair(
static_cast<TNodeID
>(nodes_cit->nodeID), mrpt_node));
289 for (constraints_cit_t constr_cit = ros_graph.constraints.begin();
290 constr_cit != ros_graph.constraints.end(); ++constr_cit)
293 auto constr_ends(make_pair(
294 static_cast<TNodeID
>(constr_cit->nodeID_from),
295 static_cast<TNodeID
>(constr_cit->nodeID_to)));
298 mrpt::poses::CPosePDFGaussianInf mrpt_constr;
299 convert(constr_cit->constraint, mrpt_constr);
301 mrpt_graph.edges.insert(make_pair(constr_ends, mrpt_constr));
304 mrpt_graph.edges_store_inverse_poses =
false;
310 mrpt_msgs::NetworkOfPoses& ros_graph,
311 const mrpt::graphs::CNetworkOfPoses3DInf_NA& mrpt_graph)
313 THROW_EXCEPTION(
"Conversion not implemented yet");