Main Content

read

Read point clouds from ousterlidar object buffer

Since R2022a

    Add-On Required: This feature requires the Lidar Toolbox Support Package for Ouster Lidar Sensors add-on.

    Description

    The read function reads point cloud data from the ousterlidar object buffer. The function then deletes the read point clouds and any point clouds older than them from the buffer.

    If the object is streaming, then the function returns only the point cloud data available in the buffer at the time of the function call, then continues streaming.

    If the object is not streaming and there are existing point clouds in the buffer, the function returns the point clouds available in the buffer. If there are no existing point clouds, the function starts streaming to obtain point cloud data, returns the data, and then stops streaming.

    example

    ptCloud = read(ousterObj) reads a point cloud from the ousterlidar object ousterObj. This syntax returns the oldest point cloud in the buffer.

    ptCloud = read(ousterObj,numPC) reads the number of point clouds specified by numPC from the ousterlidar object ousterObj.

    ptCloud = read(ousterObj,mode) specifies the mode in which to read point clouds from the ousterlidar object ousterObj starting with the oldest point cloud in the buffer.

    example

    ptCloud = read(ousterObj,numPC,mode) specifies the number of point clouds and the mode in which to read data from the object buffer.

    [ptCloud,timestamps] = read(___) returns point clouds and their respective timestamps from the ousterlidar object ousterObj using any combination of input arguments from the previous syntaxes.

    [___,pcAttributes] = read(___) returns a structure, pcAttributes, containing attributes for each point in the point cloud using any combination of input arguments from previous syntaxes.

    Examples

    collapse all

    You can read point clouds from an Ouster® lidar sensor with or without using the start function to stream data into the object buffer.

    If you do not stream from the sensor before reading, the read function internally starts streaming, acquires the specified point clouds, and then stops streaming.

    Create an ousterlidar object, ousterObj, for the OS0-64 sensor model.

    ousterObj = ousterlidar("OS0-64","OS0-64G_sample.json");

    Read point cloud data from the object buffer by using the read function. Because ousterObj is not currently streaming, the read function starts streaming, reads the latest point cloud, then stops streaming.

    [ptCloud,timestamp] = read(ousterObj);

    Display the point cloud by using the pcshow function.

    pcshow(ptCloud)

    You can read point clouds from an Ouster lidar sensor with or without using the start function to stream data into the object buffer.

    If you first stream point clouds into the object buffer, you can read them starting from the oldest or the most recent point cloud in the buffer. You can also specify the number of point clouds to read.

    Create an ousterlidar object, ousterObj, for the OS0-64 sensor model.

    ousterObj = ousterlidar("OS0-64","OS0-64G_sample.json");

    Start streaming point clouds into the object buffer by using the start function. The function continues streaming in the background.

    start(ousterObj)

    Read the oldest 10 point clouds from the buffer.

    [ptClouds,timestamps] = read(ousterObj,10,"oldest");

    After you use the read function, these 10 point clouds are no longer available in the buffer.

    You can stop streaming by using the stop function.

    stop(ousterObj)

    Input Arguments

    collapse all

    Ouster lidar sensor connection, specified as an ousterlidar object.

    Position of point clouds to read from the object buffer, specified as a character vector or string. The possible values are:

    • "oldest" — Returns point clouds beginning with the oldest point cloud.

    • "latest" — Returns point clouds beginning with the most recent point cloud.

    • "all" — Returns all point clouds available in the buffer.

    You can specify the number of point clouds to read from the buffer when this argument value is "oldest" or "latest" mode.

    Example: read(ousterLidar,10,'latest') reads the 10 most recent point clouds from the object buffer, and then deletes them from the buffer.

    Data Types: char | string

    Number of point clouds to read, specified as a positive integer.

    Data Types: double

    Output Arguments

    collapse all

    Point cloud data read from the Ouster lidar sensor, returned as a pointCloud object.

    Note

    In case of dual return, this function returns a point cloud array of the size numPC-by-2, corresponding to the strongest and second strongest return, respectively.

    Timestamps for the read point clouds, returned as a datetime array.

    Data Types: datetime

    Point cloud attributes for each point, returned as a structure that contains these fields:

    • Range — Distance from the sensor surface, specified as an M-by-N matrix.

    • SignalPhoton — Signal intensity of photons in the signal return measurement, specified as an M-by-N matrix, same as the size of Location property of pointCloud object ptCloud.

    • NearInfrared — Near infrared (NIR) photons related to natural environmental illumination, specified as an M-by-N matrix, same as the size of Location property of pointCloud object ptCloud.

    Note

    In case of dual return, this function returns point attributes as an array of size numPC-by-2, where the first column corresponds to the strongest return and the second column contains the second strongest return data.

    Version History

    Introduced in R2022a

    expand all