Main Content

readTopicMsgs

Read topic messages

Since R2020b

Description

example

msgTable = readTopicMsgs(ulogOBJ) reads the data of all topic messages from the specified ulogreader object and returns a table that contains topic names, instance ID, start timestamp, last timestamp, topic messages, and message format for all available topics.

msgTable = readTopicMsgs(ulogOBJ,Name,Value) reads the data pertaining to the specified name-value pairs.

Example: readTopicMsgs(ulog,'TopicNames',{'vehicle_attitude'},'InstanceID',{0},'Time',[d1 d2])

Examples

collapse all

Load the ULOG file. Specify the relative path of the file.

ulog = ulogreader('flight.ulg');

Read all topic messages.

msg = readTopicMsgs(ulog);

Specify the time interval between which to select messages.

d1 = ulog.StartTime;
d2 = d1 + duration([0 0 55],'Format','hh:mm:ss.SSSSSS');

Read messages from the topic 'vehicle_attitude' with an instance ID of 0 in the time interval [d1 d2].

data = readTopicMsgs(ulog,'TopicNames',{'vehicle_attitude'}, ... 
'InstanceID',{0},'Time',[d1 d2]);

Extract topic messages for the topic.

vehicle_attitude = data.TopicMessages{1,1};

Read all system information.

systeminfo = readSystemInformation(ulog);

Read all initial parameter values.

params = readParameters(ulog);

Read all logged output messages.

loggedoutput = readLoggedOutput(ulog);

Read logged output messages in the time interval.

log = readLoggedOutput(ulog,'Time',[d1 d2]);

Input Arguments

collapse all

ULOG file reader, specified as a ulogreader object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'Time',[d1 d2]

Topic names of the desired messages, specified as a cell array of character vectors or a string array.

Example: 'TopicNames',{'sensor_combined','actuator_outputs'} or 'TopicNames',["actuator_outputs","ekf2_timestamps"]

Instance ID of the topic of the desired messages, specified as a cell array of positive integer scalars or vectors. Specify this name-value pair along with its corresponding 'TopicNames' name-value pair.

Example: 'TopicNames',{'vehicle_attitude','actuator_outputs'},'InstanceID',{0,[0 1]}

Time interval between which to select messages, specified as a two-element vector of duration, or a double array. The duration array is specified in the 'hh:mm:ss.SSSSSS' format. The double array is specified in microseconds.

Example: 'Time',[d1 d2]

Output Arguments

collapse all

Topic messages information, returned as a table with the columns:

  • TopicNames

  • InstanceID

  • StartTimestamp

  • LastTimestamp

  • TopicMessages

  • MsgFormat

Version History

Introduced in R2020b