[Documentation] [TitleIndex] [WordIndex

Note: This tutorial assumes that you have completed the previous tutorials: ROS tutorials.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

Visualizing the world model

Description: This tutorial shows how the wire_viz package can be used an configured..

Tutorial Level: BEGINNER

Goal

The goal of the wire_viz package is to visualize the input and the output send to and generated by twire in RViz.

Approach

The package listens to both the input and output topics of the wire_core package. It transforms all detections and/or world model objects to the appropriate frame, publishes a geometric marker at the appropriate position and, if preferred, adds a text label with information about discrete attributes, e.g., color, shape, object class, or world model ID.

Launching the visualization

First, clone the package and compile your workspace:

$ catkin_make

Then, launch the visualization:

$ roslaunch wire_viz start.launch

and start RViz:

$ rosrun rviz rviz

The markers are published over the topics /world_evidence and /visualization_markers/world_state. Both topics are of type visualization_msgs/MarkerArray.

On can instead use the launch file in the wire_tutorials package. This file launches both the visualization node and RViz with a configuration file:

$ roslaunch wire_tutorials rviz_wire_kinetic.launch

Configuring the visualization

The package can be configured by the detections.yaml file in the parameters folder of the package:

   1 # Specify marker properties for world model input (always specify default first)
   2 world_evidence:
   3  - {class: default, r: 1, g: 1, b: 1, scale_x: 0.07, scale_y: 0.07, scale_z: 0.07, show_text: false}
   4  - {class: text,    r: 1, g: 1, b: 1, scale_x: 0.1,  scale_y: 0.1,  scale_z: 0.1,  offset_z_pos: 0.2}
   5  - {class: cup,     r: 0, g: 1, b: 0, scale_x: 0.07, scale_y: 0.07, scale_z: 0.1,  type: cylinder}
   6 
   7 
   8 # Specify marker properties for world model output (always specify default first)
   9 world_state:
  10  - {class: default, r: 0, g: 1, b: 0, scale_x: 0.1, scale_y: 0.1, scale_z: 0.1, show_text: true}
  11  - {class: text,    r: 1, g: 0, b: 0, scale_x: 0.1, scale_y: 0.1, scale_z: 0.1, offset_z_pos: 0.2}
  12  - {class: cup,     r: 0, g: 1, b: 0, scale_x: 0.1, scale_y: 0.1, scale_z: 0.1, type: cylinder}
  13 
  14 
  15 # Discrete attributes that are shown in the text label for the world model input
  16 world_evidence_attributes:
  17  - {color: 1, shape: 0, class_label: 1}
  18  
  19 # Discrete attributes that are shown in the text label for the world model output
  20 world_state_attributes:
  21  - {ID: 1, class_label: 0, color: 0, shape: 0, name: 0}
  22 
  23 # Frame in which all markers are shown
  24 marker_frame: /map

A complete list of all parameters and topics is given on the wire_viz page.

The code explained

   1 # Specify marker properties for world model input (always specify default first)
   2 world_evidence:
   3  - {class: default, r: 1, g: 1, b: 1, scale_x: 0.07, scale_y: 0.07, scale_z: 0.07, show_text: false}
   4  - {class: text,    r: 1, g: 1, b: 1, scale_x: 0.1,  scale_y: 0.1,  scale_z: 0.1,  offset_z_pos: 0.2}
   5  - {class: cup,     r: 0, g: 1, b: 0, scale_x: 0.07, scale_y: 0.07, scale_z: 0.1,  type: cylinder}

This part defines how the world evidence (world model input) markers should look like. The first line must always specify a default marker. In this case the default marker has RGB values of (1,1,1) on a scale from [0,1], hence white. The default size is 0.07 in all directions and no text label is added. The second line defines how the optional text marker looks like. The offset_z_pos field allows for defining an offset in the z-direction, such that the text marker appears above the geometric marker. The last line defines the marker for detections with class label cup. Note that type can be used to define the geometric shape of the marker. If the world_evidence contains the discrete attribute color, the color in the message overwrites the color given in this specification, i.e., a detection of a green cup always results in a green marker. A full list of the available ROS parameters is given on the wire_vis page.

   8 # Specify marker properties for world model output (always specify default first)
   9 world_state:
  10  - {class: default, r: 0, g: 1, b: 0, scale_x: 0.1, scale_y: 0.1, scale_z: 0.1, show_text: true}
  11  - {class: text,    r: 1, g: 0, b: 0, scale_x: 0.1, scale_y: 0.1, scale_z: 0.1, offset_z_pos: 0.2}
  12  - {class: cup,     r: 0, g: 1, b: 0, scale_x: 0.1, scale_y: 0.1, scale_z: 0.1, type: cylinder}

The second part defines the markers visualizing the world state. Again, the default must be defined first. In this case, world model object markers will get a text label. Again, the color specified here will be overwritten by color defined by the color attribute, since this leads to more intuitive markers.

  15 # Discrete attributes that are shown in the text label for the world model input
  16 world_evidence_attributes:
  17  - {color: 1, shape: 0, class_label: 1}
  18  
  19 # Discrete attributes that are shown in the text label for the world model output
  20 world_state_attributes:
  21  - {ID: 1, class_label: 0, color: 0, shape: 0, name: 0}

Here it is possible to define which discrete attributes appear in the (optional) text label of a marker. In this example, the text label of detections contains the color and class label of a detection (if the show_text boolean defined above is switched on for detections). The text label of a world model object contains the ID, class label and shape. Any discrete attribute can be added, attributes that are not available, will simply be ignored.

  23 # Frame in which all markers are shown
  24 marker_frame: /map

Finally, the frame in which the markers must be published is defined.


2020-02-22 13:24