Analyze bag file: plotjuggler, rqt_bag
Video of this tutorial
Video of this tutorial is here
Capturing the bag file
We download three repos which enable simulating robot motion with turtlesim, and giving it a sequence of waypoints to follow using scripted_bot_driver. We build the repos, and run the robot in simulation and capture a bagfile, then we view various parameters from the bag file with Plotjuggler and rqt_bag.
Download and build the repos
The following can be done inside a docker container, or in a regular ROS installation
Clone the following repow into ros2_ws/src:
git clone git@github.com:PaulBouchier/scripted_bot_driver.git
git clone git@github.com:PaulBouchier/scripted_bot_interfaces.git
git clone git@github.com:PaulBouchier/generic_turtlesim.git
cd to ~/ros2_ws and build the workspace: colcon build
source the workspace build/setup.bash: source ~/ros2_ws/install/setup.bash
Run the simulation and capture a bag file
launch a terminator window in a ROS environment (e.g. inside a docker shell) and split into 5 ros windows
In one window run ros2 run swri_console swri_console
In another window, run the turtelbot simulator: ros2 launch generic_turtlesim generic_turtlesim_launch.yaml
In another window, launch the robot motion action server: ros2 launch scripted_bot_driver servers_launch.py
Observe console output is diplayed on a per-node basis by swri_console. You can switch between the nodes by clicking their name and view the output of each.
In another window, cd to your bag_files directory start capturing a bag file which records all messages on all topics: ros 2 bag record -a
In another window, run the scripted_move command, giving the robot a list of waypoints in the turtlesim simulator to traverse: ros2 run scripted_bot_driver scripted_mover drive_waypoints 8 4 2 2 3 3 5.5 5.5
Here is what your terminator window could look like, showing the commands run:
Observe the turtle traversing the waypoints in the turtlesim window, and progress output from the action servers and scripted_mover node is displayed in swri_console. When the turtlebot has stopped moving, stop bag recording with Ctrl-C in the bag recording window.
Here is what the turtlesim track looks like for the waypoints shown
Swri_console output:
View the bag with Plotjuggler and rqt_bag
In the bag record window (in the bag files directory), run plotjuggler and select the bag file you just recorded and choose topics from which to plot variables. See the video for a walk through of how to use plotjuggler
Run plotjuggler: ros2 run plotjuggler plotjuggler
In the bag record window (in the bag files directory), run rqt_bag and select the bag file you just recorded. The main pane shows all the topics in the bagile and which ones have messages at which times. Left click to set the playback head to a point in time you'd like to look at. Zoom in with the mouse wheel. Right-click on a topic name and select view -> raw. Observe a pane added with the contents of the last message on this topic at the time where the playback head is. Try stepping forward and back in messages and see the contents of the message at the play head. Add a second topic and step through its messages. Both message windows update based on the last recorded message at the time the cursor is at. Observe the cursor moves as you step forward and back in messages. See the video for a walk through of how to use rqt_bag
Run rqt_bag: ros2 run rqt_bag rqt_bag