Main Content

readFrame

Read Velodyne point cloud from file

Description

ptCloud = readFrame(veloReader) reads the next point cloud in sequence from the Velodyne® PCAP file and returns a pointCloud object.

ptCloud = readFrame(veloReader,frameNumber) reads the point cloud with the specific frame number from the file.

example

ptCloud = readFrame(veloReader,frameTime) reads the first point cloud recorded at or after the given frameTime.

[ptCloud,pointTimestamps] = readFrame(___) returns the timestamps for all points in the point cloud using any combination of input arguments from previous syntaxes.

[ptCloud,pointTimestamps,positionData] = readFrame(___) returns the positional information for each point cloud frame.

Examples

collapse all

Create a velodyneFileReader object to read a Velodyne® packet capture (PCAP) file and select specific point clouds using a duration scalar.

Read in point clouds by using a Velodyne® file reader. Specify the PCAP file to read and the Velodyne® device model.

veloReader = velodyneFileReader('lidarData_ConstructionRoad.pcap','HDL32E');

Create a duration scalar that represents one second after the first point cloud reading.

timeDuration = veloReader.StartTime + duration(0,0,1,Format='s');

Read the first point cloud recorded at or after the given time duration.

ptCloudObj = readFrame(veloReader,timeDuration);

Display the point cloud using pcshow.

figure
pcshow(ptCloudObj)

Input Arguments

collapse all

Velodyne file reader, specified as a velodyneFileReader object.

Frame number of the desired point cloud in file, specified as a positive integer. Frame numbers are sequential.

Frame time of the desired point cloud in the file, specified as a duration scalar in seconds. The first frame available at or after frameTime is given.

Output Arguments

collapse all

Point cloud, returned as a pointCloud object.

Timestamps for all points in the point cloud, returned as a duration vector or a matrix.

The function returns timestamps as:

  • An M-element vector for unorganized point clouds. M is the total number of points in the point cloud.

  • An M-by-N matrix for organized point clouds. M and N are the number of rows and columns in the organized point cloud, respectively.

Timestamps are between the values of StartTime and EndTime, which are properties of the velodyneFileReader object. Points in an organized point cloud with a NaN value is returned with a time stamp set to NaN.

Position data, returned as a structure with five fields:

FieldDescription
GPSReadings

GPS reading data, returned as an M-by-4 matrix of data type double. The number of rows M is the number of position readings within a given frame. Each row is of the form [Latitude Longitude Heading Altitude], where :

  • Latitude — Latitude in decimal degrees obtained by the external GPS where north is positive.

  • Longitude — Longitude in decimal degrees obtained by the external GPS where east is positive.

  • Heading — Horizontal direction of motion in degrees from True North, obtained by the external GPS. Data in this column will be NaN when an external GPS is connected and a $GPGGA NMEA message is sent.

  • Altitude — Altitude in meters above sea level. Data in this column will be NaN when an external GPS is connected and a $GPRMC NMEA message is sent.

If the GPS hardware is not connected, then the function returns GPSReadings as an empty array, [].

GyroscopeReadings

Raw gyroscopic rotation readings in radians per second, collected from the three internal gyroscopes in GPS hardware, returned as an M-by-3 matrix of data type single. The matrix has these columns:

  • Gyro1 — Gyroscopic rotation with respect to the y-axis where the positive direction is clockwise around the y-axis when viewed from the origin.

  • Gyro2 — Gyroscopic rotation with respect to the x-axis where the positive direction is counter-clockwise around the x-axis when viewed from the origin.

  • Gyro3 — Gyroscopic rotation with respect to the z-axis where the positive direction is clockwise around the z-axis when viewed from the origin.

If the Velodyne device model is not HDL-32E, then the function returns GyroscopeReadings as an empty array, [].

AccelerometerReadings

Raw accelerometer readings, in m/s2, collected from the three internal accelerometers in GPS hardware, returned as an M-by-6 matrix of data type single. The columns of the matrix correspond to the x-, y-, and z-axis-axes of the sensor body for both the primary and backup accelerometer readings, as defined in the HDL-32E user manual [1]:

  • AccelYPrimary — Increases in the positive y-axis direction.

  • AccelXPrimary — Increases in the positive x-axis direction.

  • AccelZPrimary — Decreases in the positive z-axis direction.

  • AccelYBackup — Increases in the positive y-axis direction.

  • AccelXBackup — Increases in the negative x-axis direction.

  • AccelZBackup — Decreases in the positive z-axis direction.

If the Velodyne device model is not HDL-32E, then the function returns AccelerometerReadings as an empty array, [].

PositionTimestampsTimestamp for each position reading, returned as an M-by-1 duration vector.
GPSTimesTime of the GPS in UTC, returned as an M-by-1 duration vector, used to synchronize the timestamps of the GPS coordinates with their respective point clouds.

positionData returns [] when there is no position data in the PCAP file.

References

[1] Velodyne LiDAR, Inc. "HDL-32E User Manual." 63-9113 Rev. M, 2018.

Version History

Introduced in R2018a

expand all

See Also

Functions

Objects

External Websites