[Rock-dev] Fwd: Howto get access to properties?

Leif Christensen leif.christensen at dfki.de
Tue Sep 24 12:15:22 CEST 2013


Am 09.09.2013 14:23, schrieb Alexander Duda:
>> The new async api should be used for gui's
>> however how could be an Async Property be readed or written?
>> http://www.rock-robotics.org/master/documentation/graphical_user_interface/300_displaying_logfiles.html
>> does not explain it
>> example
>>
>> t = some_async_task
>> p = t.property("a")
>>
>> failes:
>> p = 5
> Async objects have the same interface like the corresponding sync ones
> but the possibility to give a callback if the the method shall
> asynchronously be called.
> 
> sync call:
> p.write(val)
> 
> async call:
> p.write(val) do |result,error|
>     if error
>         raise
>     end
> end

Same problem here:
Just replacing

imu_xsens = TaskContext.get 'imu_xsens' with
imu_xsens = Orocos::Async.proxy("imu_xsens")

is not working when trying to set a property in the same way as before:

imu_xsens.port = "/dev/ttyUSB0"

Orocos[WARN]: killing running task contexts and deployments because of
unhandled exception
Orocos[WARN]:
/home/leifole/dev/rock/smallrock/tools/orocos.rb/lib/orocos/async/task_context_proxy.rb:809:in
`method_missing': undefined method `port=' for
#<Orocos::Async::TaskContextProxy:0x000000039e7200>

Do I have to add something else in the script, e.g. when starting the
task,etc.?

  1 require 'orocos'
  2 require 'vizkit'
  3 include Orocos
  4
  5 Orocos.initialize
  6
  7 device_name = "/dev/ttyUSB0"
  8
  9 Orocos.run 'imu_xsens::Task' => 'imu_xsens' do
 10 #  imu_xsens = TaskContext.get 'imu_xsens'
 11   imu_xsens = Orocos::Async.proxy("imu_xsens")
 12   imu_xsens.port = device_name
 13   plot = Vizkit.default_loader.Plot2d
 14
 15 #Orocos.log_all
 16
 17   imu_xsens.configure
 18   imu_xsens.start
 19
 20   imu_xsens.calibrated_sensors.connect_to do |blub|
 21     plot.update blub.mag[0],"Mag X"
 22     plot.update blub.mag[1],"Mag Y"
 23     plot.update blub.mag[2],"Mag Z"
 24   end
 25
 26   plot.show
 27   Vizkit.exec
 28 end

LG,
Leif
-- 
 Leif Christensen

 DFKI Bremen
 Robotics Innovation Center
 Robert-Hooke-Straße 5
 28359 Bremen, Germany

 Phone: +49 (0)421 17845-4149
 Fax:   +49 (0)421 17845-4150
 E-Mail: leif.christensen 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