Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
doc:chart_visualization [2014/02/25 16:09] – restructured stefes | 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. |
- | ===== Publishing messages | + | ===== Creating charts |
+ | |||
+ | The following predicates start the publisher that sends updates to the diagram canvas and create a new diagram with the given values. The // | ||
$ rosrun rosprolog rosprolog knowrob_vis | $ rosrun rosprolog rosprolog knowrob_vis | ||
?- diagram_canvas. | ?- diagram_canvas. | ||
- | ?- add_diagram(id, title, piechart, | + | |
+ | % Long version: | ||
+ | | ||
+ | ' | ||
+ | piechart, | ||
+ | | ||
+ | | ||
+ | 300, 300, ' | ||
+ | | ||
+ | |||
+ | % Shorter versions: default parameters for piecharts and barcharts | ||
+ | ?- add_piechart(piechart_id, | ||
+ | ?- add_barchart(barchart_id, | ||
+ | |||
+ | These three queries will create the following charts: | ||
+ | {{ : | ||
+ | |||
+ | |||
+ | ===== Behind the scenes: Communication via ROS topics ===== | ||
+ | |||
+ | The predicates mentioned above publish messages in the following format on the topic // | ||
- | This publishes the following message on the topic ' | + | <code yaml> |
id: id | id: id | ||
type: 0 | type: 0 | ||
Line 26: | 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.\\ | + | 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. By now, only the first element of the ' |
- | To remove a chart, publish a message with its id and an empty array for value2. | + | |
- | By now, only the first element of the ' | ||
- | |||
- | ===== 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 54: | 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 100: | Line 119: | ||
</ | </ | ||
</ | </ | ||
+ | |||
Make sure DonutChart.js, | Make sure DonutChart.js, | ||
$ roslaunch knowrob_vis knowrob_vis.launch | $ roslaunch knowrob_vis knowrob_vis.launch |