Visible to the public Recording with rosbagConflict Detection Enabled

The goal of this tutorial is to make the car move around while capturing data to a ROS bagfile. Capturing output data is a staple requirement to verify behaviors, and capturing input data is a critical piece of establishing the regression behavior of a system, since those input data can be re-applied in new releases, or to ensure that safety is guaranteed with perturbations to the data stream.

Overview

rosbag is a utility that permits saving of data from the available topics to a file, which can be replayed and examined after the end of a simulation or experiment. This tutorial aims to show how to use rosbag with our setup, but you can learn much more about rosbag at the ROS website: http://wiki.ros.org/rosbag

Starting up the simulation

Let's use the Canyon View simulation, since it will produce interesting sensor stream information.

$ roslaunch azcar_sim azcar_canyonview.launch

Visualize the data in rviz

$ rosrun rviz rviz

Load your favorite .rviz file to see what's interesting to you. We're now ready to start subscribing to a rosbag

Start the rosbag recorder

rosbag subscribes to all the topics available when it starts up, so let's see what topics are currently available:

$ rostopic list /azcar_sim/cmd_vel /azcar_sim/cmd_vel_safe /azcar_sim/distanceEstimator/angle /azcar_sim/distanceEstimator/dist /azcar_sim/front_laser_points /azcar_sim/front_left_steering_position_controller/command /azcar_sim/front_right_steering_position_controller/command /azcar_sim/joint1_velocity_controller/command /azcar_sim/joint2_velocity_controller/command /azcar_sim/joint_states /azcar_sim/lidar_points /azcar_sim/odom /azcar_sim/path /azcar_sim/steering /azcar_sim/vel /clicked_point /clock /gazebo/link_states /gazebo/model_states /gazebo/parameter_descriptions /gazebo/parameter_updates /gazebo/set_link_state /gazebo/set_model_state /initialpose /move_base_simple/goal /rosout /rosout_agg /tf /tf_static

Let's start recording.

$ rosbag record -O azcar_tutorial -a [ INFO] [1464707803.014809018, 2713.743000000]: Subscribing to /tf [ INFO] [1464707803.015188093, 2713.743000000]: Recording to azcar_tutorial.bag. [ INFO] [1464707803.021444800, 2713.744000000]: Subscribing to /clicked_point [ INFO] [1464707803.031353266, 2713.744000000]: Subscribing to /azcar_sim/steering [ INFO] [1464707803.050860446, 2713.748000000]: Subscribing to /azcar_sim/front_left_steering_position_controller/command [ INFO] [1464707803.056252991, 2713.748000000]: Subscribing to /move_base_simple/goal [ INFO] [1464707803.060882494, 2713.748000000]: Subscribing to /azcar_sim/path [ INFO] [1464707803.065875678, 2713.749000000]: Subscribing to /azcar_sim/joint_states [ INFO] [1464707803.071483786, 2713.750000000]: Subscribing to /tf_static [ INFO] [1464707803.078216378, 2713.754000000]: Subscribing to /gazebo/parameter_descriptions [ INFO] [1464707803.102165014, 2713.768000000]: Subscribing to /azcar_sim/joint1_velocity_controller/command [ INFO] [1464707803.125626420, 2713.781000000]: Subscribing to /azcar_sim/cmd_vel_safe [ INFO] [1464707803.134565556, 2713.786000000]: Subscribing to /azcar_sim/vel [ INFO] [1464707803.147343595, 2713.789000000]: Subscribing to /azcar_sim/distanceEstimator/angle [ INFO] [1464707803.155786243, 2713.793000000]: Subscribing to /azcar_sim/distanceEstimator/dist [ INFO] [1464707803.164458756, 2713.796000000]: Subscribing to /rosout [ INFO] [1464707803.179264090, 2713.799000000]: Subscribing to /initialpose [ INFO] [1464707803.188056992, 2713.801000000]: Subscribing to /rosout_agg [ INFO] [1464707803.199550325, 2713.806000000]: Subscribing to /azcar_sim/front_laser_points [ INFO] [1464707803.227938195, 2713.809000000]: Subscribing to /gazebo/link_states [ INFO] [1464707803.234883147, 2713.811000000]: Subscribing to /azcar_sim/lidar_points [ INFO] [1464707803.247438331, 2713.815000000]: Subscribing to /azcar_sim/joint2_velocity_controller/command [ INFO] [1464707803.255891726, 2713.818000000]: Subscribing to /gazebo/model_states [ INFO] [1464707803.271962928, 2713.822000000]: Subscribing to /clock [ INFO] [1464707803.281154851, 2713.825000000]: Subscribing to /azcar_sim/front_right_steering_position_controller/command [ INFO] [1464707803.294979986, 2713.830000000]: Subscribing to /azcar_sim/odom [ INFO] [1464707803.307516473, 2713.834000000]: Subscribing to /gazebo/parameter_updates

You may have noticed that we are not subscribed to cmd_vel: that's because it is not publishing. When that is published, you will see from rosbag's info stream that we subscribe to it.

Move around

Use your favorite way to make the car move around. In this example, I'm going to try to crash the car, to see whether the obstacle stopper component works, so I'm going to run the hoffmann follower, which will blindly try to run into a house or a jersey barrier. If you want to see this happening in gazebo, start up gzclient: note, however, that your machine is probably going to be complaining pretty soon about the number of processes being run!

$ rosrun hoffmannfollower hoffmannfollower_node

Check out what it looks like in rviz now (I modified my view to make this more dramatic):

The vehicle detects that we are approaching an obstacle, so it stops driving.

Stop recording your rosbag

Press Control-C on your rosbag tab, and you can look and see that it's probably pretty big---that's because you are also recording all the simulated Velodyne data, which takes up a lot of bandwidth. You could specify exactly which topics to which to subscribe, but that may take a long time.

Replay back the data

Go ahead and close everything---rviz, the main simulation, hoffmann follower, etc. Then, let's start up roscore

$ roscore

And now rviz

$ rosrun rviz rviz

In a new tab, let's replay the data we just recorded:

$ rosbag play azcar_tutorial.bag

In your rviz window, you should see the various data points, but you will not see the robot---that's because the robot parameter description is a parameter that lives in the ROS parameter server, and so it is not recorded by rosbag. You could (if you like) run the following command to see the robot:

$ roslaunch azcar_sim robotviz.launch

And now the robot should be visible, as long as you have been able to visualize it before.

Learning to use rosbags

This tutorial just gets you started with the quirks of our platform, please review the ROS tutorials on rosbags to learn how to echo data during playback, how to select data from bagfiles, playing back multiple bag files simultaneously, etc.