Skip to content

6. Processing Data Logs

ologandavid edited this page Sep 26, 2025 · 1 revision

Running the MATLAB data logger

Quad Logger also contains a script to process the bags and generate MATLAB figures and animations, and automatically saves them into our specified file structure. Run

cd quad_logger/bags
cp quad_log.bag <bag_name>.bag
roscd quad_logger/scripts
matlab

In MATLAB, open the processLog.m script and set the following variables:

  • Set the trialName variable to your <bag_name>, or leave as a blank string (this will open a UI where you can select your bagfile directly).
  • Set the namespace variable to your <robot_ns> (the namespace of the robot set in quad_gazebo.launch).
  • set bAnimate to true or false depending on whether you would like to see the trajectory animated in the body frame (MATLAB is unable to visualize floating base URDFs).
  • set bSave to true or false depending on whether you would like to save all the data and figures to a video. If yet, this will create (or overwrite) a folder named trialName in quad_logger/logs with all your data.

You can also run matlab without the desktop GUI (matlab -nodesktop), and call processLog(<bag_name>) from the command window. This will automatically animate and save the data.

The folder created from bSave = true will be ignored by git.

Note for ROS2

In ROS 2, bag files are no longer single .bag files as in ROS 1, but instead are stored as directories that contain metadata and split data files (e.g., metadata.yaml, data_0.db3, etc.). To read these bags in MATLAB, the corresponding custom message types must first be generated so that MATLAB can interpret the topics correctly. This is done with ROS 2 Message Generation in the MATLAB terminal:

ros2genmsg('~/ros2_ws/src/quad-sdk')
rehash toolboxcacheclear

Replay bag file in RViz (ROS1)

Record data:

roslaunch quad_utils logging.launch

Visualize data:

roslaunch quad_utils quad_visualization.launch
roscd quad_logger/bags
rosbag play quad_log.bag

Use the "Reset" button in RViz to flash and rerun a new bag.

Replay bag file in RViz (ROS2)

Record data:

ros2 launch quad_utils logging.py

Visualize data:

ros2 launch quad_utils quad_visualization.py
cd quad_logger/bags
ros2 bag play quad_log_bag/

Use the "Reset" button in RViz to flash and rerun a new bag.

Clone this wiki locally