Log ROS Messages from Simulink to a Rosbag Logfile
A rosbag or bag is a file format in ROS for storing message data. These bags are often created by subscribing to one or more ROS topics, and storing the received message data in an efficient file structure. Using the ROS Logger app, you can log ROS messages from Simulink® models to rosbag files.
Open the Simulink model. This model is configured for ROS Simulation. To configure a new model for ROS simulation, under Apps, select Robot Operating System (ROS) and specify the appropriate ROS network configuration parameters.
To open the ROS Logger app dialog, under Simulation tab, from Prepare section, select ROS Logger.
Follow these steps to configure the signals to be logged and the rosbag file parameters:
Ensure that Enable ROS signal logging to ROS Bag file is checked.
Select the signals to be logged in the rosbag file by checking their respective checkboxes under the Enable column.
The default name of the generated rosbag file will be modelName_mmddyy_hh_mm_ss.bag. To provide a custom name, from the Logfile name dropdown, select
Custom. Then specify the desired File name.
Specify the Compression format to be
Specify the desired chunk size for writing, in bytes.
Initialize the ROS network.
Launching ROS Core... Done in 0.46512 seconds. Initializing ROS master on http://172.29.206.84:53504. Initializing global node /matlab_global_node_58663 with NodeURI http://dcc721972glnxa64:36991/ and MasterURI http://localhost:53504.
Simulate the model.
Simulation Complete. Start logging ROS bag file... Successfully logged ROS bag file to logROSMessagesFromSimulinkExampleModel_112622_09_32_58.bag.
After simulation, logging messages to rosbag file begins and completes with the success message on the Diagnostic Viewer.