14 #include <geometry_msgs/Pose.h> 15 #include <geometry_msgs/PoseWithCovariance.h> 16 #include <mrpt_msgs/NodeIDWithPose.h> 20 #include <mrpt/version.h> 21 #if MRPT_VERSION<0x199 24 #include <mrpt/graphs/TNodeID.h> 25 using mrpt::graphs::TNodeID;
36 const mrpt::graphs::CNetworkOfPoses2DInf& mrpt_graph,
37 mrpt_msgs::NetworkOfPoses& ros_graph)
42 using namespace mrpt::graphs;
46 typedef typename mrpt::graphs::CNetworkOfPoses2DInf::global_poses_t::
47 const_iterator poses_cit_t;
49 const CNetworkOfPoses2DInf::BASE::edges_map_t& constraints =
50 mrpt_graph.BASE::edges;
53 ros_graph.root = mrpt_graph.root;
56 for (poses_cit_t poses_cit = mrpt_graph.nodes.begin();
57 poses_cit != mrpt_graph.nodes.end(); ++poses_cit)
59 mrpt_msgs::NodeIDWithPose ros_node;
62 ros_node.nodeID = poses_cit->first;
64 convert(poses_cit->second, ros_node.pose);
67 ros_node.str_ID.data =
"";
68 ros_node.nodeID_loc = 0;
70 ros_graph.nodes.vec.push_back(ros_node);
74 for (CNetworkOfPoses2DInf::const_iterator constr_it = constraints.begin();
75 constr_it != constraints.end(); ++constr_it)
77 mrpt_msgs::GraphConstraint ros_constr;
80 ros_constr.nodeID_from = constr_it->first.first;
81 ros_constr.nodeID_to = constr_it->first.second;
84 if (mrpt_graph.edges_store_inverse_poses)
86 CPosePDFGaussianInf constr_inv;
87 constr_it->second.inverse(constr_inv);
88 convert(constr_inv, ros_constr.constraint);
92 convert(constr_it->second, ros_constr.constraint);
95 ros_graph.constraints.push_back(ros_constr);
102 const mrpt::graphs::CNetworkOfPoses3DInf& mrpt_graph,
103 mrpt_msgs::NetworkOfPoses& ros_graph)
105 THROW_EXCEPTION(
"Conversion not implemented yet");
107 "Implement CNetworkOfPoses3DInf => mrpt_msgs::NetworkOfPoses " 112 const mrpt::graphs::CNetworkOfPoses2DInf_NA& mrpt_graph,
113 mrpt_msgs::NetworkOfPoses& ros_graph)
119 using namespace mrpt::graphs;
123 typedef typename mrpt::graphs::CNetworkOfPoses2DInf_NA::global_poses_t::
124 const_iterator poses_cit_t;
133 const CNetworkOfPoses2DInf_NA::BASE::edges_map_t& constraints =
134 mrpt_graph.BASE::edges;
137 ros_graph.root = mrpt_graph.root;
140 for (poses_cit_t poses_cit = mrpt_graph.nodes.begin();
141 poses_cit != mrpt_graph.nodes.end(); ++poses_cit)
143 mrpt_msgs::NodeIDWithPose ros_node;
146 ros_node.nodeID = poses_cit->first;
148 convert(poses_cit->second, ros_node.pose);
151 ros_node.str_ID.data = poses_cit->second.agent_ID_str;
152 ros_node.nodeID_loc = poses_cit->second.nodeID_loc;
154 ros_graph.nodes.vec.push_back(ros_node);
159 for (CNetworkOfPoses2DInf::const_iterator constr_it = constraints.begin();
160 constr_it != constraints.end(); ++constr_it)
162 mrpt_msgs::GraphConstraint ros_constr;
165 ros_constr.nodeID_from = constr_it->first.first;
166 ros_constr.nodeID_to = constr_it->first.second;
169 if (mrpt_graph.edges_store_inverse_poses)
171 CPosePDFGaussianInf constr_inv;
172 constr_it->second.inverse(constr_inv);
173 convert(constr_inv, ros_constr.constraint);
177 convert(constr_it->second, ros_constr.constraint);
180 ros_graph.constraints.push_back(ros_constr);
187 const mrpt::graphs::CNetworkOfPoses3DInf_NA& mrpt_graph,
188 mrpt_msgs::NetworkOfPoses& ros_graph)
190 THROW_EXCEPTION(
"Conversion not implemented yet");
198 const mrpt_msgs::NetworkOfPoses& ros_graph,
199 mrpt::graphs::CNetworkOfPoses2DInf& mrpt_graph)
206 typedef NetworkOfPoses::_nodes_type::_vec_type::const_iterator nodes_cit_t;
207 typedef NetworkOfPoses::_constraints_type::const_iterator constraints_cit_t;
210 mrpt_graph.root = ros_graph.root;
213 for (nodes_cit_t nodes_cit = ros_graph.nodes.vec.begin();
214 nodes_cit != ros_graph.nodes.vec.end(); ++nodes_cit)
218 convert(nodes_cit->pose, mrpt_pose);
220 mrpt_graph.nodes.insert(
221 make_pair(static_cast<TNodeID>(nodes_cit->nodeID), mrpt_pose));
225 for (constraints_cit_t constr_cit = ros_graph.constraints.begin();
226 constr_cit != ros_graph.constraints.end(); ++constr_cit)
231 static_cast<TNodeID>(constr_cit->nodeID_from),
232 static_cast<TNodeID>(constr_cit->nodeID_to)));
235 mrpt::poses::CPosePDFGaussianInf mrpt_constr;
236 convert(constr_cit->constraint, mrpt_constr);
238 mrpt_graph.edges.insert(make_pair(constr_ends, mrpt_constr));
241 mrpt_graph.edges_store_inverse_poses =
false;
247 const mrpt_msgs::NetworkOfPoses& ros_graph,
248 mrpt::graphs::CNetworkOfPoses3DInf& mrpt_graph)
250 THROW_EXCEPTION(
"Conversion not implemented yet");
252 "Implement mrpt_msgs::NetworkOfPoses => CNetworkOfPoses3DInf " 257 const mrpt_msgs::NetworkOfPoses& ros_graph,
258 mrpt::graphs::CNetworkOfPoses2DInf_NA& mrpt_graph)
265 typedef NetworkOfPoses::_nodes_type::_vec_type::const_iterator nodes_cit_t;
266 typedef NetworkOfPoses::_constraints_type::const_iterator constraints_cit_t;
268 typedef mrpt::graphs::CNetworkOfPoses2DInf_NA::global_pose_t
272 mrpt_graph.root = ros_graph.root;
275 for (nodes_cit_t nodes_cit = ros_graph.nodes.vec.begin();
276 nodes_cit != ros_graph.nodes.vec.end(); ++nodes_cit)
278 mrpt_graph_pose_t mrpt_node;
281 convert(nodes_cit->pose, mrpt_node);
284 mrpt_node.agent_ID_str = nodes_cit->str_ID.data;
285 mrpt_node.nodeID_loc = nodes_cit->nodeID_loc;
287 mrpt_graph.nodes.insert(
288 make_pair(static_cast<TNodeID>(nodes_cit->nodeID), mrpt_node));
292 for (constraints_cit_t constr_cit = ros_graph.constraints.begin();
293 constr_cit != ros_graph.constraints.end(); ++constr_cit)
298 static_cast<TNodeID>(constr_cit->nodeID_from),
299 static_cast<TNodeID>(constr_cit->nodeID_to)));
302 mrpt::poses::CPosePDFGaussianInf mrpt_constr;
303 convert(constr_cit->constraint, mrpt_constr);
305 mrpt_graph.edges.insert(make_pair(constr_ends, mrpt_constr));
308 mrpt_graph.edges_store_inverse_poses =
false;
314 mrpt_msgs::NetworkOfPoses& ros_graph,
315 const mrpt::graphs::CNetworkOfPoses3DInf_NA& mrpt_graph)
317 THROW_EXCEPTION(
"Conversion not implemented yet");
void convert(mrpt_msgs::NetworkOfPoses &ros_graph, const mrpt::graphs::CNetworkOfPoses3DInf_NA &mrpt_graph)
File includes methods for converting CNetworkOfPoses*DInf <=> NetworkOfPoses message types...