|
1 | 1 | // Copyright 2025 Intelligent Robotics Lab |
2 | 2 | // |
3 | | -// This file is part of the project Easy Navigation (EasyNav in sh0rt) |
4 | | -// licensed under the GNU General Public License v3.0. |
5 | | -// See <http://www.gnu.org/licenses/> for details. |
6 | | -// |
7 | | -// Easy Navigation program is free software: you can redistribute it and/or modify |
| 3 | +// This program is free software: you can redistribute it and/or modify |
8 | 4 | // it under the terms of the GNU General Public License as published by |
9 | 5 | // the Free Software Foundation, either version 3 of the License, or |
10 | 6 | // (at your option) any later version. |
|
15 | 11 | // GNU General Public License for more details. |
16 | 12 | // |
17 | 13 | // You should have received a copy of the GNU General Public License |
18 | | -// along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 14 | +// along with this program. If not, see <https://www.gnu.org/licenses/>. |
19 | 15 |
|
20 | 16 | /// \file |
21 | 17 | /// \brief Definition of the PointcloudMapsBuilderNode class. |
22 | 18 |
|
23 | | -#ifndef EASYNAV_OUTDOOR_MAPS_BUILDER__POINTCLOUDMAPSBUILDERNODE_HPP_ |
24 | | -#define EASYNAV_OUTDOOR_MAPS_BUILDER__POINTCLOUDMAPSBUILDERNODE_HPP_ |
| 19 | +#ifndef EASYNAV_POINTCLOUD_MAPS_BUILDER__POINTCLOUDMAPSBUILDERNODE_HPP_ |
| 20 | +#define EASYNAV_POINTCLOUD_MAPS_BUILDER__POINTCLOUDMAPSBUILDERNODE_HPP_ |
| 21 | + |
| 22 | +#include <string> |
| 23 | +#include <memory> |
| 24 | +#include <map> |
| 25 | +#include <vector> |
25 | 26 |
|
26 | 27 | #include "rclcpp/rclcpp.hpp" |
27 | 28 | #include "rclcpp/macros.hpp" |
|
33 | 34 | namespace easynav |
34 | 35 | { |
35 | 36 |
|
36 | | -/** |
37 | | - * @class PointcloudMapsBuilderNode |
38 | | - * @brief Lifecycle node that subscribes to point cloud sensor data and manages point cloud map building. |
39 | | - * |
40 | | - * This node processes perception data (point clouds) to build and update point cloud maps. |
41 | | - * It leverages ROS 2 lifecycle for clean startup, activation, deactivation, and cleanup phases. |
42 | | - * The node publishes processed (filtered or downsampled) point cloud maps for downstream use. |
43 | | - */ |
| 37 | + /** |
| 38 | + * @class PointcloudMapsBuilderNode |
| 39 | + * @brief Lifecycle node that subscribes to point cloud sensor data and manages point cloud map building. |
| 40 | + * |
| 41 | + * This node processes perception data (point clouds) to build and update point cloud maps. |
| 42 | + * It leverages ROS 2 lifecycle for clean startup, activation, deactivation, and cleanup phases. |
| 43 | + * The node publishes processed (filtered or downsampled) point cloud maps for downstream use. |
| 44 | + */ |
44 | 45 | class PointcloudMapsBuilderNode : public rclcpp_lifecycle::LifecycleNode |
45 | 46 | { |
46 | 47 | public: |
47 | 48 | RCLCPP_SMART_PTR_DEFINITIONS(PointcloudMapsBuilderNode) |
48 | | - |
49 | 49 | using CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn; |
50 | 50 |
|
51 | | - /** |
52 | | - * @brief Constructor. |
53 | | - * @param options Node initialization options. |
54 | | - */ |
| 51 | + /** |
| 52 | + * @brief Constructor. |
| 53 | + * @param options Node initialization options. |
| 54 | + */ |
55 | 55 | explicit PointcloudMapsBuilderNode(const rclcpp::NodeOptions & options = rclcpp::NodeOptions()); |
56 | 56 |
|
57 | | - /** |
58 | | - * @brief Destructor. |
59 | | - */ |
| 57 | + /** |
| 58 | + * @brief Destructor. |
| 59 | + */ |
60 | 60 | ~PointcloudMapsBuilderNode(); |
61 | 61 |
|
62 | | - /** |
63 | | - * @brief Lifecycle configure callback. |
64 | | - * @param state Current lifecycle state. |
65 | | - * @return CallbackReturnT indicating success or failure. |
66 | | - */ |
| 62 | + /** |
| 63 | + * @brief Lifecycle configure callback. |
| 64 | + * @param state Current lifecycle state. |
| 65 | + * @return CallbackReturnT indicating success or failure. |
| 66 | + */ |
67 | 67 | CallbackReturnT on_configure(const rclcpp_lifecycle::State & state) override; |
68 | 68 |
|
69 | | - /** |
70 | | - * @brief Lifecycle activate callback. |
71 | | - * @param state Current lifecycle state. |
72 | | - * @return CallbackReturnT indicating success or failure. |
73 | | - */ |
| 69 | + /** |
| 70 | + * @brief Lifecycle activate callback. |
| 71 | + * @param state Current lifecycle state. |
| 72 | + * @return CallbackReturnT indicating success or failure. |
| 73 | + */ |
74 | 74 | CallbackReturnT on_activate(const rclcpp_lifecycle::State & state) override; |
75 | 75 |
|
76 | | - /** |
77 | | - * @brief Lifecycle deactivate callback. |
78 | | - * @param state Current lifecycle state. |
79 | | - * @return CallbackReturnT indicating success or failure. |
80 | | - */ |
| 76 | + /** |
| 77 | + * @brief Lifecycle deactivate callback. |
| 78 | + * @param state Current lifecycle state. |
| 79 | + * @return CallbackReturnT indicating success or failure. |
| 80 | + */ |
81 | 81 | CallbackReturnT on_deactivate(const rclcpp_lifecycle::State & state) override; |
82 | 82 |
|
83 | | - /** |
84 | | - * @brief Lifecycle cleanup callback. |
85 | | - * @param state Current lifecycle state. |
86 | | - * @return CallbackReturnT indicating success or failure. |
87 | | - */ |
| 83 | + /** |
| 84 | + * @brief Lifecycle cleanup callback. |
| 85 | + * @param state Current lifecycle state. |
| 86 | + * @return CallbackReturnT indicating success or failure. |
| 87 | + */ |
88 | 88 | CallbackReturnT on_cleanup(const rclcpp_lifecycle::State & state) override; |
89 | 89 |
|
90 | | - /** |
91 | | - * @brief Perform a processing cycle on perception data and update the point cloud map. |
92 | | - * |
93 | | - * This should be called periodically (e.g., in a timer or main loop) to process incoming sensor data, |
94 | | - * update internal map representations, and publish outputs. |
95 | | - */ |
| 90 | + /** |
| 91 | + * @brief Perform a processing cycle on perception data and update the point cloud map. |
| 92 | + * |
| 93 | + * This should be called periodically (e.g., in a timer or main loop) to process incoming sensor data, |
| 94 | + * update internal map representations, and publish outputs. |
| 95 | + */ |
96 | 96 | void cycle(); |
97 | 97 |
|
98 | | -private: |
99 | | - /// Sensor topic name to subscribe to point clouds. |
100 | | - std::string sensor_topic_; |
101 | | - |
102 | | - /// Perception data container. |
103 | | - Perceptions perceptions_; |
| 98 | + /** |
| 99 | + * @brief Registers a perception handler. |
| 100 | + * @param handler Shared pointer to a PerceptionHandler instance. |
| 101 | + */ |
| 102 | + void register_handler(std::shared_ptr<PerceptionHandler> handler); |
104 | 103 |
|
105 | | - /// Callback group for subscription and timers. |
| 104 | +private: |
| 105 | + /// Callback group used for subscriptions and timers. |
106 | 106 | rclcpp::CallbackGroup::SharedPtr cbg_; |
107 | 107 |
|
108 | | - /// Downsampling resolution for point clouds. |
| 108 | + /// Downsampling resolution for point clouds. |
109 | 109 | double downsample_resolution_; |
110 | 110 |
|
111 | | - /// Default frame ID for perception and publishing. |
| 111 | + /// Default frame ID used for perception and publishing. |
112 | 112 | std::string perception_default_frame_; |
113 | 113 |
|
114 | | - /// Publisher for processed point cloud map. |
| 114 | + /// Lifecycle publisher for the processed point cloud map. |
115 | 115 | rclcpp_lifecycle::LifecyclePublisher<sensor_msgs::msg::PointCloud2>::SharedPtr pub_; |
| 116 | + |
| 117 | + /// Map of perception data grouped by sensor name. |
| 118 | + std::map<std::string, std::vector<PerceptionPtr>> perceptions_; |
| 119 | + |
| 120 | + /// Registered perception handlers by sensor name. |
| 121 | + std::map<std::string, std::shared_ptr<PerceptionHandler>> handlers_; |
116 | 122 | }; |
117 | 123 |
|
118 | 124 | } // namespace easynav |
119 | 125 |
|
120 | | -#endif // EASYNAV_OUTDOOR_MAPS_BUILDER__POINTCLOUDMAPSBUILDERNODE_HPP_ |
| 126 | +#endif // EASYNAV_POINTCLOUD_MAPS_BUILDER__POINTCLOUDMAPSBUILDERNODE_HPP_ |
0 commit comments