A high-performance Adaptive DBSCAN clustering ROS node that segments point clouds into clusters for downstream perception tasks. It processes a filtered LiDAR/RADAR point cloud, runs adaptive DBSCAN clustering, and outputs:
- Clustered Point Clouds (via
autoware_perception_msgs::DynamicObjectWithFeatureArray
) - Markers visualizing bounding boxes (via
visualization_msgs::MarkerArray
) - Noise Points (points not belonging to any cluster)
This node is especially useful for 3D LiDAR-based perception in autonomous driving or robotics systems, where you need to:
- Identify objects in point cloud data,
- Publish bounding boxes for visualization,
- And keep track of any points that do not belong to relevant objects.
- Features
- Dependencies
- Installation and Build Instructions
- Usage
- Node Parameters
- Key Parts of the Code
- Performance
- Contribution
- License
This package depends on common ROS and perception libraries:
- ROS (tested with ROS melodic/noetic)
- PCL (Point Cloud Library)
- sensor_msgs
- visualization_msgs
- autoware_perception_msgs (from Autoware, or your custom message definitions)
Ensure you have these dependencies in your package.xml
:
<depend>roscpp</depend>
<depend>sensor_msgs</depend>
<depend>visualization_msgs</depend>
<depend>pcl_conversions</depend>
<depend>pcl_ros</depend>
<depend>autoware_perception_msgs</depend>
cd ~/catkin_ws/src
git clone https://github.com/your-username/dbscan_ros.git
cd ~/catkin_ws
catkin_make
source devel/setup.bash
- Start ROS Master:
roscore
- Launch LiDAR input (e.g., bag file, driver, or simulation)
- Run dbscan_ros:
rosrun dbscan_ros dbscan_ros_node
- Visualize outputs in
rviz
with topics:/dbscan_clustering/marker
(bounding boxes)/dbscan_clustering/noise_points
(outliers)
Parameter Name | Type | Default Value | Description |
---|---|---|---|
topic_input |
string | /rslidar_points_front/ROI/no_ground |
Input point cloud topic |
topic_output |
string | /dbscan_clustering/clusters |
Output topic for clusters |
obj_width_thre |
double | 0.15 |
Approximate object width threshold |
obj_height_thre |
double | 0.15 |
Approximate object height threshold |
downsample_resolution |
double | 0.03 |
Resolution for downsampling |
lidar_horizon_resolution |
double | 0.2 |
LiDAR horizontal resolution (degrees) |
lidar_vertical_resolution |
double | 1.0 |
LiDAR vertical resolution (degrees) |
nh_private.param<std::string>("topic_input", topic_input_, "/rslidar_points_front/ROI/no_ground");
nh_private.param<double>("obj_width_thre", obj_width_thre_, 0.15);
pc_sub = nh.subscribe(topic_input_, 1, &dbscan_ros::lidar_callback, this);
cluster_marker_pub = nh.advertise<visualization_msgs::MarkerArray>("/dbscan_clustering/marker", 10);
AdaptiveDBSCANCluster<pcl::PointXYZ> db;
db.setInputCloud(ground_remo);
db.setSearchMethod(tree);
db.setClusteringParams(obj_width_thre_, num_points_per_line_, max_num_lines_, eps_with_distance_factor_, num_line_with_distance_factor_);
db.setMinClusterSize(8);
db.setMaxClusterSize(20000);
db.extract(indices);
for (pcl::PointIndices ind : indices) {
// Compute min, max, center, and create markers
}
pcl::PointIndices::Ptr all_cluster_indices_ptr(new pcl::PointIndices(all_cluster_indices));
ext.setIndices(all_cluster_indices_ptr);
pcl::PointCloud<pcl::PointXYZ> noise_cloud;
ext.setNegative(true);
ext.filter(noise_cloud);
auto start = std::chrono::steady_clock::now();
auto end = std::chrono::steady_clock::now();
auto duration_ = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
if (duration_ >= 10 ) std::cout << "time took is, " << duration_ << std::endl;
- Real-time or near real-time performance depending on:
- CPU capabilities
- Density of point cloud
- Complexity of scene
- Adaptive factors keep clusters well-defined even with different LiDAR resolutions.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch (
git checkout -b feature-name
). - Commit your changes (
git commit -m 'Add new feature'
). - Push the branch (
git push origin feature-name
). - Open a pull request.
This code is provided under MIT. Please refer to the LICENSE file for details.
Enjoy using dbscan_ros for your LiDAR clustering needs! If you run into issues, feel free to open an issue or contribute via pull requests.
Happy Clustering!