Main Content

hesaiFileReader

Read point cloud data from Hesai PCAP file

Since R2022a

Description

The hesaiFileReader object reads point cloud data from a Hesai® packet capture (PCAP) file.

Creation

Description

hesaiReader = hesaiFileReader(fileName,deviceModel) creates a hesaiFileReader object that reads point cloud data from a Hesai PCAP file. Specify the PCAP file fileName and the device model deviceModel. The inputs set the FileName and DeviceModel properties, respectively. The reader supports the Pandar128E3X, Pandar64, PandarQT, and PandarXT32 device models.

example

hesaiReader = hesaiFileReader(___,Name=Value) specify CalibrationFile and SkipPartialFrames properties using one or more name-value arguments. For example, hesaiFileReader(fileName,deviceModel,SkipPartialFrames=0) creates an Hesai file reader that does not skip partial frames.

Properties

expand all

This property is read-only.

Name of the Hesai PCAP file, specified as a character vector or string scalar.

This property is read-only.

Name of the Hesai device model, specified as "Pandar128E3X", "Pandar64", "PandarQT", or "PandarXT32".

Note

Specifying the incorrect device model returns no frames or an improperly calibrated point cloud.

This property is read-only.

Name of the Hesai calibration CSV file, specified as a character vector or string scalar. This calibration file is included with every sensor.

To set this property, you must specify it at object creation.

Example: CalibrationFile='CalibrationFileName' specifies the Hesai calibration CSV file.

This property is read-only.

Partial frame processing, specified as a logical 1 (true) or 0 (false). To skip partial frames, defined as frames with a horizontal field of view less than the mean horizontal field of view of all frames in the PCAP file, specify this property as true. Otherwise, specify it as false.

To set this property, you must specify it at object creation.

Example: SkipPartialFrames=true skips partial frames in the PCAP file.

This property is read-only.

Return mode of the Hesai PCAP file, specified as a character vector.

This property is read-only.

Total number of point cloud frames in the file, specified as a positive integer.

This property is read-only.

Total duration of the file, specified as a duration scalar in seconds.

This property is read-only.

Time of the first point cloud reading, specified as a duration scalar in seconds.

The Hesai sensor sets the start time value relative to the most recent second. For instance, if the file is recorded for 7 minutes from 1:58:00.5 p.m. to 2:05:00.5 p.m., then:

  • StartTime = 0.5 s

  • EndTime = StartTime + 7 min × 60 s = 420.5 s

This property is read-only.

Time of the last point cloud reading, specified as a duration scalar in seconds.

The Hesai sensor sets the start time value relative to the most recent second. For instance, if the file is recorded for 7 minutes from 1:58:00.5 p.m. to 2:05:00.5 p.m., then:

  • StartTime = 0.5 s

  • EndTime = StartTime + 7 min × 60 s = 420.5 s

Time of the current point cloud reading, specified as a duration scalar in seconds. As you read point clouds using readFrame, this property updates with the most recent point cloud reading time. You can use reset to reset the value of this property to the default value. The default value matches the StartTime property.

This property is read-only.

Start time for each point cloud frame, specified as a duration vector with values in seconds. The length of the vector is equal to the value of the NumberOfFrames property. The value of the first element in the vector is same as the value of the StartTime property. You can use this property to read point cloud frames captured at different times.

Object Functions

hasFrameDetermine if another Hesai point cloud is available
readFrameRead Hesai point cloud from file
resetReset hesaiFileReader object to first frame

Examples

collapse all

Download a ZIP file containing a Hesai packet capture (PCAP) file and then unzip the file.

zipFile = matlab.internal.examples.downloadSupportFile("lidar","data/hesai_BusyRoad.zip");
saveFolder = fileparts(zipFile);
pcapFileName = [saveFolder filesep 'hesai_BusyRoad.pcap'];
if ~exist(pcapFileName,"file")
    unzip(zipFile,saveFolder);
end

Create a hesaiFileReader object.

hesaiReader = hesaiFileReader(pcapFileName,"Pandar128E3X");

Define X-, Y-, and Z-axes limits for pcplayer, in meters.

xlimits = [-60 60];
ylimits = [-60 60];
zlimits = [-20 20];

Create a point cloud player.

player = pcplayer(xlimits,ylimits,zlimits);

Set labels for the pcplayer axes.

xlabel(player.Axes,"X (m)");
ylabel(player.Axes,"Y (m)");
zlabel(player.Axes,"Z (m)");

Specify the CurrentTime of the Hesai file reader so that it starts reading from 0.3 seconds after the start time.

hesaiReader.CurrentTime = hesaiReader.StartTime + seconds(0.3);

Display the stream of point clouds from CurrentTime to the final point cloud.

while(hasFrame(hesaiReader) && player.isOpen())
    ptCloud = readFrame(hesaiReader);
    view(player,ptCloud(1)); 
end

Figure Point Cloud Player contains an axes object. The axes object with xlabel X (m), ylabel Y (m) contains an object of type scatter.

Version History

Introduced in R2022a