Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
doc:chart_visualization [2014/02/25 09:32] – created 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. | ||
- | ===== Publishing diagram messages ===== | ||
- | Preliminary documentation: | + | ===== Creating charts from KnowRob ===== |
+ | |||
+ | 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: | ||
+ | | ||
+ | ' | ||
+ | | ||
+ | 'Label for x-axis' | ||
+ | 'Label for y-axis', | ||
+ | 300, 300, ' | ||
+ | | ||
+ | |||
+ | % 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 15: | Line 42: | ||
xlabel: xlabel | xlabel: xlabel | ||
ylabel: ylabel | ylabel: ylabel | ||
+ | width: 210 | ||
+ | height: 210 | ||
+ | fontsize: 12px | ||
values: | values: | ||
- | - | ||
Line 22: | Line 52: | ||
value1: [' | value1: [' | ||
value2: [' | value2: [' | ||
- | | + | </ |
- | value1: ['a', 'b'] | + | |
- | value2: ['1', '2'] | + | 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 ' |
+ | |||
+ | For testing purposes, messages can be published to the topic using the rostopic tool | ||
+ | $ rostopic pub / | ||
+ | { | ||
+ | | ||
+ | type: 0, | ||
+ | title: "some title", | ||
+ | xlabel: " | ||
+ | ylabel: " | ||
+ | width: 300, | ||
+ | height: 300, | ||
+ | fontsize: ' | ||
+ | values: [{ | ||
+ | | ||
+ | value2: [" | ||
+ | }] | ||
+ | } | ||
+ | | ||
+ | |||
+ | ===== Visualization in the browser ===== | ||
+ | |||
+ | This simple web site subscribes to the topic 'data_vis_msgs' | ||
+ | <code html> | ||
+ | < | ||
+ | < | ||
+ | <meta charset=" | ||
+ | |||
+ | <script type=" | ||
+ | <script type=" | ||
+ | <script type=" | ||
+ | <script type=" | ||
+ | <script type=" | ||
+ | <script type=" | ||
+ | <script src=" | ||
+ | |||
+ | <script type=" | ||
+ | function init() { | ||
+ | |||
+ | var ros = new ROSLIB.Ros({ | ||
+ | url : ' | ||
+ | }); | ||
+ | |||
+ | var options = { | ||
+ | ros: ros, | ||
+ | containerId: | ||
+ | topic: ' | ||
+ | }; | ||
+ | var dataVisClient = new DataVisClient(options); | ||
+ | } | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | <body onload=" | ||
+ | |||
+ | <div id=" | ||
+ | < | ||
+ | <div id=" | ||
- | An example of the receiving side can be found [[http://www.knowrob.org/doc/marker_visualization/ | + | </div> |
+ | </div> | ||
+ | </body> | ||
+ | </code> | ||
+ | Make sure DonutChart.js, | ||
+ | $ roslaunch knowrob_vis knowrob_vis.launch | ||
+ | on your localhost. Now you can publish messages using [[http:// | ||