Tutorials/drcsim/2.2/visualizing logging data


 * 1) DRC Tutorial: Visualize and Log Sensor Data

Visualizing and logging sensor information is an important part in developing and debugging controllers. This tutorial will show you how to visualize the simulated Atlas robot in rviz, log sensor information and replay that logged sensor information through rviz.

See the documentation pages of rviz and rosbag for more information.


 * 1) Setup ##

We assume that you've already done the installation step.

If you haven't done so, add the environment setup.sh files to your .bashrc.

echo 'source /usr/share/drcsim/setup.sh' >> ~/.bashrc

source ~/.bashrc

Install the ROS visualization tools if you do not yet have them. From the command line:

For ROS Fuerte:

sudo apt-get install ros-fuerte-visualization

For ROS Groovy:

sudo apt-get install ros-groovy-visualization

Bring up the Atlas robot in Gazebo

roslaunch atlas_utils atlas.launch

When it comes time to bring down this process, press Control + C in the same terminal window. Closing Gazebo from the GUI will not kill the additional processes spawned with roslaunch.


 * 1) Visualizing Sensor Data with rviz ##

rviz is a powerful robot visualization tool. It provides a convenient GUI to visualize sensor data, robot models, environment maps, which is useful for developing and debugging your robot controllers.

While your robot is running, start rviz from the command line
 * 1) Running Rviz ###

rosrun rviz rviz




 * 1) Visualizing the Robot model ###

Now instead of the black screen, we want to actually visualize information. At the bottom of the 'Displays' group, you'll find buttons 'Add', 'Remove', 'Rename' for adding items to visualize, removing items and renaming them. Let's first add the robot model, so click 'Add' and scroll to 'rviz > Robot Model' and click 'OK'. It should now look like the display below.



We now need to tell rviz which fixed frame we want to use. In the 'Displays' group, under the '.Global Options' item, click the frame label next to 'Fixed Frame'. Type in or select '/pelvis'. You should now see your robot model from a distance.

TODO: imu_link is in error (no transform to pelvis)



To navigate using a wheeled mouse:

* Holding left click and dragging rotates the camera around the model

* Holding scroll wheel and dragging pans the camera

* The scroll wheel zooms in and out

* Holding right click and dragging scrolls in and out as well.


 * 1) Visualizing Sensor Information ###

Now we will add sensors to visualize. Click 'Add' to add a new item and add 'rviz > Camera'. Under the Camera item in the displays window, click the empty space to the right of 'Image Topic' and an empty field should appear. Select or type '/multisense_sl/camera/left/image_raw'. You should now see the camera video feed in a small frame.



Now add a LaserScan using a similar method as the camera, and change the 'Topic' to '/multisense_sl/scan'. You should now see a visualization of the laser scan in rviz.

Poke around in rviz and add different sensors or robot information. TF visualizes the joint transformations, Map visualizes a 2D collision map, PointCloud(2) visualizes depth information from sensors like a Microsoft Kinect.

Bonus: actuate the laser. The laser on the robot's head is mounted on a spindle that rotates. To start it rotating:

rostopic pub /multisense_sl/set_spindle_speed std_msgs/Float64 '{ data: 6.0 } '

The data value is a desired angular velocity, in radians per second. You should see the laser scan in rviz rotating around. To build a poor-man's 3-D model of the environment, click in the "Decay Time" field of the "LaserScan" display and increase the time to something non-zero (it's a value in seconds). You should see scans accumulate in rviz.




 * 1) Saving the rviz Configuration ###

To save the configuration as the default, click "File > Save Config". The next time you run rviz, it will load this configuration.

You can save and load non default configurations by using "File > Save Config as ... " and "File > Open Config" respectively.

You can also run rviz with a different configuration by specifying it at the command line. Note: Insert the path to the file.

rosrun rviz rviz -d /your/config/file.vcg


 * 1) Logging Sensor Data with rosbag ##

rosbag provides an easy tool for the efficient storage of topic streams during robot operation.

You can see a list of ROS topics by running

rostopic list

We will record the joint states, cameras, laser and tf (transform data) from a robot into a file called ROS.bag

rosbag record -O /tmp/ROS.bag /tf /atlas/joint_states /multisense_sl/camera/left/image_raw /multisense_sl/camera/left/camera_info /multisense_sl/scan

After a while, stop the rosbag recording by pressing Control + C in its terminal.


 * 1) Playing and Visualizing rosbags ##

Bring down rviz and your simulation of the Atlas robot. We'll now create a launch file to play the rosbag file.

To play the bag file create a launch file called "playback.launch" with the following content:





You can launch the file with the following command, providing the full absolute path to your `ROS.bag` file.

roslaunch playback.launch file:=/tmp/ROS.bag

In a separate terminal run rviz and get the list of topics played by the rosbag

rosrun rviz rviz &

rostopic list

In rviz, add the robot model, cameras, laser scan and the tf if they weren't saved in your configuration. These streams should now be visualized in rviz as if the robot were running. You should see the robot model itself move to the positions you commanded during the rosbag recording (specifically, the laser should rotate).

Note: The playback will loop, but rviz needs to be told that time was reset at the end of each loop. If you see the data stop displaying in rviz, click the "Reset" button in the "Time" bar (by default, it's in the lower right corner). Data display should start up again.


 * 1) Wrap up ##

You should now be familiar with how to visualize ROS topics in rviz as well as how to log them to a rosbag. You should also now be familiar with how to replay rosbag files and visualize them in rviz.