Quad-SDK
Loading...
Searching...
No Matches
mesh_to_grid_map_converter.hpp
1#ifndef MESH_TO_GRID_MAP_CONVERTER_H
2#define MESH_TO_GRID_MAP_CONVERTER_H
3
4#include <grid_map_msgs/ProcessFile.h>
5#include <pcl/PolygonMesh.h>
6#include <pcl_msgs/PolygonMesh.h>
7#include <pcl_ros/point_cloud.h>
8#include <ros/package.h>
9#include <ros/ros.h>
10#include <std_srvs/Empty.h>
11
12#include <grid_map_core/GridMap.hpp>
13#include <string>
14
15namespace mesh_to_grid_map {
16
17constexpr double kDefaultGridMapResolution = 0.2;
18static const std::string kDefaultLayerName = "elevation";
19constexpr bool kDefaultLatchGridMapPub = true;
20constexpr bool kDefaultVerbose = false;
21static const std::string kDefaultFrameIdMeshLoaded = "map";
22static const std::string kDefaultWorldName = "flat";
23
25 public:
26 MeshToGridMapConverter(ros::NodeHandle nh, ros::NodeHandle nh_private);
27
28 private:
29 // Initial interactions with ROS
30 void subscribeToTopics();
31 void advertiseTopics();
32 void advertiseServices();
33 void getParametersFromRos();
34
35 // Datacallback
36 void meshCallback(const pcl_msgs::PolygonMesh& mesh);
37
38 // Save callback
39 bool saveGridMapService(grid_map_msgs::ProcessFile::Request& request,
40 grid_map_msgs::ProcessFile::Response& response);
41
42 // Load mesh, service call
43 bool loadMeshService(grid_map_msgs::ProcessFile::Request& request,
44 grid_map_msgs::ProcessFile::Response& response);
45
46 // Load mesh from file
47 bool loadMeshFromFile(const std::string& path_to_mesh_to_load);
48
49 // Converts a mesh to grid map and stores the result
50 bool meshToGridMap(const pcl::PolygonMesh& polygon_mesh,
51 const std::string& mesh_frame_id,
52 const uint64_t& time_stamp_nano_seconds);
53
54 // Saves the grid map
55 bool saveGridMap(const grid_map::GridMap& map,
56 const std::string& path_to_file,
57 const std::string& topic_name);
58
59 // Node Handles
60 ros::NodeHandle nh_;
61 ros::NodeHandle nh_private_;
62
63 // Data subscribers.
64 ros::Subscriber mesh_sub_;
65
66 // Publishers
67 ros::Publisher grid_map_pub_;
68
69 // Services
70 ros::ServiceServer save_grid_map_srv_;
71
72 // Last grid map
73 std::unique_ptr<grid_map::GridMap> last_grid_map_ptr_;
74
75 // Grid Map Parameters
76 double grid_map_resolution_;
77 std::string layer_name_;
78 std::string world_name_;
79
80 // Control Parameters
81 bool latch_grid_map_pub_;
82 bool verbose_;
83
84 // Load mesh parameters
85 ros::ServiceServer load_map_service_server_;
86 std::string frame_id_mesh_loaded_;
87};
88
89} // namespace mesh_to_grid_map
90
91#endif
Definition mesh_to_grid_map_converter.hpp:24