Main Content

readNextMessage

Read next message from Ibeo Data Container (IDC) file selection

Description

example

msg = readNextMessage(msgReader) reads the next message from the selection of messages available in the ibeoMessageReader object, msgReader. By default, readNextMessage starts reading from the first message in the selection and reads subsequent messages during successive calls, all the way to the last available message. To reset the reading back to the first message, use reset method on the ibeoMessageReader object. If the MessageType property of msgReader is 'object', this syntax returns the next online object message.

[msg,metadata] = readNextMessage(msgReader) returns the metadata associated with the selected message. If MessageType property of msgReader is 'object', then this syntax does not apply.

[rawMsg,procMsg] = readNextMessage(msgReader) returns the next online object detection message, rawMsg, and postprocessed object detection message, procMsg, in the selection. To use this syntax, MessageType property of msgReader must be 'object'.

[rawMsg,procMsg,rawMetadata,procMetadata] = readNextMessage(msgReader) returns the metadata associated with, rawMsg and procMsg. To use this syntax, the MessageType property of msgReader must be 'object'.

[___] = readNextMessage(msgReader,'DeviceID',deviceID) reads the next message from the selection of messages, that correspond to the specified device, deviceID.

Examples

collapse all

Create an ibeoFileReader object, ibeoReader, to read the message headers from the IDC file. Replace the placeholder argument sample_data.idc with the name of your IDC file as sample_data.idc file is not provided with the toolbox.

ibeoReader = ibeoFileReader('sample_data.idc')
ibeoReader =
 
  ibeoFileReader with properties:
 
       FileName: "C:/Documents/MATLAB/ibeo_data/sample_data.idc"
      StartTime: 15-Mar-2020 11:21:04.999434999
        EndTime: 15-Mar-2020 11:25:35.030095000
       Duration: 00:04:30
    FileSummary: CAN             53    msgs [0x1002]
                 scan            53    msgs [0x2205]
                 object          106   msgs [0x2281]
                 image           53    msgs [0x2403]
                 vehicleState    53    msgs [0x2808]
                 measurementList 53    msgs [0x2821]
                 pointCloudPlane 53    msgs [0x7510]
                 unsupported     53    msgs [0x6120]
                 unsupported     53    msgs [0x6970]

Create an ibeoMessageReader object, imgReader, to read all images in the first 2 minutes, by using the select function with appropriate message type and time range values.

timeRange = [0, minutes(2)];
imgReader = select(ibeoReader, 'image', timeRange);

Visualize the message data by reading the messages one at a time to a video player object. First, create a vision.VideoPlayer object. Then, use the hasNextMessage function to check whether imgReader contains a message after the current one. If it does, use readNextMessage function to read the images into the workspace.

videoPlayer = vision.VideoPlayer;
while hasNextMessage(imgReader)
    img = readNextMessage(imgReader);
    step(videoPlayer,img);
end
release(videoPlayer);
     

Reset the ibeoMessageReader object, imgReader, to the first message in the selection, using the reset function.

 reset(imgReader);

Input Arguments

collapse all

Message reader, specified as a ibeoMessageReader object.

Output Arguments

collapse all

Message read from IDC file, returned as a structure, pointCloud or array, determined by the MessageType property of the msgReader. For more information, see Data Structure of Ibeo Message and Metadata.

Metadata of the message, returned as a structure. The fields of each structure are determined by the MessageType property of msgReader. For more information, see Data Structure of Ibeo Message and Metadata.

Online object detection message, returned as an array of structures. To return this argument, the MessageType property of msgReader must be 'object'. For more information, see Data Structure of Ibeo Message and Metadata.

Postprocessed object detection message, returned as an array of structures. To return this argument, the MessageType property of msgReader must be 'object'. For more information, see Data Structure of Ibeo Message and Metadata.

Metadata of the online object detection message, returned as a structure. To return this argument, the MessageType property of msgReader must be 'object'. For more information, see Data Structure of Ibeo Message and Metadata.

Metadata of the postprocessed object detection message, procMsg, returned as a structure. To return this argument, the MessageType property of the msgReader must be 'object'. For more information, see Data Structure of Ibeo Message and Metadata.

More About

collapse all

Data Structure of Ibeo Message and Metadata

The following function calls illustrate the use of readNextMessage function to read a single message and its associated metadata from an IDC file using an ibeoMessageReader object.

  • [msg, metadata] = readNextMessage(msgReader)

  • [rawMsg, procMsg, rawMetadata, procMetadata] = readNextMessage(msgReader)

This table highlights the format and data structure of the message and metadata returned by this function, based on the message type of the ibeoMessageReader object.

Message TypeMessage Format [msg, rawMsg, procMsg]Metadata Format [metadata, rawMetadata, procMetadata]
Scan

pointCloud

ScanMetaDataStruct

PointCloudPlane

pointCloud

PointCloudPlaneMetaDataStruct

Image

H-by-W-by-3 array, where H and W are the height and width of the image.

ImageMetaDataStruct object

Object

Both online objects and post-processed objects have the same structure.

M-by-1 structure array of ObjectStruct, where M is the number of object detections

ObjectMetaDataStruct

VehicleState

VehicleStateStruct

VehicleStateMetaDataStruct

MeasurementList

M-by-1 structure array of MeasurementStruct, where M is the number of measurements

MeasurementMetaDataStruct

CAN

CANStruct

CANMetaDataStruct

Introduced in R2021a