Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit 5cada6c

Browse files
authored
Merge pull request #2 from estherag/rolling
Blackboard for Pointcloud Perceptions
2 parents 3c030c9 + b734b68 commit 5cada6c

7 files changed

Lines changed: 193 additions & 140 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,25 @@ Run the lifecycle node:
3636
```bash
3737
ros2 run easynav_pointcloud_maps_builder pointcloud_maps_builder_node
3838
```
39+
## Test
40+
41+
1. Create a parameter YAML file (e.g., `params.yaml`) with the following content:
42+
43+
```yaml
44+
pointcloud_maps_builder_node:
45+
ros__parameters:
46+
use_sim_time: true
47+
sensors: [map]
48+
downsample_resolution: 0.1
49+
perception_default_frame: map
50+
map:
51+
topic: map
52+
type: sensor_msgs/msg/PointCloud2
53+
group: points
54+
```
55+
56+
2. Run the node using the parameter file with this command:
57+
```
58+
ros2 run easynav_pointcloud_maps_builder pointcloud_maps_builder_main \
59+
--ros-args --params-file src/easynav_pointcloud_stack/params.yaml
60+
```

easynav_pointcloud_maps_builder/CMakeLists.txt

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,43 @@ find_package(rclcpp_lifecycle REQUIRED)
1616
find_package(sensor_msgs REQUIRED)
1717
find_package(easynav_common REQUIRED)
1818

19-
set(dependencies
20-
rclcpp
21-
rclcpp_lifecycle
22-
sensor_msgs
23-
easynav_common
24-
)
25-
26-
include_directories(include)
2719

2820
# Library
2921
add_library(${PROJECT_NAME} SHARED
3022
src/easynav_pointcloud_maps_builder/PointcloudMapsBuilderNode.cpp
23+
)
3124

25+
target_include_directories(${PROJECT_NAME} PUBLIC
26+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
27+
$<INSTALL_INTERFACE:include/${PROJECT_NAME}>
3228
)
33-
ament_target_dependencies(${PROJECT_NAME} ${dependencies})
3429

35-
# Executable
36-
add_executable(pointcloud_maps_builder_main src/pointcloud_maps_builder_main.cpp)
37-
ament_target_dependencies(pointcloud_maps_builder_main ${dependencies})
38-
target_link_libraries(pointcloud_maps_builder_main ${PROJECT_NAME})
30+
target_link_libraries(${PROJECT_NAME} PUBLIC
31+
rclcpp::rclcpp
32+
rclcpp_lifecycle::rclcpp_lifecycle
33+
sensor_msgs::sensor_msgs_library
34+
easynav_common::easynav_common
35+
)
3936

4037
# Install headers
4138
install(DIRECTORY include/
42-
DESTINATION include/
39+
DESTINATION include/${PROJECT_NAME}
4340
)
4441

4542
# Install targets
4643
install(TARGETS
4744
${PROJECT_NAME}
48-
pointcloud_maps_builder_main
45+
EXPORT export_${PROJECT_NAME}
4946
ARCHIVE DESTINATION lib
5047
LIBRARY DESTINATION lib
5148
RUNTIME DESTINATION lib/${PROJECT_NAME}
5249
)
5350

51+
# Executable
52+
add_executable(pointcloud_maps_builder_main src/pointcloud_maps_builder_main.cpp)
53+
target_link_libraries(pointcloud_maps_builder_main PUBLIC
54+
${PROJECT_NAME}
55+
)
5456
# Tests
5557
if(BUILD_TESTING)
5658
find_package(ament_lint_auto REQUIRED)
@@ -63,8 +65,14 @@ if(BUILD_TESTING)
6365
endif()
6466

6567
# Export
66-
ament_export_include_directories(include)
68+
ament_export_include_directories("include/${PROJECT_NAME}")
6769
ament_export_libraries(${PROJECT_NAME})
68-
ament_export_dependencies(${dependencies})
70+
ament_export_targets(export_${PROJECT_NAME})
71+
ament_export_dependencies(
72+
rclcpp
73+
rclcpp_lifecycle
74+
sensor_msgs
75+
easynav_common
76+
)
6977

7078
ament_package()
Lines changed: 67 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
// Copyright 2025 Intelligent Robotics Lab
22
//
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
84
// it under the terms of the GNU General Public License as published by
95
// the Free Software Foundation, either version 3 of the License, or
106
// (at your option) any later version.
@@ -15,13 +11,18 @@
1511
// GNU General Public License for more details.
1612
//
1713
// 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/>.
1915

2016
/// \file
2117
/// \brief Definition of the PointcloudMapsBuilderNode class.
2218

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>
2526

2627
#include "rclcpp/rclcpp.hpp"
2728
#include "rclcpp/macros.hpp"
@@ -33,88 +34,93 @@
3334
namespace easynav
3435
{
3536

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+
*/
4445
class PointcloudMapsBuilderNode : public rclcpp_lifecycle::LifecycleNode
4546
{
4647
public:
4748
RCLCPP_SMART_PTR_DEFINITIONS(PointcloudMapsBuilderNode)
48-
4949
using CallbackReturnT = rclcpp_lifecycle::node_interfaces::LifecycleNodeInterface::CallbackReturn;
5050

51-
/**
52-
* @brief Constructor.
53-
* @param options Node initialization options.
54-
*/
51+
/**
52+
* @brief Constructor.
53+
* @param options Node initialization options.
54+
*/
5555
explicit PointcloudMapsBuilderNode(const rclcpp::NodeOptions & options = rclcpp::NodeOptions());
5656

57-
/**
58-
* @brief Destructor.
59-
*/
57+
/**
58+
* @brief Destructor.
59+
*/
6060
~PointcloudMapsBuilderNode();
6161

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+
*/
6767
CallbackReturnT on_configure(const rclcpp_lifecycle::State & state) override;
6868

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+
*/
7474
CallbackReturnT on_activate(const rclcpp_lifecycle::State & state) override;
7575

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+
*/
8181
CallbackReturnT on_deactivate(const rclcpp_lifecycle::State & state) override;
8282

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+
*/
8888
CallbackReturnT on_cleanup(const rclcpp_lifecycle::State & state) override;
8989

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+
*/
9696
void cycle();
9797

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);
104103

105-
/// Callback group for subscription and timers.
104+
private:
105+
/// Callback group used for subscriptions and timers.
106106
rclcpp::CallbackGroup::SharedPtr cbg_;
107107

108-
/// Downsampling resolution for point clouds.
108+
/// Downsampling resolution for point clouds.
109109
double downsample_resolution_;
110110

111-
/// Default frame ID for perception and publishing.
111+
/// Default frame ID used for perception and publishing.
112112
std::string perception_default_frame_;
113113

114-
/// Publisher for processed point cloud map.
114+
/// Lifecycle publisher for the processed point cloud map.
115115
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_;
116122
};
117123

118124
} // namespace easynav
119125

120-
#endif // EASYNAV_OUTDOOR_MAPS_BUILDER__POINTCLOUDMAPSBUILDERNODE_HPP_
126+
#endif // EASYNAV_POINTCLOUD_MAPS_BUILDER__POINTCLOUDMAPSBUILDERNODE_HPP_

0 commit comments

Comments
 (0)