How to hook a service operation into the trigger mechanism

Hi,

We are using the new Lua RTT plugin (obviously ;) ),

We load the Lua service into my component, but now we want to execute one of
the operations of the service everytime my component gets triggered.

So how can a service request the TC to execute one of its operations on
trigger()/update() without having to hard-code it in the C++ code of the TC?

Ruben and Markus

How to hook a service operation into the trigger mechanism

On Tuesday 12 October 2010 11:00:56 Ruben Smits wrote:
> Hi,
>
> We are using the new Lua RTT plugin (obviously ;) ),
>
> We load the Lua service into my component, but now we want to execute one
> of the operations of the service everytime my component gets triggered.
>
> So how can a service request the TC to execute one of its operations on
> trigger()/update() without having to hard-code it in the C++ code of the
> TC?

It's the job of the lua plugin to do that. It can register a
base::ExecutableInterface object using the ExecutionEngine::runFunction call,
when it is loaded as a service in a component. Each function in the EE is
executed during a trigger(). It can then do whatever is necessary in the
'execute' function of that object and call whatever operations it deems
necessary. As long as execute() returns true, the EE keeps calling it for each
trigger(). When execute() returns false, the object will be removed. You can
also remove it using the ExecutionEngine::removeFunction call. These are all
thread-safe calls.

References:
http://www.orocos.org/stable/documentation/rtt/v2.x/api/html/classRTT_1_...
and
http://www.orocos.org/stable/documentation/rtt/v2.x/api/html/classRTT_1_...

Peter

How to hook a service operation into the trigger mechanism

On Tue, Oct 12, 2010 at 02:08:05PM +0200, Peter Soetens wrote:
> On Tuesday 12 October 2010 11:00:56 Ruben Smits wrote:
> > Hi,
> >
> > We are using the new Lua RTT plugin (obviously ;) ),
> >
> > We load the Lua service into my component, but now we want to execute one
> > of the operations of the service everytime my component gets triggered.
> >
> > So how can a service request the TC to execute one of its operations on
> > trigger()/update() without having to hard-code it in the C++ code of the
> > TC?
>
> It's the job of the lua plugin to do that. It can register a
> base::ExecutableInterface object using the ExecutionEngine::runFunction call,
> when it is loaded as a service in a component. Each function in the EE is
> executed during a trigger(). It can then do whatever is necessary in the
> 'execute' function of that object and call whatever operations it deems
> necessary. As long as execute() returns true, the EE keeps calling it for each
> trigger(). When execute() returns false, the object will be removed. You can
> also remove it using the ExecutionEngine::removeFunction call. These are all
> thread-safe calls.
>
> References:
> http://www.orocos.org/stable/documentation/rtt/v2.x/api/html/classRTT_1_...
> and
> http://www.orocos.org/stable/documentation/rtt/v2.x/api/html/classRTT_1_...

Thanks, I'll try your suggestion!

Markus