gmapping.cpp
Go to the documentation of this file.
1 #include <memory>
2 #include <cassert>
3 
4 #include <ros/ros.h>
5 #include <sensor_msgs/LaserScan.h>
6 #include <nav_msgs/OccupancyGrid.h>
7 
8 #include "../../ros/topic_with_transform.h"
9 #include "../../ros/laser_scan_observer.h"
10 #include "../../ros/init_utils.h"
11 
12 #include "../../ros/launch_properties_provider.h"
13 #include "init_gmapping.h"
14 
15 using ObservT = sensor_msgs::LaserScan;
17 
18 int main(int argc, char** argv) {
19  ros::init(argc, argv, "GMapping");
20 
21  auto props = LaunchPropertiesProvider{};
22  auto slam = init_gmapping(props);
23 
24  ros::NodeHandle nh;
25  // TODO: code duplication (viny.cpp)
26  double ros_map_publishing_rate, ros_tf_buffer_size;
27  int ros_filter_queue, ros_subscr_queue;
28  init_constants_for_ros(ros_tf_buffer_size, ros_map_publishing_rate,
29  ros_filter_queue, ros_subscr_queue);
30  auto scan_provider = std::make_unique<TopicWithTransform<ObservT>>(
32  ros_tf_buffer_size, ros_filter_queue, ros_subscr_queue
33  );
34  auto occup_grid_pub_pin = create_occupancy_grid_publisher(
35  slam.get(), nh, ros_map_publishing_rate);
36 
37  auto pose_pub_pin = create_pose_correction_tf_publisher(
38  slam.get(), scan_provider.get(), props);
39  // publish a "raw" robot pose to be compatible with test service
40  // use ObservationStampedPublishing to be compatible with TUM evaluator
42  slam.get(), scan_provider.get(), props);
43 
44  // TODO: setup scan skip policy via param
45  auto scan_obs_pin = std::make_shared<LaserScanObserver>(
46  slam, get_skip_exceeding_lsr(props), get_use_trig_cache(props));
47  // NB: pose_pub_pin must be subscribed first
48  scan_provider->subscribe(scan_obs_pin);
49 
50  ros::spin();
51 }
std::shared_ptr< PoseCorrectionTfPublisher< ObservT > > create_pose_correction_tf_publisher(WorldObservable< MapT > *slam, TopicWithTransform< ObservT > *scan_prov, const PropertiesProvider &props)
Definition: init_utils.h:92
auto init_gmapping(const PropertiesProvider &props)
Definition: init_gmapping.h:49
GmappingWorld::MapType MapType
std::string laser_scan_2D_ros_topic_name(const PropertiesProvider &props)
Definition: init_utils.h:25
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
bool get_use_trig_cache(const PropertiesProvider &props)
Definition: init_utils.h:56
std::shared_ptr< OccupancyGridPublisher< MapT > > create_occupancy_grid_publisher(WorldObservable< MapT > *slam, ros::NodeHandle nh, double ros_map_publishing_rate)
Definition: init_utils.h:128
sensor_msgs::LaserScan ObservT
Definition: gmapping.cpp:15
ROSCPP_DECL void spin(Spinner &spinner)
std::string tf_odom_frame_id(const PropertiesProvider &props)
Definition: init_utils.h:29
int main(int argc, char **argv)
Definition: gmapping.cpp:18
void init_constants_for_ros(double &ros_tf_buffer_size, double &ros_map_rate, int &ros_filter_queue, int &ros_subscr_queue)
Definition: init_utils.h:138
auto make_pose_correction_observation_stamped_publisher(WorldObservable< MapT > *slam, TopicWithTransform< ObservT > *scan_provider, const PropertiesProvider &props)
Definition: init_utils.h:113
bool get_skip_exceeding_lsr(const PropertiesProvider &props)
Definition: init_utils.h:49


slam_constructor
Author(s): JetBrains Research, OSLL team
autogenerated on Mon Jun 10 2019 15:08:25