CGraphSlamHandler_ROS.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2016, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 
10 #pragma once
11 
12 // ROS
13 #include <ros/ros.h>
15 #include <mrpt_msgs/GraphSlamStats.h>
16 #include <geometry_msgs/PoseStamped.h>
17 #include <geometry_msgs/PoseArray.h>
18 #include <geometry_msgs/TransformStamped.h>
19 #include <sensor_msgs/LaserScan.h>
20 #include <nav_msgs/Path.h>
21 #include <nav_msgs/Odometry.h>
22 #include <nav_msgs/OccupancyGrid.h>
23 #include <std_msgs/Header.h>
24 
25 #include <tf/transform_datatypes.h>
26 #include <tf2_ros/buffer.h>
30 #include <tf2/LinearMath/Vector3.h>
31 
32 // MRPT
34 #include <mrpt/maps/COccupancyGridMap2D.h>
35 #include <mrpt/obs/CObservationOdometry.h>
36 #include <mrpt/obs/CObservation2DRangeScan.h>
37 
39 #include <mrpt/system/filesystem.h>
40 #include <mrpt/system/os.h>
43 
47 
48 
49 // cpp headers
50 #include <string>
51 #include <sstream>
52 #include <vector>
53 
54 namespace mrpt { namespace graphslam { namespace apps {
55 
59 template<class GRAPH_T=mrpt::graphs::CNetworkOfPoses2DInf>
61  public CGraphSlamHandler<GRAPH_T>
62 {
63  public:
65  typedef typename GRAPH_T::constraint_t constraint_t;
67  typedef typename GRAPH_T::constraint_t::type_value pose_t;
68 
73 
75  mrpt::utils::COutputLogger* logger,
76  TUserOptionsChecker<GRAPH_T>* options_checker,
77  ros::NodeHandle* nh_in);
79 
80 
81  void getParamsAsString(std::string* str_out);
82  std::string getParamsAsString();
83 
88  void readParams();
92  void printParams();
93 
102  void sniffOdom(const nav_msgs::Odometry::ConstPtr& ros_odom);
106  void sniffLaserScan(const sensor_msgs::LaserScan::ConstPtr& ros_laser_scan);
107  void sniffCameraImage();
109  void sniff3DPointCloud();
114  bool continueExec();
118  void generateReport();
138  void setupComm();
139 
147  void initEngine_ROS();
148  void initEngine_MR();
151  static const std::string sep_header;
152  static const std::string sep_subheader;
153 
154  private:
164  void processObservation(mrpt::obs::CObservation::Ptr& observ);
170  void _process(mrpt::obs::CObservation::Ptr& observ);
175  void readROSParameters();
176  void readStaticTFs();
182  void getROSParameters(std::string* str_out);
186  void verifyUserInput();
187 
191  void resetReceivedFlags();
199  void setupSubs();
200  void setupPubs();
201  void setupSrvs();
205 
206  // ROS server parameters
209  std::string m_node_reg;
210  std::string m_edge_reg;
211  std::string m_optimizer;
221  VerbosityLevel m_min_logging_level;
222 
242  mrpt::obs::CObservationOdometry::Ptr m_mrpt_odom;
243  mrpt::obs::CObservation2DRangeScan::Ptr m_mrpt_laser_scan;
255 
271  std::string m_odom_topic;
272  std::string m_laser_scan_topic;
273  std::string m_camera_topic;
274  std::string m_point_cloud_topic;
275 
280  std::string m_gridmap_topic;
281  std::string m_stats_topic;
298  std::string m_anchor_frame_id;
299  std::string m_base_link_frame_id;
300  std::string m_odom_frame_id;
308  geometry_msgs::TransformStamped m_anchor_odom_transform;
314  nav_msgs::Path m_odom_path;
315 
320 
324 
327 
329 
336 };
337 
338 } } } // end of namespaces
339 
341 
void readROSParameters()
read configuration parameters from the ROS parameter server.
void readParams()
Read the problem configuration parameters.
void verifyUserInput()
Verify that the parameters read are valid and can be used with the CGraphSlamEngine_ROS instance...
bool usePublishersBroadcasters()
Provide feedback about the SLAM operation using ROS publilshers, update the registered frames using t...
CGraphSlamHandler_ROS(mrpt::utils::COutputLogger *logger, TUserOptionsChecker< GRAPH_T > *options_checker, ros::NodeHandle *nh_in)
void generateReport()
Generate the relevant report directory/files after the graphSLAM execution.
void initEngine_ROS()
Initialize the CGraphslamEngine_* object.
bool m_first_time_in_sniff_odom
Initial offset of the received odometry.
size_t m_measurement_cnt
Total counter of the processed measurements.
mrpt::obs::CObservation2DRangeScan::Ptr m_mrpt_laser_scan
GRAPH_T::constraint_t::type_value pose_t
type of underlying poses (2D/3D).
GRAPH_T::constraint_t constraint_t
type of graph constraints
CGraphSlamHandler_ROS< GRAPH_T > self_t
Handy self type.
VerbosityLevel m_min_logging_level
Minimum logging level for the current class instance.
bool continueExec()
Indicate whether graphslam execution can proceed normally.
geometry_msgs::TransformStamped m_anchor_odom_transform
ros::NodeHandle * m_nh
Pointer to the Ros NodeHanle instance.
void sniffOdom(const nav_msgs::Odometry::ConstPtr &ros_odom)
Callback method for handling incoming odometry measurements in a ROS topic.
CGraphSlamHandler< GRAPH_T > parent_t
Handy parent type.
void _process(mrpt::obs::CObservation::Ptr &observ)
Low level wrapper for executing the CGraphSlamEngine_ROS::execGraphSlamStep method.
void sniffLaserScan(const sensor_msgs::LaserScan::ConstPtr &ros_laser_scan)
Callback method for handling incoming LaserScans objects in a ROS topic.
void setupComm()
Wrapper method around the protected setup* class methods.
void getROSParameters(std::string *str_out)
Fill in the given string with the parameters that have been read from the ROS parameter server...
nav_msgs::Path m_odom_path
Odometry path of the robot. Handy mostly for visualization reasons.
std::string m_anchor_frame_id
Frame that the robot starts from. In a single-robot SLAM setup this can be set to the world frame...
void printParams()
Print in a compact manner the overall problem configuration parameters.
int m_pub_seq
Times a messge has been published => usePublishersBroadcasters method is called.
void resetReceivedFlags()
Reset the flags indicating whether we have received new data (odometry, laser scans etc...
Manage variables, ROS parameters and everything else related to the graphslam-engine ROS wrapper...
mrpt::obs::CObservationOdometry::Ptr m_mrpt_odom
Received laser scan - converted into MRPT CObservation* format.
void processObservation(mrpt::obs::CObservation::Ptr &observ)
Process an incoming measurement.
int m_queue_size
ROS topic publisher standard queue size.


mrpt_graphslam_2d
Author(s): Nikos Koukis
autogenerated on Sat May 2 2020 03:44:17