00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00041 #ifndef LASER_SLAM_POINT_CLOUD_SNAPSHOTTER_H
00042 #define LASER_SLAM_POINT_CLOUD_SNAPSHOTTER_H
00043
00044 #include <laser_slam/RecentScanTime.h>
00045 #include <laser_slam/LocalizedScan.h>
00046 #include <std_srvs/Empty.h>
00047 #include <pose_graph/diff_subscriber.h>
00048 #include <pose_graph/graph_db.h>
00049 #include <graph_mapping_msgs/ConstraintGraphDiff.h>
00050 #include <graph_mapping_msgs/NodePoses.h>
00051 #include <graph_mapping_msgs/LocalizationDistribution.h>
00052 #include <tf/transform_listener.h>
00053 #include <boost/thread.hpp>
00054 #include <boost/optional.hpp>
00055 #include <boost/circular_buffer.hpp>
00056
00057
00058 namespace laser_slam
00059 {
00060
00064 class PointCloudSnapshotter
00065 {
00066 public:
00067
00068 PointCloudSnapshotter (boost::shared_ptr<tf::TransformListener> tf,
00069 ros::NodeHandle param_nh);
00070
00073 boost::optional<ros::Time> recentScanTime (const ros::Time& t1, const ros::Time& t2) const;
00074
00075 private:
00076
00077 bool recentScanTimeCallback(RecentScanTime::Request& req,
00078 RecentScanTime::Response& resp);
00079 void scanCallback (const sensor_msgs::LaserScan::ConstPtr& scan);
00080 void diffCallback
00081 (boost::optional<const graph_mapping_msgs::ConstraintGraphDiff&> diff,
00082 const pose_graph::ConstraintGraph& graph);
00083 void locCallback (graph_mapping_msgs::LocalizationDistribution::ConstPtr m);
00084 void storeOptPoses (graph_mapping_msgs::NodePoses::ConstPtr m);
00085 void publishMap (const ros::TimerEvent& e);
00086 void processAndSaveScan (sensor_msgs::LaserScan::ConstPtr scan,
00087 const ros::Time& t, const unsigned n);
00088 void processAndSaveScan (sensor_msgs::LaserScan::ConstPtr scan,
00089 const geometry_msgs::PoseStamped& pos);
00090 laser_slam::LocalizedScan::Ptr processScan (sensor_msgs::LaserScan::ConstPtr scan,
00091 const geometry_msgs::Pose& sensor_pose) const;
00092 tf::Pose ffPoseAt (const ros::Time& t);
00093
00094
00095
00096
00097
00098 ros::NodeHandle param_nh_;
00099 const std::string fixed_frame_, sensor_frame_, base_frame_, global_frame_;
00100 const ros::Duration transform_wait_duration_;
00101 const double grid_resolution_;
00102 const ros::Duration scan_save_min_gap_;
00103 geometry_msgs::Pose sensor_pose_;
00104 const double scan_time_tol_;
00105 const bool cleanup_grid_;
00106 const double robot_radius_;
00107
00108
00109
00110
00111
00112 pose_graph::NodePoseMap opt_poses_;
00113 boost::circular_buffer<sensor_msgs::LaserScan::ConstPtr> recent_scans_;
00114 boost::optional<geometry_msgs::PoseStamped> last_loc_;
00115
00116
00117 boost::optional<unsigned> ref_node_;
00118
00119 bool optimize_flag_;
00120
00121
00122
00123
00124
00125 mutable boost::mutex mutex_;
00126 ros::NodeHandle nh_;
00127 boost::shared_ptr<tf::TransformListener> tf_;
00128 warehouse::WarehouseClient db_;
00129 pose_graph::CachedNodeMap<laser_slam::LocalizedScan> scans_;
00130 const pose_graph::CachedNodeMap<geometry_msgs::Pose> ff_poses_;
00131 ros::Subscriber laser_sub_, loc_sub_;
00132 pose_graph::DiffSubscriber diff_sub_;
00133 ros::Publisher map_pub_;
00134 ros::ServiceClient get_poses_client_;
00135 ros::Timer map_pub_timer_;
00136 ros::ServiceServer recent_scan_time_server_;
00137 };
00138
00139 const double SCAN_BUFFER_SIZE=100;
00140
00141 }
00142
00143 #endif // include guard