10 #include <geometry_msgs/Pose.h> 11 #include <geometry_msgs/PoseWithCovariance.h> 12 #include <mrpt/graphs/TNodeID.h> 13 #include <mrpt/ros1bridge/pose.h> 14 #include <mrpt_msgs/NodeIDWithPose.h> 19 using mrpt::graphs::TNodeID;
26 const mrpt::graphs::CNetworkOfPoses2DInf& mrpt_graph,
27 mrpt_msgs::NetworkOfPoses& ros_graph)
31 using namespace mrpt::math;
32 using namespace mrpt::graphs;
33 using namespace mrpt::poses;
36 typedef typename mrpt::graphs::CNetworkOfPoses2DInf::global_poses_t::
37 const_iterator poses_cit_t;
39 const CNetworkOfPoses2DInf::BASE::edges_map_t& constraints =
40 mrpt_graph.BASE::edges;
43 ros_graph.root = mrpt_graph.root;
46 for (poses_cit_t poses_cit = mrpt_graph.nodes.begin();
47 poses_cit != mrpt_graph.nodes.end(); ++poses_cit)
49 mrpt_msgs::NodeIDWithPose ros_node;
52 ros_node.node_id = poses_cit->first;
54 ros_node.pose = mrpt::ros1bridge::toROS_Pose(poses_cit->second);
57 ros_node.str_id.data =
"";
58 ros_node.node_id_loc = 0;
60 ros_graph.nodes.vec.push_back(ros_node);
64 for (
const auto& edge : constraints)
66 mrpt_msgs::GraphConstraint ros_constr;
69 ros_constr.node_id_from = edge.first.first;
70 ros_constr.node_id_to = edge.first.second;
73 if (mrpt_graph.edges_store_inverse_poses)
75 CPosePDFGaussianInf constr_inv;
76 edge.second.inverse(constr_inv);
84 ros_graph.constraints.push_back(ros_constr);
91 [[maybe_unused]]
const mrpt::graphs::CNetworkOfPoses3DInf& mrpt_graph,
92 [[maybe_unused]] mrpt_msgs::NetworkOfPoses& ros_graph)
94 THROW_EXCEPTION(
"Conversion not implemented yet");
100 const mrpt::graphs::CNetworkOfPoses2DInf_NA& mrpt_graph,
101 mrpt_msgs::NetworkOfPoses& ros_graph)
106 using namespace mrpt::math;
107 using namespace mrpt::graphs;
108 using namespace mrpt::poses;
111 typedef typename mrpt::graphs::CNetworkOfPoses2DInf_NA::global_poses_t::
112 const_iterator poses_cit_t;
121 const CNetworkOfPoses2DInf_NA::BASE::edges_map_t& constraints =
122 mrpt_graph.BASE::edges;
125 ros_graph.root = mrpt_graph.root;
128 for (poses_cit_t poses_cit = mrpt_graph.nodes.begin();
129 poses_cit != mrpt_graph.nodes.end(); ++poses_cit)
131 mrpt_msgs::NodeIDWithPose ros_node;
134 ros_node.node_id = poses_cit->first;
136 ros_node.pose = mrpt::ros1bridge::toROS_Pose(poses_cit->second);
139 ros_node.str_id.data = poses_cit->second.agent_ID_str;
140 ros_node.node_id_loc = poses_cit->second.nodeID_loc;
142 ros_graph.nodes.vec.push_back(ros_node);
147 for (
const auto& edge : constraints)
149 mrpt_msgs::GraphConstraint ros_constr;
152 ros_constr.node_id_from = edge.first.first;
153 ros_constr.node_id_to = edge.first.second;
156 if (mrpt_graph.edges_store_inverse_poses)
158 CPosePDFGaussianInf constr_inv;
159 edge.second.inverse(constr_inv);
167 ros_graph.constraints.push_back(ros_constr);
174 [[maybe_unused]]
const mrpt::graphs::CNetworkOfPoses3DInf_NA& mrpt_graph,
175 [[maybe_unused]] mrpt_msgs::NetworkOfPoses& ros_graph)
177 THROW_EXCEPTION(
"Conversion not implemented yet");
185 const mrpt_msgs::NetworkOfPoses& ros_graph,
186 mrpt::graphs::CNetworkOfPoses2DInf& mrpt_graph)
189 using namespace mrpt::poses;
190 using namespace mrpt_msgs;
193 typedef NetworkOfPoses::_nodes_type::_vec_type::const_iterator nodes_cit_t;
194 typedef NetworkOfPoses::_constraints_type::const_iterator constraints_cit_t;
197 mrpt_graph.root = ros_graph.root;
200 for (nodes_cit_t nodes_cit = ros_graph.nodes.vec.begin();
201 nodes_cit != ros_graph.nodes.vec.end(); ++nodes_cit)
206 mrpt_graph.nodes.insert(
207 make_pair(static_cast<TNodeID>(nodes_cit->node_id), mrpt_pose));
211 for (constraints_cit_t constr_cit = ros_graph.constraints.begin();
212 constr_cit != ros_graph.constraints.end(); ++constr_cit)
215 auto constr_ends(make_pair(
216 static_cast<TNodeID>(constr_cit->node_id_from),
217 static_cast<TNodeID>(constr_cit->node_id_to)));
220 const auto mrpt_constr = mrpt::poses::CPosePDFGaussianInf(
223 mrpt_graph.edges.insert(make_pair(constr_ends, mrpt_constr));
226 mrpt_graph.edges_store_inverse_poses =
false;
232 [[maybe_unused]]
const mrpt_msgs::NetworkOfPoses& ros_graph,
233 [[maybe_unused]] mrpt::graphs::CNetworkOfPoses3DInf& mrpt_graph)
235 THROW_EXCEPTION(
"Conversion not implemented yet");
241 const mrpt_msgs::NetworkOfPoses& ros_graph,
242 mrpt::graphs::CNetworkOfPoses2DInf_NA& mrpt_graph)
245 using namespace mrpt::poses;
246 using namespace mrpt_msgs;
249 using nodes_cit_t = NetworkOfPoses::_nodes_type::_vec_type::const_iterator;
250 using constraints_cit_t = NetworkOfPoses::_constraints_type::const_iterator;
252 using mrpt_graph_pose_t =
253 mrpt::graphs::CNetworkOfPoses2DInf_NA::global_pose_t;
256 mrpt_graph.root = ros_graph.root;
259 for (nodes_cit_t nodes_cit = ros_graph.nodes.vec.begin();
260 nodes_cit != ros_graph.nodes.vec.end(); ++nodes_cit)
263 mrpt_graph_pose_t mrpt_node =
267 mrpt_node.agent_ID_str = nodes_cit->str_id.data;
268 mrpt_node.nodeID_loc = nodes_cit->node_id_loc;
270 mrpt_graph.nodes.insert(
271 make_pair(static_cast<TNodeID>(nodes_cit->node_id), mrpt_node));
275 for (constraints_cit_t constr_cit = ros_graph.constraints.begin();
276 constr_cit != ros_graph.constraints.end(); ++constr_cit)
279 auto constr_ends(make_pair(
280 static_cast<TNodeID>(constr_cit->node_id_from),
281 static_cast<TNodeID>(constr_cit->node_id_to)));
284 const auto mrpt_constr = mrpt::poses::CPosePDFGaussianInf(
287 mrpt_graph.edges.insert(make_pair(constr_ends, mrpt_constr));
290 mrpt_graph.edges_store_inverse_poses =
false;
296 [[maybe_unused]] mrpt_msgs::NetworkOfPoses& ros_graph,
297 [[maybe_unused]]
const mrpt::graphs::CNetworkOfPoses3DInf_NA& mrpt_graph)
299 THROW_EXCEPTION(
"Conversion not implemented yet");
void convert([[maybe_unused]] mrpt_msgs::NetworkOfPoses &ros_graph, [[maybe_unused]] const mrpt::graphs::CNetworkOfPoses3DInf_NA &mrpt_graph)
bool toROS(const mrpt::obs::CObservationBeaconRanges &_obj, mrpt_msgs::ObservationRangeBeacon &_msg)
bool fromROS(const mrpt_msgs::ObservationRangeBeacon &_msg, const mrpt::poses::CPose3D &_pose, mrpt::obs::CObservationBeaconRanges &_obj)