Tutorials/drcsim/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 DRC simulated 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.

Important note: Fill in drcsim-1.0 (where 1.0 is the correct version number of drcsim) to refer to the correct location of the setup files. You can find a version number using `ls -d /usr/share/drcsim*`.

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

source ~/.bashrc

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

sudo apt-get install ros-fuerte-visualization

Bring up the DRC robot in Gazebo

drcsim-1.0

roslaunch drc_robot_utils drc_robot.launch

or, for drcsim-1.1 with the trajectory controllers used by default

roslaunch drc_robot_utils drc_robot_position_controllers.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.



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 '/left_eye/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 '/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.




 * 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 /joint_states /left_eye/image_raw /scan


 * 1) Moving the DRC robot around and recording movement ###

Move the joints to specific positions using the following commands in the form of:

rostopic pub std_msgs/Float64 '{ data : }'

For example the following commands will put the robot into an interesting pose. In a separate terminal, type these commands. Press Control + C after every one.

rostopic pub /l_leg_lhy_position_controller/command std_msgs/Float64 '{ data : -1.57 }'

rostopic pub /l_arm_usy_position_controller/command std_msgs/Float64 '{ data : -1.57 }'

rostopic pub /r_arm_usy_position_controller/command std_msgs/Float64 '{ data : 1.57 }'

Return the robot to its home state, again pressing Control + C after each one.

rostopic pub /l_leg_lhy_position_controller/command std_msgs/Float64 '{ data : 0 }'

rostopic pub /l_arm_usy_position_controller/command std_msgs/Float64 '{ data : 0 }'

rostopic pub /r_arm_usy_position_controller/command std_msgs/Float64 '{ data : 0 }'

Stop the rosbag recording by pressing Control + C in its terminal.


 * 1) Playing and Visualizing rosbags ##

Bring down rviz and your simulation of the DRC 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.




 * 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.


 * 1) Next ##

Next: DRC Robot Joint Control