Method inside a script function

Hello,

I am using Orocos RTT 1.6 under linux.

I have a script function calling a method :

export function fctTest
{
do mthTest("xx")
}

When I load this script, I get a command (called fctTest) in my component interface.

I would like that this command fails if the method mthTest (called inside the command) fails.
In particular, if I call it from a program : "do fctTest();" I would like the program to stop in error if the method mthTest fails.

Is it possible ? How ?

Thank you
Renaud Heitz

Method inside a script function

On Jul 29, 2009, at 08:05 , renaud [dot] heitz [..] ... wrote:

> Hello,
>
> I am using Orocos RTT 1.6 under linux.
>
> I have a script function calling a method :
> 
> export function fctTest
> {
>    do mthTest("xx")
> }
>
>
> When I load this script, I get a command (called fctTest) in my
> component interface.
>
> I would like that this command fails if the method mthTest (called
> inside the command) fails.
> In particular, if I call it from a program : "do fctTest();" I would
> like the program to stop in error if the method mthTest fails.

This isn't the default behaviour? Section 3.2.7 in

http://www.orocos.org/stable/documentation/rtt/v1.8.x/doc-xml/orocos-com...

If mthTest() fails and returns false, the program should stop in error.
Stephen

Re: Method inside a script function

snrkiwi wrote:

On Jul 29, 2009, at 08:05 , renaud [dot] heitz [..] ... wrote:

> This isn't the default behaviour? Section 3.2.7 in
> http://www.orocos.org/stable/documentation/rtt/v1.8.x/doc-xml/orocos-components-manual.html#program-syntax
> If mthTest() fails and returns false, the program should stop in error.

Indeed. My post was not clear enough : according to the documentation, I expect the function to fail if mthTest fails.
HOWEVER my observation is : a program fails if it calls a method that fails.
BUT a function (my function fctTest) does not fail if it calls a method that fails (my method mthTest).

I found in the documentation (section 3.2.10) :
"A function can be exported, in which case it becomes a public available command, which will fail if one of its statements fails".

If a method is considered as a "statement" there is a bug ...

Renaud

Method inside a script function

On Wed, Jul 29, 2009 at 15:51, <renaud [dot] heitz [..] ...> wrote:
>

snrkiwi wrote:
On Jul 29, 2009, at 08:05 , renaud [dot] heitz [..] ... wrote:
>
>> This isn't the default behaviour? Section 3.2.7 in
>> http://www.orocos.org/stable/documentation/rtt/v1.8.x/doc-xml/orocos-com...
>> If mthTest() fails and returns false, the program should stop in error.
>
>

>
> Indeed. My post was not clear enough : according to the documentation, I expect the function to fail if mthTest fails.
> HOWEVER my observation is : a program fails if it calls a method that fails.
> BUT a function (my function fctTest) does not fail if it calls a method that fails (my method mthTest).
>
> I found in the documentation (section 3.2.10) :
> "A function can be exported, in which case it becomes a public available command, which will fail if one of its statements fails".
>
> If a method is considered as a "statement" there is a bug ...

It is. I'll try to write up a unit test that confirms this.

Peter

Method inside a script function

On Mon, Aug 10, 2009 at 11:49, Peter Soetens<peter [..] ...> wrote:
> On Wed, Jul 29, 2009 at 15:51, <renaud [dot] heitz [..] ...> wrote:
>>

snrkiwi wrote:
On Jul 29, 2009, at 08:05 , renaud [dot] heitz [..] ... wrote:
>>
>>> This isn't the default behaviour? Section 3.2.7 in
>>> http://www.orocos.org/stable/documentation/rtt/v1.8.x/doc-xml/orocos-com...
>>> If mthTest() fails and returns false, the program should stop in error.
>>
>>

>>
>> Indeed. My post was not clear enough : according to the documentation, I expect the function to fail if mthTest fails.
>> HOWEVER my observation is : a program fails if it calls a method that fails.
>> BUT a function (my function fctTest) does not fail if it calls a method that fails (my method mthTest).
>>
>> I found in the documentation (section 3.2.10) :
>> "A function can be exported, in which case it becomes a public available command, which will fail if one of its statements fails".
>>
>> If a method is considered as a "statement" there is a bug ...
>
> It is. I'll try to write up a unit test that confirms this.

There is a unit test in tests/function_test.cpp: testFunctionFail that
checks your case (line 279).

Or the unit test is broken, or there is a difference between your case
and the unit test.

Peter

Method inside a script function

On Mon, Aug 10, 2009 at 16:31, Peter Soetens<peter [..] ...> wrote:
> On Mon, Aug 10, 2009 at 11:49, Peter Soetens<peter [..] ...> wrote:
>> On Wed, Jul 29, 2009 at 15:51, <renaud [dot] heitz [..] ...> wrote:
>>>

snrkiwi wrote:
On Jul 29, 2009, at 08:05 , renaud [dot] heitz [..] ... wrote:
>>>
>>>> This isn't the default behaviour? Section 3.2.7 in
>>>> http://www.orocos.org/stable/documentation/rtt/v1.8.x/doc-xml/orocos-com...
>>>> If mthTest() fails and returns false, the program should stop in error.
>>>
>>>

>>>
>>> Indeed. My post was not clear enough : according to the documentation, I expect the function to fail if mthTest fails.
>>> HOWEVER my observation is : a program fails if it calls a method that fails.
>>> BUT a function (my function fctTest) does not fail if it calls a method that fails (my method mthTest).
>>>
>>> I found in the documentation (section 3.2.10) :
>>> "A function can be exported, in which case it becomes a public available command, which will fail if one of its statements fails".
>>>
>>> If a method is considered as a "statement" there is a bug ...
>>
>> It is. I'll try to write up a unit test that confirms this.
>
> There is a unit test in tests/function_test.cpp: testFunctionFail that
> checks your case (line 279).
>
> Or the unit test is broken, or there is a difference between your case
> and the unit test.

The unit test was broken. The gtask.stop() was issued to early,
resetting the error states. I tracked the error to the
ProgramProcessor unloading the function when it's in the error state.
This causes the reset of the state of that function. The caller then
never sees the error state of the function. Which causes the error
never being propagated to the calling site.

This will be fixed by tomorrow...

Peter

Method inside a script function

On Mon, Aug 10, 2009 at 16:55, Peter Soetens<peter [..] ...> wrote:
> On Mon, Aug 10, 2009 at 16:31, Peter Soetens<peter [..] ...> wrote:
>> On Mon, Aug 10, 2009 at 11:49, Peter Soetens<peter [..] ...> wrote:
>>> On Wed, Jul 29, 2009 at 15:51, <renaud [dot] heitz [..] ...> wrote:
>>>>

snrkiwi wrote:
On Jul 29, 2009, at 08:05 , renaud [dot] heitz [..] ... wrote:
>>>>
>>>>> This isn't the default behaviour? Section 3.2.7 in
>>>>> http://www.orocos.org/stable/documentation/rtt/v1.8.x/doc-xml/orocos-com...
>>>>> If mthTest() fails and returns false, the program should stop in error.
>>>>
>>>>

>>>>
>>>> Indeed. My post was not clear enough : according to the documentation, I expect the function to fail if mthTest fails.
>>>> HOWEVER my observation is : a program fails if it calls a method that fails.
>>>> BUT a function (my function fctTest) does not fail if it calls a method that fails (my method mthTest).
>>>>
>>>> I found in the documentation (section 3.2.10) :
>>>> "A function can be exported, in which case it becomes a public available command, which will fail if one of its statements fails".
>>>>
>>>> If a method is considered as a "statement" there is a bug ...
>>>
>>> It is. I'll try to write up a unit test that confirms this.
>>
>> There is a unit test in tests/function_test.cpp: testFunctionFail that
>> checks your case (line 279).
>>
>> Or the unit test is broken, or there is a difference between your case
>> and the unit test.
>
> The unit test was broken. The gtask.stop() was issued to early,
> resetting the error states. I tracked the error to the
> ProgramProcessor unloading the function when it's in the error state.
> This causes the reset of the state of that function. The caller then
> never sees the error state of the function. Which causes the error
> never being propagated to the calling site.
>
> This will be fixed by tomorrow...

Could you try the patch in attachment ? It fixes the unit test + the
function code here. It does not include my earlier fix you need for
the NonPeriodicActivity, which I assume you still have in place.

>
> Peter
>

Re: Method inside a script function

> Could you try the patch in attachment ? It fixes the unit test + the
> function code here. It does not include my earlier fix you need for
> the NonPeriodicActivity, which I assume you still have in place.

I have just tested the patch. Thank you very much it works fine.

Renaud