static_map_node.cpp
Go to the documentation of this file.
1 
6 // ROS
7 #include <ros/ros.h>
8 
9 // Us
10 #include "static_map.hpp"
11 
13 {
14 
15  // Constants for now. Use <remap> in launch file
16  // to point to correct topics
17  _mapConfig.occupancyOutputTopic = "costmap";
18  _mapConfig.gridmapOutputTopic = "gridmap";
19 
20 
21  // Required Parameters
22  if (!_nh.getParam("static_map_sub_topic", _mapConfig.staticMapSubTopic))
23  {
24  ROS_ERROR("No static map sub topic set.");
25  return -1;
26  }
27 
28  // Optional parameters
29  _nh.param<std::string>("map_name", _mapConfig.mapName, "Static Map");
30  // Empty string notifies we won't be subscribed to these
31  _nh.param<std::string>("marker_sub_topic", _mapConfig.markerSubTopic, "");
32  _nh.param<std::string>("gridmap_sub_topic", _mapConfig.gridMapSubTopic, "");
33  _nh.param<std::string>("gridmap_layer", _mapConfig.gridMapLayer, "");
34 
35 
36  return 0;
37 }
38 
39 int main(int argc, char **argv)
40 {
41  ros::init(argc, argv, "t_static_map");
42  ros::NodeHandle nh("~");
44 
45  if (getParameters(nh, mapConfig) < 0)
46  {
47  ROS_ERROR("Configuration error. Unable to get required parameters.");
48  exit(1);
49  }
50 
51  mitre_fast_layered_map::StaticMap staticMap(&nh, mapConfig);
52 
53  if (staticMap.init() < 0)
54  {
55  ROS_ERROR("Unable to initialize map. Exiting...");
56  exit(-1);
57  }
58 
59  ros::Rate rate(10);
60 
61  while(ros::ok())
62  {
63  if(staticMap.once() != 0)
64  {
65  ROS_WARN_THROTTLE(1, "Map unable to publish.");
66  }
67  rate.sleep();
68  ros::spinOnce();
69  }
70 }
#define ROS_WARN_THROTTLE(rate,...)
std::string mapName
Name identification for the map.
Definition: static_map.hpp:33
std::string gridMapLayer
Layer to retrieve permanent obstacles from.
Definition: static_map.hpp:38
std::string gridMapSubTopic
in the grid map will be added to the static map instance.
Definition: static_map.hpp:36
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std::string staticMapSubTopic
Static map from map server to use as starting configuration.
Definition: static_map.hpp:34
bool param(const std::string &param_name, T &param_val, const T &default_val) const
ROSCPP_DECL bool ok()
std::string markerSubTopic
Topic users can post marker messages to to add obstacles.
Definition: static_map.hpp:35
std::string occupancyOutputTopic
Topic for occupancy grid.
Definition: static_map.hpp:40
bool sleep()
Mapping solution for largely static obstacles. Despite the name, it can be modified, but all modifications are considered permanent unless explicitly removed. Not for use as a rapidly changing dynamic map. See the SensorMap for that capability.
bool getParam(const std::string &key, std::string &s) const
int main(int argc, char **argv)
ROSCPP_DECL void spinOnce()
#define ROS_ERROR(...)
std::string gridmapOutputTopic
Topic for grid map msgs output.
Definition: static_map.hpp:41
int getParameters(ros::NodeHandle _nh, mitre_fast_layered_map::StaticMapConfiguration &_mapConfig)


mitre_fast_layered_map
Author(s):
autogenerated on Thu Mar 11 2021 03:06:49