Main Content

start

Start streaming point clouds from Velodyne LiDAR sensor

Since R2022b

Add-On Required: This feature requires the MATLAB Coder Support Package for NVIDIA Jetson and NVIDIA DRIVE Platforms add-on.

Description

example

start(lidarobj) starts streaming point clouds from the Velodyne LiDAR® sensor specified by lidarobj. Before it adds new point clouds, the function deletes existing point clouds.

Examples

collapse all

This example shows how to create a connection to a Velodyne LiDAR sensor on an NVIDIA® Jetson™ platform and capture PointCloud frames from this sensor.

Create a live hardware connection from the MATLAB® software to the NVIDIA hardware by using the jetson function. To create a live hardware connection object, provide the host name or IP address, user name, and password of the target board. For example,

hwobj = jetson('jetson-board-name','ubuntu','ubuntu');

Create a MATLAB entry-point function to capture PointCloud frames from a Velodyne LiDAR sensor.

function outStruct = readPointCloudFrame(mdlName,calibFile,port)
%#codegen

% Create hwobj
hwobj = jetson();

% % Create Velodyne Lidar Object for 'VLP16' make
obj = velodynelidar(hwobj,mdlName,calibFile,'Port',port);

% Start Receiving LiDAR Packets
start(obj);
if strcmp(mdlName,'VLP16')
    lenOut = 120;
    outStructLen = 28000;
else
    lenOut = 70;
    outStructLen = 48000;
end
% timePause = uint8(1);
outStruct = cell(2,lenOut);

for i=1:lenOut
    outStruct{1,i} = zeros(outStructLen,3);
    outStruct{2,i} = zeros(outStructLen,1,'uint8');
end

for i=1:lenOut

    % Read a Point Cloud frame
    pcFrame = read(obj);

    outStruct{1,i} = pcFrame.Location(1:min(pcFrame.Count,outStructLen),:);
    outStruct{2,i} = pcFrame.Intensity(1:min(pcFrame.Count,outStructLen));

    pause(0.1);

end


% Stop receiving LiDAR Packets
stop(obj);

% xyz = pcFrame.Location;
% Intensity = pcFrame.Intensity;

end

Note

The entry-point function cannot have multiple connection objects to the Velodyne LiDAR sensor.

Deploy the readPointCloudFrame entry-point function to the NVIDIA Jetson platform

sensorModel = coder.Constant('VLP16');
port = 2368;
calibrationFile = coder.Constant(fullfile(pwd,'VLP16CalibFile.xml'));

cfg = coder.config('exe');
cfg.Hardware = coder.hardware('NVIDIA Jetson');
cfg.GenerateExampleMain = "GenerateCodeAndCompile";

codegen -config cfg -args {sensorModel,calibrationFile,port} readPointCloudFrame

Input Arguments

collapse all

Velodyne LiDAR sensor connection created by using velodynelidar, specified as a velodynelidar object.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2022b