Using classical deployer with lua deployment file

Hi,

At the very end of the LuaCookbook it is described how to use the classical
deployer with lua deployment file. I would like to be able to switch easily
so now I have the following run.sh file:

if [[ $1 == "-l" ]]; then
## Using the rrtlua-deployer
rosrun ocl rttlua-gnulinux -i deployment_general.lua
elif [[ $1 == "-t" ]]; then
## Using the standard orocos deployer
rosrun ocl deployer-gnulinux -s start.ops
else
cat <<EOF
run.sh: launch the minimal rFSM - RTT example.
Options:
-t run standard rtt taskbrowser
-l run lua taskbrowser
-h print this
EOF
fi

With the following start.ops file:
##load the lua service
loadService ("Deployer","Lua")

##execute your deployment file
Lua.exec_file("deployment_general.lua")

The first thing to do in the deployment file is to get a reference to the
deployer. Since the difference between 'deployer' (lua) and 'Deployer'
(classical tc), I have the following there:

tc=rtt.getTC()
if tc:getName() == "lua" then
print("Using the lua deployer")
depl=tc:getPeer("deployer")
else
print("Using the standard deployer")
depl=tc
end

This works fine. Further on, I create a Supervisor Component (lua) and also
there I need to get a reference to the deployer. I thought of the following
(in the configureHook of the Supervisor):
tc = rtt.getTC()
if tc:hasPeer("deployer") then depl=tc:getPeer("deployer") end
if tc:hasPeer("Deployer") then depl=tc:getPeer("Deployer") end

However, hasPeer does not seem to work:
1.159 [ ERROR
][/home/bwillaert/rosstacks/orocos_toolchain/ocl/bin/rttlua-gnulinux::main()]
LuaComponent 'Supervisor': error calling function configureHook:
...s_v2/lwr_general/coordination/supervisor_general.lua:34: attempt to call
method 'hasPeer' (a nil value)

Any idea why or suggestions to do things differently?

Thanks a lot,

Bert

Using classical deployer with lua deployment file

Hi Bert,

this is the way in which I managed the problem:

------------------------------------------------------------------------
//Script deploy
------------------------------------------------------------------------

import("ocl")

//load the lua service
loadService ("Deployer","Lua")

//execute your deployment file
Lua.exec_file("your_lua_deploy.lua")

------------------------------------------------------------------------
//Lua deploy
------------------------------------------------------------------------

tc=rtt.getTC()
tcName=tc:getName()

if tcName=="lua" then
depl=tc:getPeer("deployer")
elseif tcName=="Deployer" then
depl = tc
end

...

depl:loadComponent("Supervisor", "OCL::LuaComponent")

if tcName == "lua" then
depl:aliasPeer("Supervisor", "deployer", "Deployer")
elseif tcName == "Deployer" then
depl:addPeer("Supervisor", "Deployer")
end

------------------------------------------------------------------------
//Lua platform (and others lua files)
------------------------------------------------------------------------

tc=rtt.getTC();
depl=tc:getPeer("Deployer")

Using "aliasPeer" instead of "addPeer" you can add to the Supervisor
component the peer "Deployer" (written with a capital D) in both cases:
this allows you to refer to the deployer as "Deployer" in every other lua
files, included the lua platform file. I hope this can be useful.

Best regards,
Nicola

2012/12/12 Bert Willaert <bert [dot] willaert [..] ...>

> Hi,
>
> At the very end of the LuaCookbook it is described how to use the
> classical deployer with lua deployment file. I would like to be able to
> switch easily so now I have the following run.sh file:
>
> if [[ $1 == "-l" ]]; then
> ## Using the rrtlua-deployer
> rosrun ocl rttlua-gnulinux -i deployment_general.lua
> elif [[ $1 == "-t" ]]; then
> ## Using the standard orocos deployer
> rosrun ocl deployer-gnulinux -s start.ops
> else
> cat <<EOF
> run.sh: launch the minimal rFSM - RTT example.
> Options:
> -t run standard rtt taskbrowser
> -l run lua taskbrowser
> -h print this
> EOF
> fi
>
> With the following start.ops file:
> ##load the lua service
> loadService ("Deployer","Lua")
>
> ##execute your deployment file
> Lua.exec_file("deployment_general.lua")
>
> The first thing to do in the deployment file is to get a reference to the
> deployer. Since the difference between 'deployer' (lua) and 'Deployer'
> (classical tc), I have the following there:
>
> tc=rtt.getTC()
> if tc:getName() == "lua" then
> print("Using the lua deployer")
> depl=tc:getPeer("deployer")
> else
> print("Using the standard deployer")
> depl=tc
> end
>
> This works fine. Further on, I create a Supervisor Component (lua) and
> also there I need to get a reference to the deployer. I thought of the
> following (in the configureHook of the Supervisor):
> tc = rtt.getTC()
> if tc:hasPeer("deployer") then depl=tc:getPeer("deployer") end
> if tc:hasPeer("Deployer") then depl=tc:getPeer("Deployer") end
>
> However, hasPeer does not seem to work:
> 1.159 [ ERROR
> ][/home/bwillaert/rosstacks/orocos_toolchain/ocl/bin/rttlua-gnulinux::main()]
> LuaComponent 'Supervisor': error calling function configureHook:
> ...s_v2/lwr_general/coordination/supervisor_general.lua:34: attempt to call
> method 'hasPeer' (a nil value)
>
> Any idea why or suggestions to do things differently?
>
> Thanks a lot,
>
> Bert
>
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>
>

Using classical deployer with lua deployment file

Thanks Nicola! That does the job.

On Wed, Dec 12, 2012 at 12:28 PM, Nicola Preda <nicola [dot] preda [..] ...>wrote:

> Hi Bert,
>
> this is the way in which I managed the problem:
>
> ------------------------------------------------------------------------
> //Script deploy
> ------------------------------------------------------------------------
>
> import("ocl")
>
> //load the lua service
> loadService ("Deployer","Lua")
>
> //execute your deployment file
> Lua.exec_file("your_lua_deploy.lua")
>
> ------------------------------------------------------------------------
> //Lua deploy
> ------------------------------------------------------------------------
>
> tc=rtt.getTC()
> tcName=tc:getName()
>
> if tcName=="lua" then
> depl=tc:getPeer("deployer")
> elseif tcName=="Deployer" then
> depl = tc
> end
>
> ...
>
> depl:loadComponent("Supervisor", "OCL::LuaComponent")
>
> if tcName == "lua" then
> depl:aliasPeer("Supervisor", "deployer", "Deployer")
> elseif tcName == "Deployer" then
> depl:addPeer("Supervisor", "Deployer")
> end
>
> ------------------------------------------------------------------------
> //Lua platform (and others lua files)
> ------------------------------------------------------------------------
>
> tc=rtt.getTC();
> depl=tc:getPeer("Deployer")
>
> Using "aliasPeer" instead of "addPeer" you can add to the Supervisor
> component the peer "Deployer" (written with a capital D) in both cases:
> this allows you to refer to the deployer as "Deployer" in every other lua
> files, included the lua platform file. I hope this can be useful.
>
> Best regards,
> Nicola
>
>
>
> 2012/12/12 Bert Willaert <bert [dot] willaert [..] ...>
>
>> Hi,
>>
>> At the very end of the LuaCookbook it is described how to use the
>> classical deployer with lua deployment file. I would like to be able to
>> switch easily so now I have the following run.sh file:
>>
>> if [[ $1 == "-l" ]]; then
>> ## Using the rrtlua-deployer
>> rosrun ocl rttlua-gnulinux -i deployment_general.lua
>> elif [[ $1 == "-t" ]]; then
>> ## Using the standard orocos deployer
>> rosrun ocl deployer-gnulinux -s start.ops
>> else
>> cat <<EOF
>> run.sh: launch the minimal rFSM - RTT example.
>> Options:
>> -t run standard rtt taskbrowser
>> -l run lua taskbrowser
>> -h print this
>> EOF
>> fi
>>
>> With the following start.ops file:
>> ##load the lua service
>> loadService ("Deployer","Lua")
>>
>> ##execute your deployment file
>> Lua.exec_file("deployment_general.lua")
>>
>> The first thing to do in the deployment file is to get a reference to the
>> deployer. Since the difference between 'deployer' (lua) and 'Deployer'
>> (classical tc), I have the following there:
>>
>> tc=rtt.getTC()
>> if tc:getName() == "lua" then
>> print("Using the lua deployer")
>> depl=tc:getPeer("deployer")
>> else
>> print("Using the standard deployer")
>> depl=tc
>> end
>>
>> This works fine. Further on, I create a Supervisor Component (lua) and
>> also there I need to get a reference to the deployer. I thought of the
>> following (in the configureHook of the Supervisor):
>> tc = rtt.getTC()
>> if tc:hasPeer("deployer") then depl=tc:getPeer("deployer") end
>> if tc:hasPeer("Deployer") then depl=tc:getPeer("Deployer") end
>>
>> However, hasPeer does not seem to work:
>> 1.159 [ ERROR
>> ][/home/bwillaert/rosstacks/orocos_toolchain/ocl/bin/rttlua-gnulinux::main()]
>> LuaComponent 'Supervisor': error calling function configureHook:
>> ...s_v2/lwr_general/coordination/supervisor_general.lua:34: attempt to call
>> method 'hasPeer' (a nil value)
>>
>> Any idea why or suggestions to do things differently?
>>
>> Thanks a lot,
>>
>> Bert
>>
>> --
>> Orocos-Users mailing list
>> Orocos-Users [..] ...
>> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>>
>>
>