base.h
Go to the documentation of this file.
00001 
00006 #ifndef BASE_H
00007 #define BASE_H
00008 
00009 #include <ros/ros.h>
00010 #include <tf/transform_broadcaster.h>
00011 #include <nav_msgs/Odometry.h>
00012 #include <sensor_msgs/Image.h>
00013 #include <message_filters/subscriber.h>
00014 #include <message_filters/time_synchronizer.h>
00015 #include <message_filters/sync_policies/exact_time.h>
00016 #include <image_transport/subscriber_filter.h>
00017 #include <pcl_ros/point_cloud.h>
00018 #include <pcl_ros/transforms.h>
00019 #include <pcl/point_types.h>
00020 #include <pcl/filters/voxel_grid.h>
00021 #include <pcl/filters/passthrough.h>
00022 #include <libhaloc/lc.h>
00023 #include "common/pose.h"
00024 #include "common/graph.h"
00025 #include "common/tools.h"
00026 
00027 using namespace std;
00028 using namespace cv;
00029 using namespace tools;
00030 
00031 typedef pcl::PointXYZRGB                  PointRGB;
00032 typedef pcl::PointCloud<PointRGB>         PointCloud;
00033 
00034 namespace slam
00035 {
00036 
00037 class SlamBase
00038 {
00039 
00040 public:
00041 
00042         // Constructor
00043   SlamBase(ros::NodeHandle nh, ros::NodeHandle nhp);
00044 
00045   // Finalize stereo slam node
00046   void finalize();
00047 
00048   struct Params
00049   {
00050     // Motion parameters
00051     double min_displacement;         
00052     bool save_clouds;                
00053     string clouds_dir;               
00054 
00055     // Default settings
00056     Params () {
00057       min_displacement            = 0.2;
00058       save_clouds                 = false;
00059       clouds_dir                  = "";
00060     }
00061   };
00062 
00066   inline void setParams(const Params& params)
00067   {
00068     params_ = params;
00069   }
00070 
00074   inline Params params() const { return params_; }
00075 
00076 protected:
00077 
00078         // Node handlers
00079         ros::NodeHandle nh_;
00080   ros::NodeHandle nh_private_;
00081 
00082   // Protected functions and callbacks
00083   void init();
00084   void readParameters();
00085   void msgsCallback(const nav_msgs::Odometry::ConstPtr& odom_msg,
00086                     const sensor_msgs::ImageConstPtr& l_img_msg,
00087                     const sensor_msgs::ImageConstPtr& r_img_msg,
00088                     const sensor_msgs::CameraInfoConstPtr& l_info_msg,
00089                     const sensor_msgs::CameraInfoConstPtr& r_info_msg);
00090   void msgsCallback(const nav_msgs::Odometry::ConstPtr& odom_msg,
00091                     const sensor_msgs::ImageConstPtr& l_img_msg,
00092                     const sensor_msgs::ImageConstPtr& r_img_msg,
00093                     const sensor_msgs::CameraInfoConstPtr& l_info_msg,
00094                     const sensor_msgs::CameraInfoConstPtr& r_info_msg,
00095                     const sensor_msgs::PointCloud2ConstPtr& cloud_msg);
00096 
00097 private:
00098 
00099   // Topic properties
00100   image_transport::SubscriberFilter left_sub_, right_sub_;
00101   message_filters::Subscriber<sensor_msgs::CameraInfo> left_info_sub_, right_info_sub_;
00102   message_filters::Subscriber<nav_msgs::Odometry> odom_sub_;
00103   message_filters::Subscriber<sensor_msgs::PointCloud2> cloud_sub_;
00104 
00105   // Topic sync properties (no pointcloud)
00106   typedef message_filters::sync_policies::ExactTime<nav_msgs::Odometry,
00107                                                     sensor_msgs::Image,
00108                                                     sensor_msgs::Image,
00109                                                     sensor_msgs::CameraInfo,
00110                                                     sensor_msgs::CameraInfo> ExactPolicyNoCloud;
00111   typedef message_filters::Synchronizer<ExactPolicyNoCloud> ExactSyncNoCloud;
00112   boost::shared_ptr<ExactSyncNoCloud> exact_sync_no_cloud_;
00113 
00114   // Topic sync properties (with pointcloud)
00115   typedef message_filters::sync_policies::ExactTime<nav_msgs::Odometry,
00116                                                     sensor_msgs::Image,
00117                                                     sensor_msgs::Image,
00118                                                     sensor_msgs::CameraInfo,
00119                                                     sensor_msgs::CameraInfo,
00120                                                     sensor_msgs::PointCloud2> ExactPolicyCloud;
00121   typedef message_filters::Synchronizer<ExactPolicyCloud> ExactSyncCloud;
00122   boost::shared_ptr<ExactSyncCloud> exact_sync_cloud_;
00123 
00124   Params params_;                   
00125   haloc::LoopClosure lc_;           
00126   slam::Pose pose_;                 
00127   slam::Graph graph_;               
00128   bool first_iter_;                 
00129   PointCloud pcl_cloud_;            
00130 };
00131 
00132 } // namespace
00133 
00134 #endif // BASE_H


stereo_slam
Author(s): Pep Lluis Negre
autogenerated on Thu Aug 27 2015 15:24:22