Ground plane segmentation from Lidar PointCloud

August 2022

Motivation: To use live Velodyne VLP-16 sensor data for obstacle detection and avoidance

Objective: Segment ground and non-ground points present in ROS2 sensor_msgs/PointCloud2 to help in obstacle detection and avoidance.

Details: While working in the Marine Animal Remote Sensing (MARS) Laboratory at the Woods Hole Oceanographic Institution (WHOI) on the ECHO Penguin robot, one of the necessary task required for autonomous navigation of the robot was to detect obstacles using Velodyne VLP-16 lidar and avoid them. As the sensor’s data captures both the ground and non-ground points, it is necessary to segment the points. To achive this, three algorithms were used.

1) Naive height based approximation: As the LiDAR sensor is at ~ 1 m above the ground plane, consider all points which are within 0.8 m to 1.2 m (40 cm configurable buffer to account for unevenness of the ground plane) below the sensor’s height as ground and remove them from the dataset. But this approach removes some non-ground points as well. To solve this issue, step 2 is used.

2) Principal component analysis (PCA) is used on the ground-points of previous step to detect outliers (i.e. non-ground points). After a little bit of parameter tuning, satisfactory results were achieved in gazebo simulation environment.

3) Random sample consensus (RANSAC) is used on the ground points output of the previous step to filter the point cloud further and achieve better results. Initially, I made my own function to pick three random points, and then tried to find the best fit ground plane within a defined number of iterations (configurable). Then I found an already implement RANSAC function which helped in code cleanup. The filtered points (ground and non-ground) are then visualized in two environments: empty_world and husky_playpen

Original PointCloud2 sizeAlgorithms and points count
Naive height based assumptionPCARANSAC
Environment # 1 (empty_world)15000Ground Points150001499814998
Non-ground points
022
Environment # 2 (clearpath_playpen)16826Ground points853385267596
Non-ground points829383009230

As can be seen from the above images and tabular representation, PCA and RANSAC algorithms are working well for ground plane extraction. For empty_world environment, the algorithms can detect that almost all (except 2) points are ground points. Whereas for the other environment, nearly 50% of the points are ground points which got removed from the dataset for further computation which can save a lot of power and processing time.

Special thanks to the references listed below which provided a path to proceed forward with this problem and explained the fundamentals really well!

References: http://sayef.tech/post/ground-detection-and-removal-from-point-clouds/, https://medium.com/@ajithraj_gangadharan/3d-ransac-algorithm-for-lidar-pcd-segmentation-315d2a51351, https://leomariga.github.io/pyRANSAC-3D/api-documentation/plane/