GridMapRosConverter.hpp
Go to the documentation of this file.
1 /*
2  * GridMapRosConverter.hpp
3  *
4  * Created on: Jul 14, 2014
5  * Author: Péter Fankhauser
6  * Institute: ETH Zurich, ANYbotics
7  */
8 
9 #pragma once
10 
13 #include <grid_map_msgs/GridMap.h>
14 
15 // STL
16 #include <vector>
17 #include <unordered_map>
18 
19 // Eigen
20 #include <Eigen/Core>
21 
22 // ROS
23 #include <ros/ros.h>
24 #include <sensor_msgs/PointCloud2.h>
25 #include <sensor_msgs/Image.h>
27 #include <nav_msgs/OccupancyGrid.h>
28 #include <nav_msgs/GridCells.h>
29 #include <cv_bridge/cv_bridge.h>
30 
31 namespace grid_map {
32 
37 {
38  public:
43 
47  virtual ~GridMapRosConverter();
48 
58  static bool fromMessage(const grid_map_msgs::GridMap& message, grid_map::GridMap& gridMap, const std::vector<std::string>& layers, bool copyBasicLayers = true, bool copyAllNonBasicLayers = true);
59 
66  static bool fromMessage(const grid_map_msgs::GridMap& message, grid_map::GridMap& gridMap);
67 
73  static void toMessage(const grid_map::GridMap& gridMap, grid_map_msgs::GridMap& message);
74 
81  static void toMessage(const grid_map::GridMap& gridMap, const std::vector<std::string>& layers,
82  grid_map_msgs::GridMap& message);
83 
92  static void toPointCloud(const grid_map::GridMap& gridMap,
93  const std::string& pointLayer,
94  sensor_msgs::PointCloud2& pointCloud);
95 
105  static void toPointCloud(const grid_map::GridMap& gridMap,
106  const std::vector<std::string>& layers,
107  const std::string& pointLayer,
108  sensor_msgs::PointCloud2& pointCloud);
109 
117  static void toPointCloud(
118  const grid_map::SignedDistanceField& signedDistanceField, sensor_msgs::PointCloud2& pointCloud, size_t decimation = 1,
119  const std::function<bool(float)>& condition = [](float) { return true; });
120 
128  static bool fromOccupancyGrid(const nav_msgs::OccupancyGrid& occupancyGrid,
129  const std::string& layer, grid_map::GridMap& gridMap);
130 
140  static void toOccupancyGrid(const grid_map::GridMap& gridMap, const std::string& layer,
141  float dataMin, float dataMax, nav_msgs::OccupancyGrid& occupancyGrid);
142 
153  static void toGridCells(const grid_map::GridMap& gridMap, const std::string& layer,
154  float lowerThreshold, float upperThreshold,
155  nav_msgs::GridCells& gridCells);
156 
166  static bool initializeFromImage(const sensor_msgs::Image& image, const double resolution,
167  grid_map::GridMap& gridMap,
168  const grid_map::Position& position = grid_map::Position::Zero());
169 
182  static bool addLayerFromImage(const sensor_msgs::Image& image, const std::string& layer,
183  grid_map::GridMap& gridMap, const float lowerValue = 0.0,
184  const float upperValue = 1.0, const double alphaThreshold = 0.5);
185 
193  static bool addColorLayerFromImage(const sensor_msgs::Image& image, const std::string& layer,
194  grid_map::GridMap& gridMap);
195 
206  static bool toImage(const grid_map::GridMap& gridMap, const std::string& layer,
207  const std::string encoding, sensor_msgs::Image& image);
208 
219  static bool toImage(const grid_map::GridMap& gridMap, const std::string& layer,
220  const std::string encoding, const float lowerValue, const float upperValue,
221  sensor_msgs::Image& image);
222 
233  static bool toCvImage(const grid_map::GridMap& gridMap, const std::string& layer,
234  const std::string encoding, cv_bridge::CvImage& cvImage);
235 
246  static bool toCvImage(const grid_map::GridMap& gridMap, const std::string& layer,
247  const std::string encoding, const float lowerValue,
248  const float upperValue, cv_bridge::CvImage& cvImage);
249 
260  static bool saveToBag(const grid_map::GridMap& gridMap, const std::string& pathToBag,
261  const std::string& topic);
262 
270  static bool loadFromBag(const std::string& pathToBag, const std::string& topic,
271  grid_map::GridMap& gridMap);
272 
273 };
274 
275 } /* namespace */
static void toMessage(const grid_map::GridMap &gridMap, grid_map_msgs::GridMap &message)
static bool toImage(const grid_map::GridMap &gridMap, const std::string &layer, const std::string encoding, sensor_msgs::Image &image)
static bool fromOccupancyGrid(const nav_msgs::OccupancyGrid &occupancyGrid, const std::string &layer, grid_map::GridMap &gridMap)
static void toPointCloud(const grid_map::GridMap &gridMap, const std::string &pointLayer, sensor_msgs::PointCloud2 &pointCloud)
static void toOccupancyGrid(const grid_map::GridMap &gridMap, const std::string &layer, float dataMin, float dataMax, nav_msgs::OccupancyGrid &occupancyGrid)
static bool loadFromBag(const std::string &pathToBag, const std::string &topic, grid_map::GridMap &gridMap)
static bool initializeFromImage(const sensor_msgs::Image &image, const double resolution, grid_map::GridMap &gridMap, const grid_map::Position &position=grid_map::Position::Zero())
static bool fromMessage(const grid_map_msgs::GridMap &message, grid_map::GridMap &gridMap, const std::vector< std::string > &layers, bool copyBasicLayers=true, bool copyAllNonBasicLayers=true)
Eigen::Vector2d Position
static bool saveToBag(const grid_map::GridMap &gridMap, const std::string &pathToBag, const std::string &topic)
static bool addColorLayerFromImage(const sensor_msgs::Image &image, const std::string &layer, grid_map::GridMap &gridMap)
static void toGridCells(const grid_map::GridMap &gridMap, const std::string &layer, float lowerThreshold, float upperThreshold, nav_msgs::GridCells &gridCells)
static bool toCvImage(const grid_map::GridMap &gridMap, const std::string &layer, const std::string encoding, cv_bridge::CvImage &cvImage)
static bool addLayerFromImage(const sensor_msgs::Image &image, const std::string &layer, grid_map::GridMap &gridMap, const float lowerValue=0.0, const float upperValue=1.0, const double alphaThreshold=0.5)


grid_map_ros
Author(s): Péter Fankhauser
autogenerated on Wed Jul 5 2023 02:23:44