Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:chart_visualization [2014/06/05 11:38] – external edit 127.0.0.1doc:chart_visualization [2015/11/25 08:50] (current) – [Visualization in the rowser] admin
Line 1: Line 1:
 ====== Chart visualization ====== ====== Chart visualization ======
 +~~NOTOC~~
 +\\
 +^ This page describes the 'catkinized' version of KnowRob that uses the [[http://wiki.ros.org/catkin/|catkin buildsystem]] and the pure Java-based [[http://wiki.ros.org/rosjava|rosjava]]. The older version, which was based on the rosbuild buildsystem and rosjava_jni, used a [[http://wiki.ros.org/mod_vis|local visualization canvas implemented in Java]].^
 +\\
  
-The Chart visualization client listens to a given ROS topic for data_vis_msgs and displays them as a chart. Currently, donut charts and bar charts are supported.+The chart visualization client listens to a given ROS topic for data_vis_msgs and displays them as a chart. Currently, donut charts and bar charts are supported.
  
  
 ===== Creating charts from KnowRob ===== ===== Creating charts from KnowRob =====
-The following predicates start the diagram canvas publisher and create a new diagram with the given values. The add_diagram predicate is the most generic that gives full control over all parametersthe add_piechart and add_barchart predicates have fewer parameters and use default values for e.g. the size of the diagrams.+ 
 +The following predicates start the  publisher that sends updates to the diagram canvas and create a new diagram with the given values. The //add_diagram// predicate is the most generic one that gives full control over all parameters. In contrast, the //add_piechart// and //add_barchart// predicates have fewer parameters and use default values for e.g. the size of the diagrams.
  
   $ rosrun rosprolog rosprolog knowrob_vis   $ rosrun rosprolog rosprolog knowrob_vis
Line 25: Line 30:
 These three queries will create the following charts: These three queries will create the following charts:
 {{ :doc:diagram-examples.png?nolink |}} {{ :doc:diagram-examples.png?nolink |}}
 +
  
 ===== Behind the scenes: Communication via ROS topics ===== ===== Behind the scenes: Communication via ROS topics =====
  
-The predicates mentioned above publish messages in the following format on the topic 'data_vis_msgs'. This topic is forwarded by rosbridge, and the roslibjs listener included in the web page receives and visualizes the messages.+The predicates mentioned above publish messages in the following format on the topic //data_vis_msgs//. This topic is forwarded via a websocket by the //rosbridge// server, and a //roslibjs// listener included in the web page receives and visualizes the messages.
  
 +<code yaml>
   id: id   id: id
   type: 0   type: 0
Line 45: Line 52:
       value1: ['a', 'b']       value1: ['a', 'b']
       value2: ['1', '2']       value2: ['1', '2']
 +</code>
  
-Type 0 means donut chart, type 1 bar chart. To update data in an already existing diagram simply publish the message again with the same id and new data in value1 and value2. The chart will update immediately. To remove a chart, publish a message with its id and an empty array for value2. By now, only the first element of the 'values'-array is used (it'an array to support other kinds of diagrams, for example multiple timelines).+Type 0 means donut chart, type 1 is a bar chart. To update data in an already existing diagramsimply publish the message again with the same id and new data in value1 and value2. The chart will update immediately. To remove a chart, publish a message with its id and an empty array for value2. By now, only the first element of the 'values'-array is used (it has been made an array to support other kinds of diagrams in the future, for example multiple timelines).
  
 For testing purposes, messages can be published to the topic using the rostopic tool For testing purposes, messages can be published to the topic using the rostopic tool
Line 66: Line 74:
   '   '
  
-===== Visualization in the Browser =====+===== Visualization in the browser =====
  
-=== Example === 
 This simple web site subscribes to the topic 'data_vis_msgs' and adds diagrams to the div 'chart'. This simple web site subscribes to the topic 'data_vis_msgs' and adds diagrams to the div 'chart'.
 <code html> <code html>
Line 112: Line 119:
 </body> </body>
 </code> </code>
 +
 Make sure DonutChart.js, BarChart.js and DataVisClient.js are located in the same directory as the html file and you run Make sure DonutChart.js, BarChart.js and DataVisClient.js are located in the same directory as the html file and you run
   $ roslaunch knowrob_vis knowrob_vis.launch   $ roslaunch knowrob_vis knowrob_vis.launch