Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
doc:chart_visualization [2014/02/25 15:10] – updated to fit changed ros message stefes | doc:chart_visualization [2014/12/07 07:17] – [Chart visualization] 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, | + | |
+ | % Long version: | ||
+ | | ||
+ | ' | ||
+ | | ||
+ | | ||
+ | | ||
+ | 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: [' | + | |
- | An example of the receiving side can be found [[http:// | + | Type 0 means donut chart, type 1 is a bar chart. To update data in an already existing diagram, simply publish |
- | ===== Visualization in the Browser | + | For testing purposes, messages can be published to the topic using the rostopic tool |
+ | $ rostopic pub / | ||
+ | { | ||
+ | id: " | ||
+ | type: 0, | ||
+ | title: "some title", | ||
+ | xlabel: " | ||
+ | ylabel: " | ||
+ | width: 300, | ||
+ | height: 300, | ||
+ | fontsize: ' | ||
+ | values: [{ | ||
+ | value1: [" | ||
+ | value2: [" | ||
+ | }] | ||
+ | } | ||
+ | ' | ||
+ | |||
+ | ===== Visualization in the rowser | ||
- | === Example === | ||
This simple web site subscribes to the topic ' | This simple web site subscribes to the topic ' | ||
<code html> | <code html> | ||
Line 78: | Line 119: | ||
</ | </ | ||
</ | </ | ||
+ | |||
Make sure DonutChart.js, | Make sure DonutChart.js, | ||
$ roslaunch knowrob_vis knowrob_vis.launch | $ roslaunch knowrob_vis knowrob_vis.launch | ||
- | on your localhost. | + | on your localhost. |
- | $ rostopic pub / | + | |
- | { | + | |
- | id: " | + | |
- | type: 0, | + | |
- | title: "some title", | + | |
- | xlabel: " | + | |
- | ylabel: " | + | |
- | width: 300, | + | |
- | height: 300, | + | |
- | fontsize: ' | + | |
- | values: | + | |
- | value1: | + | |
- | value2: [" | + | |
- | }] | + | |
- | } | + | |
- | ' | + | |
- | for testing purpose | + | |
- | 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 ' | + | |