[Rock-dev] Port plotting in orogen
Alexander Duda
Alexander.Duda at dfki.de
Wed Jun 8 15:44:22 CEST 2011
On Wed, 2011-06-08 at 15:37 +0200, Sylvain Joyeux wrote:
> On 06/08/2011 03:19 PM, Ruun wrote:
> > Hi everyone,
> >
> > i need to analyse some port data provided by an orogen module over the
> > time.
> >
> > Does the rock toolchain provides a component, that can be connected to
> > a port and starts a gui e.g. via vizkit in order to collect the data and
> > visualize
> > them in a plotting widget? (So i can see the current curves for the current
> > collected samples).
> >
> > That would be a great help.
> The standard way to do this in rock is to NOT use a component, but
> simply a ruby script that uses vizkit. It works pretty well.
>
> vizkit already has a plotting widget that can be used to that effect
> (I'm sorry, I don't know the details of its usage ;-))
I am currently working on a documentation which will be placed on
rock-robotics.org the next week.
Here is a small ruby example how it is used:
require 'vizkit'
include Orocos
class Plot
def initialize(task)
@task = task
# create a new qt plot widget
@widget = Vizkit.default_loader.PlotWidget
# connect method display with the output port
@task.my_port.connect_to(self.method(:display),:type
=> :buffer, :size => 100)
@pen = Qt::Pen.new
@pen.setColor(Qt::Color.new(255,0,0))
end
#updates the plot
def display(sample,_)
@widget.clearAll()
@widget.registerCurve(2, at pen,"pos",1)
values = sample.rays.to_a
array_x = 0.upto(values.size()-1).to_a.map{|v|v.to_f}
@widget.addPoints(array_x,values,1) # plot column
values= [0.0,values.max]
array_x = [sample.max_ray_pos.to_f,sample.max_ray_pos.to_f]
@widget.addPoints(array_x,values,2)
end
def show
@widget.show
end
end
Orocos.initialize
Orocos.run 'deployment' do
task = Orocos::TaskContext.get 'my_task'
plot = Plot.new(task)
plot.show
task.start
# start qt event loop
Vizkit.exec
end
--
Dipl.-Ing. Alexander Duda
Unterwasserrobotik
DFKI Bremen
Robotics Innovation Center
Robert-Hooke-Straße 5
28359 Bremen, Germany
Phone: +49 (0)421 178-456620
Fax: +49 (0)421 178-454150
E-Mail: alexander.duda at dfki.de
Weitere Informationen: http://www.dfki.de/robotik
-----------------------------------------------------------------------
Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
(Vorsitzender) Dr. Walter Olthoff
Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
Amtsgericht Kaiserslautern, HRB 2313
Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
USt-Id.Nr.: DE 148646973
Steuernummer: 19/673/0060/3
More information about the Rock-dev
mailing list