Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:chart_visualization [2014/04/17 10:28] – [Publishing messages from KnowRob] admin | doc: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 ' | ||
+ | \\ | ||
- | 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 | + | |
+ | 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 | ||
$ rosrun rosprolog rosprolog knowrob_vis | $ rosrun rosprolog rosprolog knowrob_vis | ||
Line 11: | Line 16: | ||
| | ||
% Long version: | % Long version: | ||
- | ?- add_diagram(diagram-id, | + | ?- add_diagram(diagram_id, |
' | ' | ||
| | ||
Line 17: | Line 22: | ||
'Label for y-axis', | 'Label for y-axis', | ||
300, 300, ' | 300, 300, ' | ||
- | [[[a,b],[' | + | [[[a,b,c,d],['21',' |
| | ||
% Shorter versions: default parameters for piecharts and barcharts | % Shorter versions: default parameters for piecharts and barcharts | ||
- | add_piechart(piechart-id, ' | + | |
- | add_barchart(barchart-id, ' | + | |
- | This publishes | + | These three queries will create |
+ | {{ : | ||
+ | |||
+ | |||
+ | ===== Behind the scenes: Communication via ROS topics ===== | ||
+ | |||
+ | The predicates mentioned above publish messages in the following format | ||
+ | |||
+ | <code yaml> | ||
id: id | id: id | ||
type: 0 | type: 0 | ||
Line 39: | Line 52: | ||
value1: [' | value1: [' | ||
value2: [' | value2: [' | ||
- | - | + | </ |
- | value1: [' | + | |
- | value2: [' | + | |
- | + | ||
- | 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 ' | + | Type 0 means donut chart, type 1 is a 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. |
- | ===== Publishing messages via rostopic ===== | ||
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 | ||
$ rostopic pub / | $ rostopic pub / | ||
Line 67: | Line 74: | ||
' | ' | ||
- | ===== Visualization in the Browser | + | ===== Visualization in the browser |
- | === Example === | ||
This simple web site subscribes to the topic ' | This simple web site subscribes to the topic ' | ||
<code html> | <code html> | ||
Line 113: | Line 119: | ||
</ | </ | ||
</ | </ | ||
+ | |||
Make sure DonutChart.js, | Make sure DonutChart.js, | ||
$ roslaunch knowrob_vis knowrob_vis.launch | $ roslaunch knowrob_vis knowrob_vis.launch |