Orocos-Dev Digest, Vol 76, Issue 33

>   4. Re: [Bug 864] New: OCL Timercomponent with multiple timers
>      fires sometimes with wrong timerIds (S Roderick)
> Date: Thu, 26 May 2011 07:50:48 -0400
> From: S Roderick
> Subject: Re: [Orocos-Dev] [Bug 864] New: OCL Timercomponent with
>        multiple timers fires sometimes with wrong timerIds
> Message-ID: <300981F3-B70B-4559-9E8A-D3ACB38C20EE [..] ...>
> Content-Type: text/plain; CHARSET=US-ASCII

[...]
>> I'm using the OCL::TimerComponent, connected to a Controller component, which
>> triggers (eventPort) a custom method (watchdog). I had no problem using the
>> Timer component with only one timer (Timercomponent gets configured and started
>> properly, and the actual timer is started with Timer.startTimer (id, period)).
>> When I start a second timer in the same component (with a different timerId of
>> course), that timer triggers my component _sometimes_ more then once in a
>> single period and at the same time, the other one didn't trigger at all?! See
>> for example the deployer output below, where timer 0 and timer 1 both run at
>> 0.5 seconds. Timer 0 does not trigger the method at e.g. 3.974seconds, while
>> timer 1 triggers it twice:
>
> <sni

>
> The TimerComponent has had this problem for a while (search the ML). We use it like this in state machines:

<http://bugs.orocos.org/show_bug.cgi?id=703>

I suppose you are using 2.x? According to
<http://bugs.orocos.org/show_bug.cgi?id=703#c12> I thought this might
have been solved in 2.x.

See also
<http://lists.mech.kuleuven.be/pipermail/orocos-users/2010-February/001779.html>

>

> ...
>                handle
>                {
>                        // wait for N seconds
>                        do Timer.wait(ID_WAIT, 2.0)
>                }
>                exit
>                {
>                        // in case still running
>                        try Timer.killTimer(ID_WAIT)
>                }
>                transition Timer.timeout(timerID)
>                        if timerID == ID_WAIT then select OTHER_STATE
>                transition nonTimerRelated() select ANOTHER_STATE
>        }
> 

>
> Where we explicitly wait for the timer ID of interest. Otherwise you run into your problem :-(

We do similar magic, and additionnaly increase timerID every time
(make sure you don't go in overrun though) we get in the same state,
st. like

state blabla
{
entry
{
try comp.start()
/* Workaround for orocos 1.x Statemachine bug:
increase Timer id.
* See
<ttp://www.orocos.org/forum/orocos/orocos-users/timer-timeouts>
*/
set timerID = timerID + 1
// Wait for Steady State (takes +- 4 secs)
set isTimerID_OK=Timer.arm(timerID, 4.0)
// do trigger()
}

transition if (isTimerID_OK == false) then
{
set fatalErrorMessage="Unable to create a
valid timerID in the excitationState"
} select fatalErrorState

transition Timer.timeout(tID) if tID == timerID then
select acquisitionState

Note: this is 1.x...

HTH,

Klaas
--
Orocos-Dev mailing list
Orocos-Dev [..] ...
http://lists.mech.kuleuven.be/mailman/listinfo/orocos-dev