Lua deployment scripts & PropertyBags

Dear Developers

I'm trying to use Lua scripts fro the deployment. However it is not clear for me from Lua Cookbook , how can I access and set Properties of the component (especially using PropertyBags)?

Best regards,

Yury

Lua deployment scripts & PropertyBags

Hey Yury,

2011/9/25 Yury Brodskiy <y [dot] brodskiy [..] ...>:
> Dear Developers
>
>
> I'm trying to use Lua scripts fro the deployment. However it is not clear for me from  Lua Cookbook , how can I access and set Properties  of the component (especially using PropertyBags)?

This is how I currently use it in a FSM.
In my LUA statemachine, I get a reference to the Orocos TaskContext, using

Supervisor = rtt.getTC()

Then, properties are accessed using

Supervisor:getPeer("ComponentName"):getProperty("PropertyName"):set(NewPropertyValue)

Regards,

Steven

>
> Best regards,
>
>  Yury
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

Lua deployment scripts & PropertyBags

Hi Yury,

On Sun, Sep 25, 2011 at 05:18:52PM +0200, Yury Brodskiy wrote:
>
> I'm trying to use Lua scripts fro the deployment. However it is not
> clear for me from Lua Cookbook , how can I access and set Properties
> of the component (especially using PropertyBags)?

You can get properties using
TaskContext:getProperty('prop-name'). This returns a property on which
you can then call the set(x) method. If (and only if) the property is
complex (e.g. not a number, string or boolean) then you can also index
it directly:

p.linear.X=1.2

I hope this helps. If it is not clear yet, it would be good if you
could give more details and/or the errors that you are getting...

Best regards
Markus

Lua deployment scripts & PropertyBags

Hi Markus

I have a component with a property bag with a single property inside, this property s a vector of double with one value:
I'm trying to access it as follows:

> Gain1=svf_test:getProperty("Gain1")
> =Gain1
Gain1 (PropertyBag) = [[K='(double[])'
]] // Submodel parameters
> =Gain1.K
nil
> =svf_test.Gain1
nil

It all works properly using the OROCOS scripts.
But apparently I'm doing something wrong with lua.
Best regards,
Yury

On 25, Sep 2011, at 19:11 , Markus Klotzbuecher wrote:

> Hi Yury,
>
> On Sun, Sep 25, 2011 at 05:18:52PM +0200, Yury Brodskiy wrote:
>>
>> I'm trying to use Lua scripts fro the deployment. However it is not
>> clear for me from Lua Cookbook , how can I access and set Properties
>> of the component (especially using PropertyBags)?
>
> You can get properties using
> TaskContext:getProperty('prop-name'). This returns a property on which
> you can then call the set(x) method. If (and only if) the property is
> complex (e.g. not a number, string or boolean) then you can also index
> it directly:
>
> p.linear.X=1.2
>
> I hope this helps. If it is not clear yet, it would be good if you
> could give more details and/or the errors that you are getting...
>
> Best regards
> Markus

Lua deployment scripts & PropertyBags

Hi Yuri,

On Sun, Sep 25, 2011 at 10:05:56PM +0200, Yury Brodskiy wrote:

> I have a component with a property bag with a single property
> inside, this property s a vector of double with one value: I'm
> trying to access it as follows:
>
> > Gain1=svf_test:getProperty("Gain1")
> > =Gain1
> Gain1 (PropertyBag) = [[K='(double[])']] // Submodel parameters
> > =Gain1.K
> nil
> > =svf_test.Gain1
> nil
>
> It all works properly using the OROCOS scripts.
> But apparently I'm doing something wrong with lua.

Hmm, this looks strange. How are you creating this property? Are you
creating the PropertyBag explicitely (if yes, why?) It appears the
PropertyBag becomes visible as an array of arrays. Can you try

=Gain1[0]
=Gain1[0][0]
=Gain1[0][0].K

What do the above print?

Best regards
Markus

Lua deployment scripts & PropertyBags

Hi Markus

The Property Bags created explicitly in a components written in C++. It is done is in this way to represent hierarchical structure of the computational model and to enable change the interface of the component using configuration file. Everything work very nicely with xml and orocos script deployment scheme, but I had in mind rFSM use case.

Here follows all the information about the PropertyBag, I can think of:
--Code:

> Gain1=svf_test:getProperty("Gain1")
> =Gain1
Gain1 (PropertyBag) = [[K='(double[])'
]] // Submodel parameters
> =Gain1[0]
nil
> =Gain1[0][0]
stdin:1: attempt to index field '?' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?
> =Gain1[0][0].K
stdin:1: attempt to index field '?' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?
> =Gain1["K"]
nil
> =Gain1[0]["K"]
stdin:1: attempt to index field '?' (a nil value)
stack traceback:
stdin:1: in main chunk
[C]: ?
> for k,v in pairs(getmetatable(Gain1)) do print(k,v) end
fromtab function: 0x9948c40
delete function: 0x99408b0
info function: 0x9940898
set function: 0x98fdf60
__tostring function: 0x996e6a8
__newindex function: 0x98fdfa8
__index function: 0x98fdf90
get function: 0x98fdef0
> =type(Gain1:get())
userdata
> =Gain1:get():toString()
[[K='(double[])'
]]
> =Gain1:get():getType()
PropertyBag
> for k,v in pairs(getmetatable(Gain1:get())) do print(k,v) end
assign function: 0x993f548
getMember function: 0x993f5c0
var2tab function: 0x996e4f0
fromtab function: 0x996e840
__tostring function: 0x996e7f8
__gc function: 0x98fdca8
__pow function: 0x98fdc18
__newindex function: 0x98fdc90
__le function: 0x98fdc60
__index function: 0x98fdc78
__lt function: 0x98fdc48
__mod function: 0x98fdc00
__unm function: 0x993f580
__eq function: 0x98fdc30
resize function: 0x993f4d8
__mul function: 0x98fdde0
getMemberNames function: 0x993f458
opBinary function: 0x993f510
toString function: 0x98fe548
__add function: 0x993f598
__div function: 0x98fddf8
tolua function: 0x98fbb70
getType function: 0x98feee0
getTypeName function: 0x993f420
getMemberRaw function: 0x99009e0
__sub function: 0x98fddc8
isbasic function: 0x98fe2e8

--Code
Best regards,
Yury

On 25, Sep 2011, at 22:54 , Markus Klotzbuecher wrote:

> Hi Yuri,
>
> On Sun, Sep 25, 2011 at 10:05:56PM +0200, Yury Brodskiy wrote:
>
>> I have a component with a property bag with a single property
>> inside, this property s a vector of double with one value: I'm
>> trying to access it as follows:
>>
>>> Gain1=svf_test:getProperty("Gain1")
>>> =Gain1
>> Gain1 (PropertyBag) = [[K='(double[])']] // Submodel parameters
>>> =Gain1.K
>> nil
>>> =svf_test.Gain1
>> nil
>>
>> It all works properly using the OROCOS scripts.
>> But apparently I'm doing something wrong with lua.
>
> Hmm, this looks strange. How are you creating this property? Are you
> creating the PropertyBag explicitely (if yes, why?) It appears the
> PropertyBag becomes visible as an array of arrays. Can you try
>
> =Gain1[0]
> =Gain1[0][0]
> =Gain1[0][0].K
>
> What do the above print?
>
> Best regards
> Markus

Lua deployment scripts & PropertyBags

Hi Yury,

On Mon, Sep 26, 2011 at 10:07:31AM +0200, Yury Brodskiy wrote:
> Hi Markus
>
> The Property Bags created explicitly in a components written in C++.
> It is done is in this way to represent hierarchical structure of the
> computational model and to enable change the interface of the
> component using configuration file. Everything work very nicely with
> xml and orocos script deployment scheme, but I had in mind rFSM use
> case.

It seems the property bag does not work out of the box.

Are you planning to make changes to these parameters at runtime? If
yes, I would strongly suggest to use a Port instead, that is
thread-safe and moreover can "raise" an event (when added as an event
port).

If this is only static configuration, then you can workaround by
loading the scripting service and running the ops script you already
have that sets up these properties.

Best regards
Markus