GridCellsVisualization.cpp
Go to the documentation of this file.
1 /*
2  * GridCellsVisualization.cpp
3  *
4  * Created on: Mar 28, 2015
5  * Author: Péter Fankhauser
6  * Institute: ETH Zurich, ANYbotics
7  */
8 
11 #include <nav_msgs/GridCells.h>
12 
13 // STD
14 #include <limits>
15 
16 namespace grid_map_visualization {
17 
19 : VisualizationBase(nodeHandle, name),
20  lowerThreshold_(-std::numeric_limits<float>::infinity()),
21  upperThreshold_(std::numeric_limits<float>::infinity())
22 {
23 }
24 
26 {
27 }
28 
30 {
32 
33  if (!getParam("layer", layer_)) {
34  ROS_ERROR("GridCellsVisualization with name '%s' did not find a 'layer' parameter.", name_.c_str());
35  return false;
36  }
37 
38  if (!getParam("lower_threshold", lowerThreshold_)) {
39  ROS_INFO("GridCellsVisualization with name '%s' did not find a 'lower_threshold' parameter. Using negative infinity.", name_.c_str());
40  }
41 
42  if (!getParam("upper_threshold", upperThreshold_)) {
43  ROS_INFO("GridCellsVisualization with name '%s' did not find a 'upper_threshold' parameter. Using infinity.", name_.c_str());
44  }
45 
46  return true;
47 }
48 
50 {
51  publisher_ = nodeHandle_.advertise<nav_msgs::GridCells>(name_, 1, true);
52  return true;
53 }
54 
56 {
57  if (!isActive()) return true;
58  if (!map.exists(layer_)) {
59  ROS_WARN_STREAM("GridCellsVisualization::visualize: No grid map layer with name '" << layer_ << "' found.");
60  return false;
61  }
62  nav_msgs::GridCells gridCells;
64  publisher_.publish(gridCells);
65  return true;
66 }
67 
68 } /* namespace */
void publish(const boost::shared_ptr< M > &message) const
GridCellsVisualization(ros::NodeHandle &nodeHandle, const std::string &name)
std::string layer_
Type that is transformed to the occupancy grid.
bool exists(const std::string &layer) const
bool getParam(const std::string &name, std::string &value)
#define ROS_INFO(...)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
#define ROS_WARN_STREAM(args)
float lowerThreshold_
Values that are between lower and upper threshold are shown.
ros::NodeHandle & nodeHandle_
ROS nodehandle.
std::string name_
Name of the visualization.
static void toGridCells(const grid_map::GridMap &gridMap, const std::string &layer, float lowerThreshold, float upperThreshold, nav_msgs::GridCells &gridCells)
ros::Publisher publisher_
ROS publisher of the occupancy grid.
virtual bool readParameters(XmlRpc::XmlRpcValue &config)
#define ROS_ERROR(...)


grid_map_visualization
Author(s): Péter Fankhauser
autogenerated on Tue Jun 1 2021 02:13:51