slam_gmapping.h
Go to the documentation of this file.
1 /*
2  * slam_gmapping
3  * Copyright (c) 2008, Willow Garage, Inc.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright notice,
8  * this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the names of Stanford University or Willow Garage, Inc. nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  *
28  */
29 
30 /* Author: Brian Gerkey */
31 
32 #include "ros/ros.h"
33 #include "sensor_msgs/LaserScan.h"
34 #include "std_msgs/Float64.h"
35 #include "nav_msgs/GetMap.h"
36 #include "tf/transform_listener.h"
39 #include "tf/message_filter.h"
40 
43 
44 #include <boost/thread.hpp>
45 
47 {
48  public:
49  SlamGMapping();
51  SlamGMapping(unsigned long int seed, unsigned long int max_duration_buffer);
52  ~SlamGMapping();
53 
54  void init();
55  void startLiveSlam();
56  void startReplay(const std::string & bag_fname, std::string scan_topic);
57  void publishTransform();
58 
59  void laserCallback(const sensor_msgs::LaserScan::ConstPtr& scan);
60  bool mapCallback(nav_msgs::GetMap::Request &req,
61  nav_msgs::GetMap::Response &res);
62  void publishLoop(double transform_publish_period);
63 
64  private:
74 
77  // The angles in the laser, going from -x to x (adjustment is made to get the laser between
78  // symmetrical bounds as that's what gmapping expects)
79  std::vector<double> laser_angles_;
80  // The pose, in the original laser frame, of the corresponding centered laser with z facing up
82  // Depending on the order of the elements in the scan and the orientation of the scan frame,
83  // We might need to change the order of the scan
85  unsigned int gsp_laser_beam_count_;
87 
89 
90  bool got_map_;
91  nav_msgs::GetMap::Response map_;
92 
95  boost::mutex map_to_odom_mutex_;
96  boost::mutex map_mutex_;
97 
100 
101  boost::thread* transform_thread_;
102 
103  std::string base_frame_;
104  std::string laser_frame_;
105  std::string map_frame_;
106  std::string odom_frame_;
107 
108  void updateMap(const sensor_msgs::LaserScan& scan);
109  bool getOdomPose(GMapping::OrientedPoint& gmap_pose, const ros::Time& t);
110  bool initMapper(const sensor_msgs::LaserScan& scan);
111  bool addScan(const sensor_msgs::LaserScan& scan, GMapping::OrientedPoint& gmap_pose);
112  double computePoseEntropy();
113 
114  // Parameters used by GMapping
115  double maxRange_;
116  double maxUrange_;
117  double maxrange_;
119  double sigma_;
121  double lstep_;
122  double astep_;
124  double lsigma_;
125  double ogain_;
126  int lskip_;
127  double srr_;
128  double srt_;
129  double str_;
130  double stt_;
136  double xmin_;
137  double ymin_;
138  double xmax_;
139  double ymax_;
140  double delta_;
141  double occ_thresh_;
146 
148 
149  unsigned long int seed_;
150 
152  double tf_delay_;
153 };
bool mapCallback(nav_msgs::GetMap::Request &req, nav_msgs::GetMap::Response &res)
void laserCallback(const sensor_msgs::LaserScan::ConstPtr &scan)
message_filters::Subscriber< sensor_msgs::LaserScan > * scan_filter_sub_
Definition: slam_gmapping.h:71
double linearUpdate_
bool initMapper(const sensor_msgs::LaserScan &scan)
void updateMap(const sensor_msgs::LaserScan &scan)
tf::TransformListener tf_
Definition: slam_gmapping.h:70
double lasamplerange_
ros::ServiceServer ss_
Definition: slam_gmapping.h:69
double angularUpdate_
std::string odom_frame_
double computePoseEntropy()
std::string laser_frame_
double occ_thresh_
double lasamplestep_
ros::Publisher sst_
Definition: slam_gmapping.h:67
double llsamplestep_
unsigned long int seed_
void publishLoop(double transform_publish_period)
bool got_first_scan_
Definition: slam_gmapping.h:88
bool do_reverse_range_
Definition: slam_gmapping.h:84
bool getOdomPose(GMapping::OrientedPoint &gmap_pose, const ros::Time &t)
tf::Stamped< tf::Pose > centered_laser_pose_
Definition: slam_gmapping.h:81
unsigned int gsp_laser_beam_count_
Definition: slam_gmapping.h:85
double tf_delay_
tf::TransformBroadcaster * tfB_
Definition: slam_gmapping.h:73
void startReplay(const std::string &bag_fname, std::string scan_topic)
boost::mutex map_mutex_
Definition: slam_gmapping.h:96
tf::Transform map_to_odom_
Definition: slam_gmapping.h:94
void startLiveSlam()
nav_msgs::GetMap::Response map_
Definition: slam_gmapping.h:91
double llsamplerange_
double maxUrange_
double temporalUpdate_
boost::mutex map_to_odom_mutex_
Definition: slam_gmapping.h:95
boost::thread * transform_thread_
ros::Publisher entropy_publisher_
Definition: slam_gmapping.h:66
ros::Duration map_update_interval_
Definition: slam_gmapping.h:93
double transform_publish_period_
ros::NodeHandle private_nh_
GMapping::GridSlamProcessor * gsp_
Definition: slam_gmapping.h:75
double maxrange_
double resampleThreshold_
ros::Publisher sstm_
Definition: slam_gmapping.h:68
void publishTransform()
std::string base_frame_
std::string map_frame_
double maxRange_
std::vector< double > laser_angles_
Definition: slam_gmapping.h:79
ros::NodeHandle node_
Definition: slam_gmapping.h:65
double minimum_score_
tf::MessageFilter< sensor_msgs::LaserScan > * scan_filter_
Definition: slam_gmapping.h:72
GMapping::OdometrySensor * gsp_odom_
Definition: slam_gmapping.h:86
GMapping::RangeSensor * gsp_laser_
Definition: slam_gmapping.h:76
bool addScan(const sensor_msgs::LaserScan &scan, GMapping::OrientedPoint &gmap_pose)


gmapping
Author(s): Brian Gerkey
autogenerated on Mon Feb 28 2022 23:45:27