|
2 | 2 | // Copyright (c) 2022, Takahiro Miki. All rights reserved. |
3 | 3 | // Licensed under the MIT license. See LICENSE file in the project root for details. |
4 | 4 | // |
5 | | -#include <pybind11_catkin/pybind11/embed.h> // everything needed for embedding |
| 5 | + |
| 6 | +#pragma once |
| 7 | + |
| 8 | +// STL |
6 | 9 | #include <iostream> |
| 10 | + |
| 11 | +// Boost |
| 12 | +#include <boost/thread/recursive_mutex.hpp> |
| 13 | + |
| 14 | +// Eigen |
7 | 15 | #include <Eigen/Dense> |
8 | 16 |
|
| 17 | +// Pybind |
| 18 | +#include <pybind11_catkin/pybind11/embed.h> // everything needed for embedding |
| 19 | + |
| 20 | +// ROS |
| 21 | +#include <geometry_msgs/PolygonStamped.h> |
9 | 22 | #include <ros/ros.h> |
10 | 23 | #include <sensor_msgs/PointCloud2.h> |
11 | | -#include <geometry_msgs/PolygonStamped.h> |
12 | 24 | #include <std_srvs/Empty.h> |
13 | 25 | #include <std_srvs/SetBool.h> |
| 26 | +#include <tf/transform_broadcaster.h> |
14 | 27 | #include <tf/transform_listener.h> |
15 | 28 | #include <visualization_msgs/Marker.h> |
16 | 29 | #include <visualization_msgs/MarkerArray.h> |
17 | | -#include <tf/transform_broadcaster.h> |
| 30 | + |
18 | 31 | // Grid Map |
19 | | -#include <grid_map_ros/grid_map_ros.hpp> |
20 | | -#include <grid_map_msgs/GridMap.h> |
21 | 32 | #include <grid_map_msgs/GetGridMap.h> |
22 | | -#include <elevation_map_msgs/CheckSafety.h> |
23 | | -#include <elevation_map_msgs/Initialize.h> |
| 33 | +#include <grid_map_msgs/GridMap.h> |
| 34 | +#include <grid_map_ros/grid_map_ros.hpp> |
| 35 | + |
24 | 36 | // PCL |
25 | | -#include <pcl/point_types.h> |
26 | 37 | #include <pcl/PCLPointCloud2.h> |
| 38 | +#include <pcl/point_types.h> |
27 | 39 | #include <pcl_conversions/pcl_conversions.h> |
28 | | -#include <boost/thread/recursive_mutex.hpp> |
| 40 | + |
| 41 | +#include <elevation_map_msgs/CheckSafety.h> |
| 42 | +#include <elevation_map_msgs/Initialize.h> |
29 | 43 |
|
30 | 44 | #include "elevation_mapping_cupy/elevation_mapping_wrapper.hpp" |
31 | 45 |
|
32 | 46 | namespace py = pybind11; |
33 | 47 |
|
| 48 | +namespace elevation_mapping_cupy { |
34 | 49 |
|
35 | | -namespace elevation_mapping_cupy{ |
| 50 | +class ElevationMappingNode { |
| 51 | + public: |
| 52 | + ElevationMappingNode(ros::NodeHandle& nh); |
36 | 53 |
|
| 54 | + private: |
| 55 | + void readParameters(); |
| 56 | + void setupMapPublishers(); |
| 57 | + void pointcloudCallback(const sensor_msgs::PointCloud2& cloud); |
| 58 | + void publishAsPointCloud(); |
| 59 | + bool getSubmap(grid_map_msgs::GetGridMap::Request& request, grid_map_msgs::GetGridMap::Response& response); |
| 60 | + bool checkSafety(elevation_map_msgs::CheckSafety::Request& request, elevation_map_msgs::CheckSafety::Response& response); |
| 61 | + bool initializeMap(elevation_map_msgs::Initialize::Request& request, elevation_map_msgs::Initialize::Response& response); |
| 62 | + bool clearMap(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response); |
| 63 | + bool clearMapWithInitializer(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response); |
| 64 | + bool setPublishPoint(std_srvs::SetBool::Request& request, std_srvs::SetBool::Response& response); |
| 65 | + void updatePose(const ros::TimerEvent&); |
| 66 | + void updateVariance(const ros::TimerEvent&); |
| 67 | + void updateTime(const ros::TimerEvent&); |
| 68 | + void updateGridMap(const ros::TimerEvent&); |
| 69 | + void publishNormalAsArrow(const grid_map::GridMap& map); |
| 70 | + void initializeWithTF(); |
| 71 | + void publishMapToOdom(double error); |
| 72 | + void publishStatistics(const ros::TimerEvent&); |
| 73 | + void publishMapOfIndex(int index); |
37 | 74 |
|
38 | | -class ElevationMappingNode { |
39 | | - public: |
40 | | - ElevationMappingNode(ros::NodeHandle& nh); |
41 | | - ~ElevationMappingNode() = default; |
42 | | - |
43 | | - private: |
44 | | - void readParameters(); |
45 | | - void setupMapPublishers(); |
46 | | - void pointcloudCallback(const sensor_msgs::PointCloud2& cloud); |
47 | | - void publishAsPointCloud(); |
48 | | - bool getSubmap(grid_map_msgs::GetGridMap::Request& request, grid_map_msgs::GetGridMap::Response& response); |
49 | | - bool checkSafety(elevation_map_msgs::CheckSafety::Request& request, |
50 | | - elevation_map_msgs::CheckSafety::Response& response); |
51 | | - bool initializeMap(elevation_map_msgs::Initialize::Request& request, |
52 | | - elevation_map_msgs::Initialize::Response& response); |
53 | | - bool clearMap(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response); |
54 | | - bool clearMapWithInitializer(std_srvs::Empty::Request& request, std_srvs::Empty::Response& response); |
55 | | - bool setPublishPoint(std_srvs::SetBool::Request& request, std_srvs::SetBool::Response& response); |
56 | | - void updatePose(const ros::TimerEvent&); |
57 | | - void updateVariance(const ros::TimerEvent&); |
58 | | - void updateTime(const ros::TimerEvent&); |
59 | | - void updateGridMap(const ros::TimerEvent&); |
60 | | - void publishNormalAsArrow(const grid_map::GridMap& map); |
61 | | - void initializeWithTF(); |
62 | | - void publishMapToOdom(double error); |
63 | | - void publishStatistics(const ros::TimerEvent&); |
64 | | - void publishMapOfIndex(int index); |
65 | | - |
66 | | - visualization_msgs::Marker vectorToArrowMarker(const Eigen::Vector3d& start, const Eigen::Vector3d& end, const int id); |
67 | | - ros::NodeHandle nh_; |
68 | | - std::vector<ros::Subscriber> pointcloudSubs_; |
69 | | - std::vector<ros::Publisher> mapPubs_; |
70 | | - ros::Publisher alivePub_; |
71 | | - ros::Publisher pointPub_; |
72 | | - ros::Publisher normalPub_; |
73 | | - ros::Publisher statisticsPub_; |
74 | | - ros::ServiceServer rawSubmapService_; |
75 | | - ros::ServiceServer clearMapService_; |
76 | | - ros::ServiceServer clearMapWithInitializerService_; |
77 | | - ros::ServiceServer initializeMapService_; |
78 | | - ros::ServiceServer setPublishPointService_; |
79 | | - ros::ServiceServer checkSafetyService_; |
80 | | - ros::Timer updateVarianceTimer_; |
81 | | - ros::Timer updateTimeTimer_; |
82 | | - ros::Timer updatePoseTimer_; |
83 | | - ros::Timer updateGridMapTimer_; |
84 | | - ros::Timer publishStatisticsTimer_; |
85 | | - ros::Time lastStatisticsPublishedTime_; |
86 | | - tf::TransformListener transformListener_; |
87 | | - ElevationMappingWrapper map_; |
88 | | - std::string mapFrameId_; |
89 | | - std::string correctedMapFrameId_; |
90 | | - std::string baseFrameId_; |
91 | | - grid_map::GridMap gridMap_; |
92 | | - |
93 | | - // map topics info |
94 | | - std::vector<std::vector<std::string>> map_topics_; |
95 | | - std::vector<std::vector<std::string>> map_layers_; |
96 | | - std::vector<std::vector<std::string>> map_basic_layers_; |
97 | | - std::set<std::string> map_layers_all_; |
98 | | - std::set<std::string> map_layers_sync_; |
99 | | - std::vector<double> map_fps_; |
100 | | - std::set<double> map_fps_unique_; |
101 | | - std::vector<ros::Timer> mapTimers_; |
102 | | - |
103 | | - std::vector<std::string> initialize_frame_id_; |
104 | | - std::vector<double> initialize_tf_offset_; |
105 | | - std::string initializeMethod_; |
106 | | - |
107 | | - Eigen::Vector3d lowpassPosition_; |
108 | | - Eigen::Vector4d lowpassOrientation_; |
109 | | - |
110 | | - boost::recursive_mutex mapMutex_; |
111 | | - |
112 | | - double positionError_; |
113 | | - double orientationError_; |
114 | | - double positionAlpha_; |
115 | | - double orientationAlpha_; |
116 | | - double recordableFps_; |
117 | | - bool enablePointCloudPublishing_; |
118 | | - bool enableNormalArrowPublishing_; |
119 | | - bool enableDriftCorrectedTFPublishing_; |
120 | | - bool useInitializerAtStart_; |
121 | | - bool isGridmapUpdated_; |
122 | | - double initializeTfGridSize_; |
123 | | - int pointCloudProcessCounter_; |
| 75 | + visualization_msgs::Marker vectorToArrowMarker(const Eigen::Vector3d& start, const Eigen::Vector3d& end, const int id); |
| 76 | + ros::NodeHandle nh_; |
| 77 | + std::vector<ros::Subscriber> pointcloudSubs_; |
| 78 | + std::vector<ros::Publisher> mapPubs_; |
| 79 | + ros::Publisher alivePub_; |
| 80 | + ros::Publisher pointPub_; |
| 81 | + ros::Publisher normalPub_; |
| 82 | + ros::Publisher statisticsPub_; |
| 83 | + ros::ServiceServer rawSubmapService_; |
| 84 | + ros::ServiceServer clearMapService_; |
| 85 | + ros::ServiceServer clearMapWithInitializerService_; |
| 86 | + ros::ServiceServer initializeMapService_; |
| 87 | + ros::ServiceServer setPublishPointService_; |
| 88 | + ros::ServiceServer checkSafetyService_; |
| 89 | + ros::Timer updateVarianceTimer_; |
| 90 | + ros::Timer updateTimeTimer_; |
| 91 | + ros::Timer updatePoseTimer_; |
| 92 | + ros::Timer updateGridMapTimer_; |
| 93 | + ros::Timer publishStatisticsTimer_; |
| 94 | + ros::Time lastStatisticsPublishedTime_; |
| 95 | + tf::TransformListener transformListener_; |
| 96 | + ElevationMappingWrapper map_; |
| 97 | + std::string mapFrameId_; |
| 98 | + std::string correctedMapFrameId_; |
| 99 | + std::string baseFrameId_; |
| 100 | + grid_map::GridMap gridMap_; |
| 101 | + |
| 102 | + // map topics info |
| 103 | + std::vector<std::vector<std::string>> map_topics_; |
| 104 | + std::vector<std::vector<std::string>> map_layers_; |
| 105 | + std::vector<std::vector<std::string>> map_basic_layers_; |
| 106 | + std::set<std::string> map_layers_all_; |
| 107 | + std::set<std::string> map_layers_sync_; |
| 108 | + std::vector<double> map_fps_; |
| 109 | + std::set<double> map_fps_unique_; |
| 110 | + std::vector<ros::Timer> mapTimers_; |
| 111 | + |
| 112 | + std::vector<std::string> initialize_frame_id_; |
| 113 | + std::vector<double> initialize_tf_offset_; |
| 114 | + std::string initializeMethod_; |
| 115 | + |
| 116 | + Eigen::Vector3d lowpassPosition_; |
| 117 | + Eigen::Vector4d lowpassOrientation_; |
| 118 | + |
| 119 | + boost::recursive_mutex mapMutex_; |
| 120 | + |
| 121 | + double positionError_; |
| 122 | + double orientationError_; |
| 123 | + double positionAlpha_; |
| 124 | + double orientationAlpha_; |
| 125 | + double recordableFps_; |
| 126 | + bool enablePointCloudPublishing_; |
| 127 | + bool enableNormalArrowPublishing_; |
| 128 | + bool enableDriftCorrectedTFPublishing_; |
| 129 | + bool useInitializerAtStart_; |
| 130 | + bool isGridmapUpdated_; |
| 131 | + double initializeTfGridSize_; |
| 132 | + int pointCloudProcessCounter_; |
124 | 133 | }; |
125 | 134 |
|
126 | | -} |
| 135 | +} // namespace elevation_mapping_cupy |
0 commit comments