Main Content

Read and Compare Two Point Clouds from a LiDAR Sensor

This example shows how to acquire the oldest and newest point clouds from the buffer and display them to compare the images.

  1. Create a velodynelidar object, v, for use with a model HDL-32E sensor.

    v = velodynelidar('HDL32E')
    
    v = 
    
        velodynelidar with properties:
    
                       Model: 'HDL32E'
                   IPAddress: '192.168.1.001'
                        Port: 2368
     NumPointCloudsAvailable: 0
                     Timeout: 10
                   Streaming: 0
             CalibrationFile: 'matlab\...\utilities\velodyneFileReaderConfiguration\VLP16.xml'
  2. Preview the point cloud data to make sure the sensor is capturing the expected data.

    preview(v);

    The preview window opens.

  3. When you are done previewing, close the preview window.

    closePreview(v);

    You must close the preview window before you can use the read function to acquire data.

  4. Start streaming point clouds.

    start(v)
  5. Suppose you let the buffer build up for a while before you perform a read. You might then need to know how many point clouds are in the buffer. To find out, use the NumPointCloudsAvailable property. Use the property to query for the number of point clouds that are available in the buffer after the object has been created and streaming point clouds has started.

    n = v.NumPointCloudsAvailable
    
    n =
    
        8321
  6. Because you now have many point clouds in the buffer, you might want to look at the oldest point cloud and the latest point cloud to see how they vary with changing conditions over time.

  7. Get the oldest point cloud from the buffer.

    When you read the oldest point clouds in the buffer, newer point clouds continue to exist and be available. When you read the latest point clouds in the buffer, older point clouds are discarded. Therefore, read the oldest point cloud first.

    [pcloud, timestamp] = read(v, 'oldest');
  8. Display the point cloud.

    pcshow(pcloud);

    The point cloud is displayed in a Figure window.

    Note that pcshow is part of the Computer Vision Toolbox™.

  9. Now get the latest point cloud from the buffer. When you read the latest point cloud in the buffer, older point clouds are discarded.

    [pcloud, timestamp] = read(v, 'latest');
  10. Display the point cloud.

    pcshow(pcloud);

    The point cloud is displayed in a Figure window.

    If you compare the two figures you can see that the environment did change between the oldest and the latest images.

    Note that pcshow is part of the Computer Vision Toolbox.

  11. You can stop streaming point clouds at any time.

    stop(v)

See Also

| | | | | |

Related Topics