Hi,
I'm trying in the taskbrowser and in rtt_lua to create a variable from a msg like type, eg. motion_control_msgs.JointPositions, which contains two structs which are arrays.
The typekit was generated using rtt_rosnode create_rtt_msgs functionallity.
var motion_control_msgs.JointPositions a
= {names = { [ ], size = 0, capacity = 0 }, positions = { [ ], size = 0, capacity = 0 } }
(btw, it seems to me that you can create a variable of this type with different sizes of 'names' and 'positions')
Since there is no resize option for array like types, the only way to get an array of a certain type is to initialize it with the correct type, but in this case, it is not
possible in the task browser...
Is it possible to create this 'resize' method with array like types?
Then the lua case: I tried to create it with
t=rtt.Variable("motion_control_msgs.JointPositions")
t:fromtab({names={"a","b"}, positions={0.0,0.0}})
but this doesn't work either.
How should I do this?
In the end, I ended up creating a dummy c++ component, with a property of the desired type, filled in some values there, created a property file from that and loaded that
into my rtt_lua code...
Nick
array like types and typekits in the taskbrowser and rtt_lua
On Thu, Aug 30, 2012 at 11:16:09AM +0200, Dominick Vanthienen wrote:
> Hi,
>
> I'm trying in the taskbrowser and in rtt_lua to create a variable from a msg like type, eg. motion_control_msgs.JointPositions, which contains two structs which are arrays.
> The typekit was generated using rtt_rosnode create_rtt_msgs functionallity.
>
> var motion_control_msgs.JointPositions a
> = {names = { [ ], size = 0, capacity = 0 }, positions = { [ ], size = 0, capacity = 0 } }
> (btw, it seems to me that you can create a variable of this type with different sizes of 'names' and 'positions')
>
> Since there is no resize option for array like types, the only way to get an array of a certain type is to initialize it with the correct type, but in this case, it is not
> possible in the task browser...
> Is it possible to create this 'resize' method with array like types?
>
> Then the lua case: I tried to create it with
> t=rtt.Variable("motion_control_msgs.JointPositions")
> t:fromtab({names={"a","b"}, positions={0.0,0.0}})
The current "fromtab' does not automatically resize, so you need to
take care of it. Something like below should work:
t.names:resize(2)
t.positions:resize(2)
t:fromtab({names={"a","b"}, positions={0.0,0.0}})
There is however a patch in my ocl-mk for the next release that does
that automatically:
commit 010aae590cf77da7190e9207bab4d4d1d0a40d62
Author: Markus Klotzbuecher <markus [dot] klotzbuecher [..] ...>
Date: Tue May 8 16:13:34 2012 +0200
lua: let [var]fromtab automagically resize vector types
> but this doesn't work either.
> How should I do this?
>
> In the end, I ended up creating a dummy c++ component, with a
> property of the desired type, filled in some values there, created a
> property file from that and loaded that into my rtt_lua code...
Markus