Play back data from ROS 2 log file
ROS Toolbox / ROS 2
The Read Data block plays back ROS 2 bag log files by outputting the most
recent message from the log file, based on the current simulation time. You must load a ROS 2
bag log file (
.db3) and specify a topic, using the
Topic parameter, to get a stream of messages from the file. The block
outputs messages of this topic from the file in sync with the simulation time.
In the Read Data block mask, select Load logfile data
to specify a ROS 2 bag log file (
.db3) to load. In the Load Logfile dialog
box, specify the full path to the log file, or select Browse and navigate to the logfile you
want to load. To start playback at a certain point in the file, specify a Start time
offset, in seconds. To specify how long the block plays back this file, from the
specified start time, specify a Duration, in seconds. By default, the
block outputs all messages for the specified topic in the file.
IsNew — New message indicator
New message indicator, returned as a logical scalar. If the output is
1, then the block loaded a new message from the ROS 2 bag log
file at the corresponding time. This output can be used to trigger subsystems for
processing new messages.
Msg — ROS 2 message
ROS 2 message, returned as a nonvirtual bus. Messages are returned in the order they are stored in the ROS 2 bag log file and synced with the simulation time.
Topic — Topic name to extract from log file
string scalar | character vector
Specify the name of the topic to extract from the log file. This topic must exist in the loaded ROS 2 bag log file. Click Select to inspect the available topics and select a specific topic.
Sample time — Interval between outputs
-1 (default) | scalar
Specify the interval between outputs. In simulation, the sample time follows simulation time rather than wall-clock time.
The default value indicates that the block sample time is inherited. For more information about the inherited sample time type, see Specify Sample Time (Simulink).