[Rock-dev] orocos.rb accessing complex task properties

Sylvain Joyeux sylvain.joyeux at dfki.de
Thu Dec 16 10:38:46 CET 2010


On 12/16/2010 10:27 AM, Alexander Duda wrote:
> If you are trying to access a task property which is a struct or class
> orocos.rb is not very transparent.
>
> task.property.x = 123	# is not working
>
> #you have to do it this way
> prop = task.property
> prop.x = 123
> task.property = prop
>
> This is because task.property is creating a new object
> and .x= is modifying it but it is not written back to the task.
> As far as I know there is no nice solution for it because of corba.
This is not only because of CORBA. It is a very dangerous business to 
allow users to write properties "field by field" like this, as -- until 
they updated all the fields they want to write -- the data structure 
will not be consistent

> Therefore I would suggest to block calls like
> task.property if the property is a class or a struct
>
> task.property.x = 123
> should result in
> "Warning: Use task.read(x) to access complex properties"
Do you mean: use task.read('property') ?

> task.property2 = 123   #should still work
>
> Otherwise nearly all new user will run into it.
>
> Thoughts?
I don't like the solution, as complex properties should be the norm, not 
the exception (if you have properties that are common in purpose, they 
should be in the same data structure), and it will therefore make coding 
all of that VERY tedious.

Other than that, I agree that it is indeed an issue.

There are means to make "task.property.x = value" work. As stated, don't 
like that, but I can make amends for the sake of simplicity

Unfortunately, there are no ways to make a difference between
   task.property.x = value
and
   property = task.property
   property.x = value

-- 
Sylvain Joyeux (Dr. Ing.)
Researcher - Space and Security Robotics
DFKI Robotics Innovation Center
Bremen, Robert-Hooke-Straße 5, 28359 Bremen, Germany

Phone:   +49 421 218-64136
Fax:     +49 421 218-64150
Email:   sylvain.joyeux at dfki.de

Weitere Informationen: http://www.dfki.de


More information about the Rock-dev mailing list