00001 /* 00002 * slam_gmapping 00003 * Copyright (c) 2008, Willow Garage, Inc. 00004 * 00005 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE 00006 * COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY 00007 * COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS 00008 * AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 00009 * 00010 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO 00011 * BE BOUND BY THE TERMS OF THIS LICENSE. THE LICENSOR GRANTS YOU THE RIGHTS 00012 * CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND 00013 * CONDITIONS. 00014 * 00015 */ 00016 00017 /* Author: Brian Gerkey */ 00018 00019 #include "ros/ros.h" 00020 #include "sensor_msgs/LaserScan.h" 00021 #include "std_msgs/Float64.h" 00022 #include "nav_msgs/GetMap.h" 00023 #include "tf/transform_listener.h" 00024 #include "tf/transform_broadcaster.h" 00025 #include "message_filters/subscriber.h" 00026 #include "tf/message_filter.h" 00027 00028 #include "gmapping/gridfastslam/gridslamprocessor.h" 00029 #include "gmapping/sensor/sensor_base/sensor.h" 00030 00031 #include <boost/thread.hpp> 00032 00033 class SlamGMapping 00034 { 00035 public: 00036 SlamGMapping(); 00037 ~SlamGMapping(); 00038 00039 void publishTransform(); 00040 00041 void laserCallback(const sensor_msgs::LaserScan::ConstPtr& scan); 00042 bool mapCallback(nav_msgs::GetMap::Request &req, 00043 nav_msgs::GetMap::Response &res); 00044 void publishLoop(double transform_publish_period); 00045 00046 private: 00047 ros::NodeHandle node_; 00048 ros::Publisher entropy_publisher_; 00049 ros::Publisher sst_; 00050 ros::Publisher sstm_; 00051 ros::ServiceServer ss_; 00052 tf::TransformListener tf_; 00053 message_filters::Subscriber<sensor_msgs::LaserScan>* scan_filter_sub_; 00054 tf::MessageFilter<sensor_msgs::LaserScan>* scan_filter_; 00055 tf::TransformBroadcaster* tfB_; 00056 00057 GMapping::GridSlamProcessor* gsp_; 00058 GMapping::RangeSensor* gsp_laser_; 00059 double gsp_laser_angle_increment_; 00060 double angle_min_; 00061 double angle_max_; 00062 unsigned int gsp_laser_beam_count_; 00063 GMapping::OdometrySensor* gsp_odom_; 00064 00065 bool got_first_scan_; 00066 00067 bool got_map_; 00068 nav_msgs::GetMap::Response map_; 00069 00070 ros::Duration map_update_interval_; 00071 tf::Transform map_to_odom_; 00072 boost::mutex map_to_odom_mutex_; 00073 boost::mutex map_mutex_; 00074 00075 int laser_count_; 00076 int throttle_scans_; 00077 00078 boost::thread* transform_thread_; 00079 00080 std::string base_frame_; 00081 std::string laser_frame_; 00082 std::string map_frame_; 00083 std::string odom_frame_; 00084 00085 void updateMap(const sensor_msgs::LaserScan& scan); 00086 bool getOdomPose(GMapping::OrientedPoint& gmap_pose, const ros::Time& t); 00087 bool initMapper(const sensor_msgs::LaserScan& scan); 00088 bool addScan(const sensor_msgs::LaserScan& scan, GMapping::OrientedPoint& gmap_pose); 00089 double computePoseEntropy(); 00090 00091 // Parameters used by GMapping 00092 double maxRange_; 00093 double maxUrange_; 00094 double maxrange_; 00095 double sigma_; 00096 int kernelSize_; 00097 double lstep_; 00098 double astep_; 00099 int iterations_; 00100 double lsigma_; 00101 double ogain_; 00102 int lskip_; 00103 double srr_; 00104 double srt_; 00105 double str_; 00106 double stt_; 00107 double linearUpdate_; 00108 double angularUpdate_; 00109 double temporalUpdate_; 00110 double resampleThreshold_; 00111 int particles_; 00112 double xmin_; 00113 double ymin_; 00114 double xmax_; 00115 double ymax_; 00116 double delta_; 00117 double occ_thresh_; 00118 double llsamplerange_; 00119 double llsamplestep_; 00120 double lasamplerange_; 00121 double lasamplestep_; 00122 00123 double tf_delay_; 00124 };