Point Cloud Library with Velodyne LiDAR


I tried Velodyne VLP-16 at Fujiyoshi Lab. of Chubu University.
Thank you so much for giving me this opportunity.

Velodyne LiDAR

What is LiDAR?

The LiDAR is sensor to retrieve three-dimensional distance and reflectance intensity of horizontal 360 degree that uses rotates laser range units.
Velodyne‘s LiDAR is mounted on a robot car (autonomous car) and drones, that have been utilized to sense the surrounding environment.


VLP-16 retrieve data by skipping an infrared laser of vertical range +/- 15 degree.
In horizontal, It retrieve data with resolution of 0.1~0.4 degree at 300~1200rpm.
HDL-64E/HDL-32E have high resolution of vertical direction than VLP-16, because threse sensors have more lasers in vertical direction.


Data in the UDP/IP will be sent from the LiDAR.
The receive side will retrieve data with analyzes packets.


VeloView is viewer application for Velodyne LiDARs.
This viewer can viewing data that retrieve from LiDAR in real time, recording data and saving data to file (PCAP, CSV).
The PCAP file includes all received packet data.
The CSV file includes one frame data that is reflection intensity and distance of 0-359.9 degree.

PCL with Velodyne LiDAR

Point Cloud Library (PCL) have Grabber for input data from Velodyne LiDARs.
You can easily retrieve Point Cloud from Velodyne LiDARs same as other Grabbers.

Also, You can choose whether to retrieve data from sensor or PCAP file by argument to constructor of Grabber.
However, If you want to retrieve data from PCAP file, You need build PCL with WITH_PCAP option. (Pre-built library is disabled this option.)

  • HDLGrabber
  • This Grabber for HDL-64E/HDL-32E.

  • VLPGrabber
  • This Grabber for VLP-16.

Drawing Point Cloud retrieve from Velodyne LiDAR

This sample program is published in following.


You need to include pcl/io/vlp_grabber.h in order to use pcl::VLPGrabber.
If you want to use pcl::HDLGrabber, You need to include pcl/io/hdl_grabber.h.


#include <pcl/io/vlp_grabber.h>
//#include <pcl/io/hdl_grabber.h>


You will create instance of pcl::VLPGrabber.
At this time, You can choose whether to retrieve data from sensor or PCAP file by argument to constructor of Grabber.
If you want to retrieve data from PCAP file, You will specify path to PCAP file to constructor.
If you want to retrieve real-time data from sensor, You will specify IP address and port number to constructor.

*1 If you want to use pcl::HDLGrabber and HDL-64, You need specify calibration file to constructor.
*2 IP address and port number is depends on Velodyne LiDAR and NIC settings.


// VLP Grabber
boost::shared_ptr<pcl::VLPGrabber> grabber;
if( !pcap.empty() ){
    std::cout << "Capture from PCAP..." << std::endl;
    grabber = boost::shared_ptr<pcl::VLPGrabber>( new pcl::VLPGrabber( pcap ) );
else if( !ipaddress.empty() && !port.empty() ){
    std::cout << "Capture from Sensor..." << std::endl;
    grabber = boost::shared_ptr<pcl::VLPGrabber>( new pcl::VLPGrabber( boost::asio::ip::address::from_string( ipaddress ), boost::lexical_cast<unsigned short>( port ) ) );

Color Handler

The data retrieved from Velodyne LiDARs has not color information.
For this reason, You need to specify rules for displayed on viewer.
You will create pcl::visualization::PointCloudColorHandler each pcl::PointType.
pcl::visualization::PointCloudColorHandler that was created is give to viewer.


// Point Cloud Color Hndler
pcl::visualization::PointCloudColorHandler<PointType>::Ptr handler;
const std::type_info& type = typeid( PointType );
if( type == typeid( pcl::PointXYZ ) ){
    std::vector<double> color = { 255.0, 255.0, 255.0 };
    boost::shared_ptr<pcl::visualization::PointCloudColorHandlerCustom<PointType>> color_handler( new pcl::visualization::PointCloudColorHandlerCustom<PointType>( color[0], color[1], color[2] ) );
    handler = color_handler;
else if( type == typeid( pcl::PointXYZI ) ){
    boost::shared_ptr<pcl::visualization::PointCloudColorHandlerGenericField<PointType>> color_handler( new pcl::visualization::PointCloudColorHandlerGenericField<PointType>( "intensity" ) );
    handler = color_handler;
else if( type == typeid( pcl::PointXYZRGBA ) ){
    boost::shared_ptr<pcl::visualization::PointCloudColorHandlerRGBField<PointType>> color_handler( new pcl::visualization::PointCloudColorHandlerRGBField<PointType>() );
    handler = color_handler;
    throw std::runtime_error( "This PointType is unsupported." );


while( !viewer->wasStopped() ){
    // Update Viewer

    boost::mutex::scoped_try_lock lock( mutex );
    if( lock.owns_lock() && cloud ){
        // Update Point Cloud
        handler->setInputCloud( cloud );
        if( !viewer->updatePointCloud( cloud, *handler, "cloud" ) ){
            viewer->addPointCloud( cloud, *handler, "cloud" );

Execution Result

It will be display Point Cloud that retrieved from Velodyne LiDAR when running this sample program.
This sample data (2014-11-10-11-32-17_Velodyne-VLP_10Hz_Monterey Highway.pcap) has been retrieved from sensor that mount on car top.
Point Cloud is attached color by reflected intensity of infrared laser.
You can see ambient environment such as street trees, buildings, road, and other cars.

Leave a Reply

Your email address will not be published. Required fields are marked *