pointcloud_fusion is a ROS 2 package designed to synchronize and fuse point clouds from multiple LiDAR sensors. It uses TF2 transformations to convert point clouds to a common reference frame and merges them into a single unified point cloud.
- Multi-LiDAR Synchronization: Synchronizes point clouds from two LiDAR sensors using approximate time synchronization
- TF2 Integration: Automatically transforms point clouds to a target reference frame using TF2
- Point Cloud Fusion: Merges multiple point clouds into a single unified output
- ROS 2 Native: Built specifically for ROS 2 with modern C++ practices
- Configurable: Flexible parameter configuration for different sensor setups
- ROS 2 (tested with ROS 2 humble)
- Ubuntu 22.04 or later (or compatible Linux distribution)
- CMake 3.22 or later
rclcpp- ROS 2 C++ client librarysensor_msgs- ROS 2 sensor messagesmessage_filters- Message synchronizationpcl_ros- Point Cloud Library ROS interfacepcl_conversions- PCL/ROS conversionstf2_ros- TF2 ROS bindingsEigen3- Linear algebra library
-
Create a ROS 2 workspace (if you don't have one):
mkdir -p ~/ros2_ws/src cd ~/ros2_ws/src
-
Clone the repository:
git clone https://github.com/qza36/pointcloud_fusion.git
-
Install dependencies:
cd ~/ros2_ws rosdep install --from-paths src --ignore-src -r -y
-
Build the package:
cd ~/ros2_ws colcon build --packages-select pointcloud_fusion
-
Source the workspace:
source ~/ros2_ws/install/setup.bash
ros2 run pointcloud_fusion fusion_noderos2 run pointcloud_fusion fusion_node --ros-args \
-p target_frame:=base_link \
-p lidar_topic:=/BottomLidar/livox/lidar/pointcloud \
-p rear_lidar_topic:=/TopLidar/livox/lidar/pointcloud \
-p lidar_frame:=livox_frame_bottom \
-p rear_lidar_frame:=livox_frame_topThe node supports the following ROS 2 parameters:
| Parameter | Type | Default Value | Description |
|---|---|---|---|
target_frame |
string | base_link |
Target reference frame for point cloud fusion |
lidar_topic |
string | /BottomLidar/livox/lidar/pointcloud |
First LiDAR point cloud topic |
rear_lidar_topic |
string | /TopLidar/livox/lidar/pointcloud |
Second LiDAR point cloud topic |
lidar_frame |
string | livox_frame_bottom |
Frame ID of the first LiDAR |
rear_lidar_frame |
string | livox_frame_top |
Frame ID of the second LiDAR |
-
First LiDAR point cloud (default:
/BottomLidar/livox/lidar/pointcloud)- Type:
sensor_msgs/msg/PointCloud2 - Point cloud from the first LiDAR sensor
- Type:
-
Second LiDAR point cloud (default:
/TopLidar/livox/lidar/pointcloud)- Type:
sensor_msgs/msg/PointCloud2 - Point cloud from the second LiDAR sensor
- Type:
/points/fused- Type:
sensor_msgs/msg/PointCloud2 - Fused point cloud in the target reference frame
- Type:
- Subscription: The node subscribes to two point cloud topics from different LiDAR sensors
- Synchronization: Uses approximate time synchronization to match point clouds from both sensors
- Transformation: Transforms both point clouds to the target reference frame using TF2
- Fusion: Concatenates the transformed point clouds into a single unified point cloud
- Publication: Publishes the fused point cloud to the output topic
┌─────────────────┐
│ LiDAR Sensor 1 │
│ (Bottom) │
└────────┬────────┘
│ PointCloud2
▼
┌────────────────────┐
│ │
│ Message Filters │◄─────┐
│ (Synchronizer) │ │ PointCloud2
│ │ │
└────────┬───────────┘ │
│ │
│ ┌─────┴────────┐
│ │ LiDAR Sensor 2│
│ │ (Top) │
▼ └───────────────┘
┌─────────────────────┐
│ TF2 Transform │
│ to target_frame │
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ Point Cloud Fusion │
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ /points/fused │
│ (Output) │
└─────────────────────┘
cd ~/ros2_ws
colcon build --packages-select pointcloud_fusion --symlink-installcd ~/ros2_ws
colcon test --packages-select pointcloud_fusionIf you encounter transform errors:
- Ensure TF2 transformations are properly broadcasted between sensor frames and the target frame
- Check that frame IDs match between the point cloud messages and TF tree
- Use
ros2 run tf2_ros tf2_echo <source_frame> <target_frame>to verify transforms
If point clouds are not being synchronized:
- Verify both LiDAR topics are publishing data
- Check that timestamps on both topics are reasonably close (within ~100ms)
- Adjust the synchronization queue size if needed
TODO: License declaration
- Maintainer: ZhiangQi
- Email: an9qi@yandex.com
Contributions are welcome! Please feel free to submit issues or pull requests.
pointcloud_fusion 是一个 ROS 2 软件包,用于同步和融合来自多个激光雷达传感器的点云数据。它使用 TF2 变换将点云转换到共同的参考坐标系,并将它们合并为单个统一的点云。
- 多激光雷达同步: 使用近似时间同步算法同步来自两个激光雷达传感器的点云
- TF2 集成: 使用 TF2 自动将点云转换到目标参考坐标系
- 点云融合: 将多个点云合并为单个统一输出
- 原生 ROS 2: 专为 ROS 2 构建,采用现代 C++ 实践
- 可配置: 灵活的参数配置,适用于不同的传感器设置
- ROS 2(已在 ROS 2 humble上测试)
- Ubuntu 22.04 或更高版本(或兼容的 Linux 发行版)
- CMake 3.22 或更高版本
rclcpp- ROS 2 C++ 客户端库sensor_msgs- ROS 2 传感器消息message_filters- 消息同步pcl_ros- 点云库 ROS 接口pcl_conversions- PCL/ROS 转换tf2_ros- TF2 ROS 绑定Eigen3- 线性代数库
-
创建 ROS 2 工作空间(如果还没有):
mkdir -p ~/ros2_ws/src cd ~/ros2_ws/src
-
克隆仓库:
git clone https://github.com/qza36/pointcloud_fusion.git
-
安装依赖项:
cd ~/ros2_ws rosdep install --from-paths src --ignore-src -r -y
-
编译软件包:
cd ~/ros2_ws colcon build --packages-select pointcloud_fusion
-
加载工作空间:
source ~/ros2_ws/install/setup.bash
ros2 run pointcloud_fusion fusion_noderos2 run pointcloud_fusion fusion_node --ros-args \
-p target_frame:=base_link \
-p lidar_topic:=/BottomLidar/livox/lidar/pointcloud \
-p rear_lidar_topic:=/TopLidar/livox/lidar/pointcloud \
-p lidar_frame:=livox_frame_bottom \
-p rear_lidar_frame:=livox_frame_top节点支持以下 ROS 2 参数:
| 参数 | 类型 | 默认值 | 描述 |
|---|---|---|---|
target_frame |
string | base_link |
点云融合的目标参考坐标系 |
lidar_topic |
string | /BottomLidar/livox/lidar/pointcloud |
第一个激光雷达点云话题 |
rear_lidar_topic |
string | /TopLidar/livox/lidar/pointcloud |
第二个激光雷达点云话题 |
lidar_frame |
string | livox_frame_bottom |
第一个激光雷达的坐标系 ID |
rear_lidar_frame |
string | livox_frame_top |
第二个激光雷达的坐标系 ID |
-
第一个激光雷达点云(默认:
/BottomLidar/livox/lidar/pointcloud)- 类型:
sensor_msgs/msg/PointCloud2 - 来自第一个激光雷达传感器的点云数据
- 类型:
-
第二个激光雷达点云(默认:
/TopLidar/livox/lidar/pointcloud)- 类型:
sensor_msgs/msg/PointCloud2 - 来自第二个激光雷达传感器的点云数据
- 类型:
/points/fused- 类型:
sensor_msgs/msg/PointCloud2 - 目标参考坐标系中的融合点云
- 类型:
- 订阅: 节点订阅来自不同激光雷达传感器的两个点云话题
- 同步: 使用近似时间同步来匹配来自两个传感器的点云
- 变换: 使用 TF2 将两个点云转换到目标参考坐标系
- 融合: 将转换后的点云连接成单个统一的点云
- 发布: 将融合后的点云发布到输出话题
┌─────────────────┐
│ 激光雷达传感器 1 │
│ (底部) │
└────────┬────────┘
│ PointCloud2
▼
┌────────────────────┐
│ │
│ 消息过滤器 │◄─────┐
│ (同步器) │ │ PointCloud2
│ │ │
└────────┬───────────┘ │
│ │
│ ┌─────┴────────┐
│ │ 激光雷达传感器 2│
│ │ (顶部) │
▼ └───────────────┘
┌─────────────────────┐
│ TF2 坐标变换 │
│ 到 target_frame │
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ 点云融合 │
└────────┬────────────┘
│
▼
┌─────────────────────┐
│ /points/fused │
│ (输出) │
└─────────────────────┘
cd ~/ros2_ws
colcon build --packages-select pointcloud_fusion --symlink-installcd ~/ros2_ws
colcon test --packages-select pointcloud_fusion如果遇到变换错误:
- 确保在传感器坐标系和目标坐标系之间正确广播了 TF2 变换
- 检查点云消息的坐标系 ID 是否与 TF 树匹配
- 使用
ros2 run tf2_ros tf2_echo <source_frame> <target_frame>验证变换
如果点云无法同步:
- 验证两个激光雷达话题是否正在发布数据
- 检查两个话题的时间戳是否足够接近(在 ~100ms 以内)
- 如有必要,调整同步队列大小
待定:许可证声明
- 维护者: ZhiangQI
- 邮箱: an9qi@yandex.com
欢迎贡献!请随时提交问题或拉取请求。