prevent function from executing when other is executing

Hi,

I have a component that is running a kalman filter, which has 2 main
functions: propagate and update. I periodically propagate my kalman
filter, and I update my kalman filter event-driven when data comes
available on a port.

I sometimes get a segmentation fault when running this component. I
noticed that this is due to the problem that sometimes, while my
component is performing the propagation, new data becomes available on a
port, and the component will attempt to update the kalman filter while
performing the propagation. I tried solving it by setting some booleans
while doing the propagate/update. So something like this:

For propagating:


while(updating){}
propagating=true;
propagate();
propagating=false;


And for updating:


while(propagating){}
updating=true;
update();
updating=false;


But this didn't completely solve the issue.
Is there a better solution to prevent one function from executing while
the other is executing, and vise versa?

Kurt

prevent function from executing when other is executing

On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
<kurt [dot] geebelen [..] ...> wrote:
>
> Hi,
>
> I have a component that is running a kalman filter, which has 2 main
> functions: propagate and update. I periodically propagate my kalman
> filter, and I update my kalman filter event-driven when data comes
> available on a port.
>
> I sometimes get a segmentation fault when running this component. I
> noticed that this is due to the problem that sometimes, while my
> component is performing the propagation, new data becomes available on a
> port, and the component will attempt to update the kalman filter while
> performing the propagation. I tried solving it by setting some booleans
> while doing the propagate/update. So something like this:
>
> For propagating:
>
> &#10;&gt; while(updating){}&#10;&gt; propagating=true;&#10;&gt; propagate();&#10;&gt; propagating=false;&#10;&gt;

Change to:

&#10;{&#10;   os::MutexLock lock(m);&#10;   propagate();&#10;} // note these curly braces, they must be here !&#10;

>
> And for updating:
>
> &#10;&gt; while(propagating){}&#10;&gt; updating=true;&#10;&gt; update();&#10;&gt; updating=false;&#10;&gt;

change to:

&#10;{&#10;   os::MutexLock lock(m);&#10;   update();&#10;} // note these curly braces, they must be here !&#10;

>
> But this didn't completely solve the issue.
> Is there a better solution to prevent one function from executing while
> the other is executing, and vise versa?

Add a 'os::Mutex m;' member variable in your component class header
and lock it each time (as shown above) you want to mutually exclude
execution of some code by different threads.

The curly braces limit the 'scope' where the protection starts: it
starts at the 'lock' statement and ends at the ending '}'.

Peter

prevent function from executing when other is executing

On Sun, 31 Jul 2011, Peter Soetens wrote:

> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
> <kurt [dot] geebelen [..] ...> wrote:
>>
>> Hi,
>>
>> I have a component that is running a kalman filter, which has 2 main
>> functions: propagate and update. I periodically propagate my kalman
>> filter, and I update my kalman filter event-driven when data comes
>> available on a port.
>>
>> I sometimes get a segmentation fault when running this component. I
>> noticed that this is due to the problem that sometimes, while my
>> component is performing the propagation, new data becomes available on a
>> port, and the component will attempt to update the kalman filter while
>> performing the propagation. I tried solving it by setting some booleans
>> while doing the propagate/update. So something like this:
>>
>> For propagating:
>>
>> &#10;&gt;&gt; while(updating){}&#10;&gt;&gt; propagating=true;&#10;&gt;&gt; propagate();&#10;&gt;&gt; propagating=false;&#10;&gt;&gt;
>
> Change to:
>
> &#10;&gt; {&#10;&gt;   os::MutexLock lock(m);&#10;&gt;   propagate();&#10;&gt; } // note these curly braces, they must be here !&#10;&gt;
>
>>
>> And for updating:
>>
>> &#10;&gt;&gt; while(propagating){}&#10;&gt;&gt; updating=true;&#10;&gt;&gt; update();&#10;&gt;&gt; updating=false;&#10;&gt;&gt;
>
> change to:
>
> &#10;&gt; {&#10;&gt;   os::MutexLock lock(m);&#10;&gt;   update();&#10;&gt; } // note these curly braces, they must be here !&#10;&gt;
>

Please, don't invite users to start introducing explicit locks in their
applications! This brings us back to the times _before_ Orocos/RTT existed,
and to the reasons _why_ it was developed: to shield users from these ugly,
low-level, error-prone OS primitives. It is obvious that locks have _no_
place in a real component based application, by definition almost.

I am 100% sure Kurt's problem can be neatly solved with appropriate design
of his application using the core primitives of RTT, namely Ports and
simple Coordination with a state machine.

In addition to providing good software, Orocos also has an educational
vocation, and that is to stimulate best practice software engineering into
the mechatronics and robotics communities...

>> But this didn't completely solve the issue.
>> Is there a better solution to prevent one function from executing while
>> the other is executing, and vise versa?
>
> Add a 'os::Mutex m;' member variable in your component class header
> and lock it each time (as shown above) you want to mutually exclude
> execution of some code by different threads.
>
> The curly braces limit the 'scope' where the protection starts: it
> starts at the 'lock' statement and ends at the ending '}'.
>
> Peter

Herman

prevent function from executing when other is executing

On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:

> On Sun, 31 Jul 2011, Peter Soetens wrote:
>
>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
>> <kurt [dot] geebelen [..] ...> wrote:
>>>
>>> Hi,
>>>
>>> I have a component that is running a kalman filter, which has 2 main
>>> functions: propagate and update. I periodically propagate my kalman
>>> filter, and I update my kalman filter event-driven when data comes
>>> available on a port.
>>>
>>> I sometimes get a segmentation fault when running this component. I
>>> noticed that this is due to the problem that sometimes, while my
>>> component is performing the propagation, new data becomes available on a
>>> port, and the component will attempt to update the kalman filter while
>>> performing the propagation. I tried solving it by setting some booleans
>>> while doing the propagate/update. So something like this:
>>>
>>> For propagating:
>>>
>>> &#10;&gt;&gt;&gt; while(updating){}&#10;&gt;&gt;&gt; propagating=true;&#10;&gt;&gt;&gt; propagate();&#10;&gt;&gt;&gt; propagating=false;&#10;&gt;&gt;&gt;
>>
>> Change to:
>>
>> &#10;&gt;&gt; {&#10;&gt;&gt;  os::MutexLock lock(m);&#10;&gt;&gt;  propagate();&#10;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;
>>
>>>
>>> And for updating:
>>>
>>> &#10;&gt;&gt;&gt; while(propagating){}&#10;&gt;&gt;&gt; updating=true;&#10;&gt;&gt;&gt; update();&#10;&gt;&gt;&gt; updating=false;&#10;&gt;&gt;&gt;
>>
>> change to:
>>
>> &#10;&gt;&gt; {&#10;&gt;&gt;  os::MutexLock lock(m);&#10;&gt;&gt;  update();&#10;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;
>>
>
> Please, don't invite users to start introducing explicit locks in their
> applications! This brings us back to the times _before_ Orocos/RTT existed,
> and to the reasons _why_ it was developed: to shield users from these ugly,
> low-level, error-prone OS primitives. It is obvious that locks have _no_
> place in a real component based application, by definition almost.
>
> I am 100% sure Kurt's problem can be neatly solved with appropriate design
> of his application using the core primitives of RTT, namely Ports and
> simple Coordination with a state machine.
>
> In addition to providing good software, Orocos also has an educational
> vocation, and that is to stimulate best practice software engineering into
> the mechatronics and robotics communities...

True, but sometimes you need something to work first, before you make it correct. Peter's suggestion will fix his immediate needs _and_ we need to educate Kurt that this isn't the best approach and that he should consider doing it another way.
S

prevent function from executing when other is executing

Hi,

I have written a C+-class for the kalman filter, which has the 2
functions propagate and update (I didn't use the ExtendedKalmanFilter
class of the BLF-library because this way it was more clear to me what
was happening). The variables that are changed in both functions are the
covariance matrix and the state of the kalman filter. They are of type
Matrix of the Newmat library I am using
(http://www.robertnz.net/nm10.htm). The elements of these matrices are
of type double.

My estimator component than creates an instance of this kalman filter
class, periodically propagates it (apply system model), and whenever a
measurement becomes available, updates the kalman filter with this
measurement. This is thus where it sometimes goes wrong, when these
functions coincide.

Kurt

Op 31/07/2011 20:13, S Roderick schreef:
> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
>
>> On Sun, 31 Jul 2011, Peter Soetens wrote:
>>
>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
>>> <kurt [dot] geebelen [..] ...> wrote:
>>>> Hi,
>>>>
>>>> I have a component that is running a kalman filter, which has 2 main
>>>> functions: propagate and update. I periodically propagate my kalman
>>>> filter, and I update my kalman filter event-driven when data comes
>>>> available on a port.
>>>>
>>>> I sometimes get a segmentation fault when running this component. I
>>>> noticed that this is due to the problem that sometimes, while my
>>>> component is performing the propagation, new data becomes available on a
>>>> port, and the component will attempt to update the kalman filter while
>>>> performing the propagation. I tried solving it by setting some booleans
>>>> while doing the propagate/update. So something like this:
>>>>
>>>> For propagating:
>>>>
>>>> &#10;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt;&gt;&gt;&gt; propagate();&#10;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt;&gt;&gt;&gt;
>>> Change to:
>>>
>>> &#10;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;   os::MutexLock lock(m);&#10;&gt;&gt;&gt;   propagate();&#10;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;
>>>
>>>> And for updating:
>>>>
>>>> &#10;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt;&gt;&gt;&gt; updating=true;&#10;&gt;&gt;&gt;&gt; update();&#10;&gt;&gt;&gt;&gt; updating=false;&#10;&gt;&gt;&gt;&gt;
>>> change to:
>>>
>>> &#10;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;   os::MutexLock lock(m);&#10;&gt;&gt;&gt;   update();&#10;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;
>>>
>> Please, don't invite users to start introducing explicit locks in their
>> applications! This brings us back to the times _before_ Orocos/RTT existed,
>> and to the reasons _why_ it was developed: to shield users from these ugly,
>> low-level, error-prone OS primitives. It is obvious that locks have _no_
>> place in a real component based application, by definition almost.
>>
>> I am 100% sure Kurt's problem can be neatly solved with appropriate design
>> of his application using the core primitives of RTT, namely Ports and
>> simple Coordination with a state machine.
>>
>> In addition to providing good software, Orocos also has an educational
>> vocation, and that is to stimulate best practice software engineering into
>> the mechatronics and robotics communities...
> True, but sometimes you need something to work first, before you make it correct. Peter's suggestion will fix his immediate needs _and_ we need to educate Kurt that this isn't the best approach and that he should consider doing it another way.
> S
>

prevent function from executing when other is executing

On Mon, 1 Aug 2011, Kurt Geebelen wrote:

> Hi,
(Please do not top post <http://en.wikipedia.org/wiki/Top_posting>)

> I have written a C+-class for the kalman filter, which has the 2
> functions propagate and update (I didn't use the ExtendedKalmanFilter
> class of the BLF-library because this way it was more clear to me what
> was happening).

Oops... What is not clear with the way the BFL integrates an EKF into
Orocos?
E.g. <http://comments.gmane.org/gmane.science.robotics.orocos.devel/8457>

> The variables that are changed in both functions are the
> covariance matrix and the state of the kalman filter. They are of type
> Matrix of the Newmat library I am using
> (http://www.robertnz.net/nm10.htm). The elements of these matrices are
> of type double.
>
> My estimator component than creates an instance of this kalman filter
> class, periodically propagates it (apply system model), and whenever a
> measurement becomes available, updates the kalman filter with this
> measurement. This is thus where it sometimes goes wrong, when these
> functions coincide.

Exactly. But they should not "coincide" :-) I mean, the component that
contains the (E)KF code should run the process update and measurement
update 'atomically', which could be realised by letting it read from Data
ports (one for new timer data, one for new measurement data).

I have the impression you have another design, in which you call an
operation on the EKF component from two other components, and in this way
it becomes very difficult for the EKF component to guarantee data
consistency...

Is my assumption about your architecture correct or not?
In other words, what _is_ the architecture of your complete system?

> Kurt

Herman

> Op 31/07/2011 20:13, S Roderick schreef:
>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
>>
>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
>>>
>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
>>>> <kurt [dot] geebelen [..] ...> wrote:
>>>>> Hi,
>>>>>
>>>>> I have a component that is running a kalman filter, which has 2 main
>>>>> functions: propagate and update. I periodically propagate my kalman
>>>>> filter, and I update my kalman filter event-driven when data comes
>>>>> available on a port.
>>>>>
>>>>> I sometimes get a segmentation fault when running this component. I
>>>>> noticed that this is due to the problem that sometimes, while my
>>>>> component is performing the propagation, new data becomes available on a
>>>>> port, and the component will attempt to update the kalman filter while
>>>>> performing the propagation. I tried solving it by setting some booleans
>>>>> while doing the propagate/update. So something like this:
>>>>>
>>>>> For propagating:
>>>>>
>>>>> &#10;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt;&gt;&gt;&gt;&gt;
>>>> Change to:
>>>>
>>>> &#10;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;   os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;   propagate();&#10;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;
>>>>
>>>>> And for updating:
>>>>>
>>>>> &#10;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt;&gt;&gt;&gt;&gt;
>>>> change to:
>>>>
>>>> &#10;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;   os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;   update();&#10;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;
>>>>
>>> Please, don't invite users to start introducing explicit locks in their
>>> applications! This brings us back to the times _before_ Orocos/RTT existed,
>>> and to the reasons _why_ it was developed: to shield users from these ugly,
>>> low-level, error-prone OS primitives. It is obvious that locks have _no_
>>> place in a real component based application, by definition almost.
>>>
>>> I am 100% sure Kurt's problem can be neatly solved with appropriate design
>>> of his application using the core primitives of RTT, namely Ports and
>>> simple Coordination with a state machine.
>>>
>>> In addition to providing good software, Orocos also has an educational
>>> vocation, and that is to stimulate best practice software engineering into
>>> the mechatronics and robotics communities...
>> True, but sometimes you need something to work first, before you make it correct. Peter's suggestion will fix his immediate needs _and_ we need to educate Kurt that this isn't the best approach and that he should consider doing it another way.
>> S
>>
>

--
K.U.Leuven, Mechanical Eng., Mechatronics & Robotics Research Group
<http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
EURON Coordinator (European Robotics Research Network) <http://www.euron.org>
Open Realtime Control Services <http://www.orocos.org>
Associate Editor JOSER <http://www.joser.org>, IJRR <http://www.ijrr.org>

prevent function from executing when other is executing

Op 1/08/2011 10:00, Herman Bruyninckx schreef:
> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>
>> Hi,
> (Please do not top post<http://en.wikipedia.org/wiki/Top_posting>)

Sorry

>
>> I have written a C+-class for the kalman filter, which has the 2
>> functions propagate and update (I didn't use the ExtendedKalmanFilter
>> class of the BLF-library because this way it was more clear to me what
>> was happening).
> Oops... What is not clear with the way the BFL integrates an EKF into
> Orocos?
> E.g.<http://comments.gmane.org/gmane.science.robotics.orocos.devel/8457>

Nothing is wrong with it. I just thought it would be a better exercise
to implement it myself.

>
>> The variables that are changed in both functions are the
>> covariance matrix and the state of the kalman filter. They are of type
>> Matrix of the Newmat library I am using
>> (http://www.robertnz.net/nm10.htm). The elements of these matrices are
>> of type double.
>>
>> My estimator component than creates an instance of this kalman filter
>> class, periodically propagates it (apply system model), and whenever a
>> measurement becomes available, updates the kalman filter with this
>> measurement. This is thus where it sometimes goes wrong, when these
>> functions coincide.
> Exactly. But they should not "coincide" :-) I mean, the component that
> contains the (E)KF code should run the process update and measurement
> update 'atomically', which could be realised by letting it read from Data
> ports (one for new timer data, one for new measurement data).
>
> I have the impression you have another design, in which you call an
> operation on the EKF component from two other components, and in this way
> it becomes very difficult for the EKF component to guarantee data
> consistency...
>
> Is my assumption about your architecture correct or not?
> In other words, what _is_ the architecture of your complete system?

There is only one component communicating with the kalman filter, namely
the estimator component. Note that the EKF is not a orocos-component,
but just a C++ class, on which the estimator-component is calling
functions. I could integrate this code in the estimator component, but I
don't think this would change much?

In the estimator component, in the updateHook, I thus do the process
update. The measurements are coming from another component, which puts
them on a Data port. My estimator component connects with this port, and
I have coupled an event to this port, which performs the measurement
update with the data on this port.

>
>> Kurt
> Herman

Kurt

>
>> Op 31/07/2011 20:13, S Roderick schreef:
>>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
>>>
>>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
>>>>
>>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
>>>>> <kurt [dot] geebelen [..] ...> wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I have a component that is running a kalman filter, which has 2 main
>>>>>> functions: propagate and update. I periodically propagate my kalman
>>>>>> filter, and I update my kalman filter event-driven when data comes
>>>>>> available on a port.
>>>>>>
>>>>>> I sometimes get a segmentation fault when running this component. I
>>>>>> noticed that this is due to the problem that sometimes, while my
>>>>>> component is performing the propagation, new data becomes available on a
>>>>>> port, and the component will attempt to update the kalman filter while
>>>>>> performing the propagation. I tried solving it by setting some booleans
>>>>>> while doing the propagate/update. So something like this:
>>>>>>
>>>>>> For propagating:
>>>>>>
>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>> Change to:
>>>>>
>>>>> &#10;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;    os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;    propagate();&#10;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;
>>>>>
>>>>>> And for updating:
>>>>>>
>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>> change to:
>>>>>
>>>>> &#10;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;    os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;    update();&#10;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;
>>>>>
>>>> Please, don't invite users to start introducing explicit locks in their
>>>> applications! This brings us back to the times _before_ Orocos/RTT existed,
>>>> and to the reasons _why_ it was developed: to shield users from these ugly,
>>>> low-level, error-prone OS primitives. It is obvious that locks have _no_
>>>> place in a real component based application, by definition almost.
>>>>
>>>> I am 100% sure Kurt's problem can be neatly solved with appropriate design
>>>> of his application using the core primitives of RTT, namely Ports and
>>>> simple Coordination with a state machine.
>>>>
>>>> In addition to providing good software, Orocos also has an educational
>>>> vocation, and that is to stimulate best practice software engineering into
>>>> the mechatronics and robotics communities...
>>> True, but sometimes you need something to work first, before you make it correct. Peter's suggestion will fix his immediate needs _and_ we need to educate Kurt that this isn't the best approach and that he should consider doing it another way.
>>> S
>>>
> --
> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
> Open Realtime Control Services<http://www.orocos.org>
> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>

prevent function from executing when other is executing

On Mon, 1 Aug 2011, Kurt Geebelen wrote:

> Op 1/08/2011 10:00, Herman Bruyninckx schreef:
>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>>
>>> Hi,
>> (Please do not top post<http://en.wikipedia.org/wiki/Top_posting>)
>
> Sorry
>
>>
>>> I have written a C+-class for the kalman filter, which has the 2
>>> functions propagate and update (I didn't use the ExtendedKalmanFilter
>>> class of the BLF-library because this way it was more clear to me what
>>> was happening).
>> Oops... What is not clear with the way the BFL integrates an EKF into
>> Orocos?
>> E.g.<http://comments.gmane.org/gmane.science.robotics.orocos.devel/8457>
>
> Nothing is wrong with it. I just thought it would be a better exercise
> to implement it myself.

That turns out to be true :-) There is no better schooling than to repeat
the errors one _has_ to make before being able to appreciate better
practice solutions :-)

>>> The variables that are changed in both functions are the
>>> covariance matrix and the state of the kalman filter. They are of type
>>> Matrix of the Newmat library I am using
>>> (http://www.robertnz.net/nm10.htm). The elements of these matrices are
>>> of type double.
>>>
>>> My estimator component than creates an instance of this kalman filter
>>> class, periodically propagates it (apply system model), and whenever a
>>> measurement becomes available, updates the kalman filter with this
>>> measurement. This is thus where it sometimes goes wrong, when these
>>> functions coincide.
>> Exactly. But they should not "coincide" :-) I mean, the component that
>> contains the (E)KF code should run the process update and measurement
>> update 'atomically', which could be realised by letting it read from Data
>> ports (one for new timer data, one for new measurement data).
>>
>> I have the impression you have another design, in which you call an
>> operation on the EKF component from two other components, and in this way
>> it becomes very difficult for the EKF component to guarantee data
>> consistency...
>>
>> Is my assumption about your architecture correct or not?
>> In other words, what _is_ the architecture of your complete system?
>
> There is only one component communicating with the kalman filter, namely
> the estimator component.

Strange, since the Kalman Filter _is_ an estimator...

> Note that the EKF is not a orocos-component,
> but just a C++ class, on which the estimator-component is calling
> functions.

And where does the EKF class resides? It must be in some "component", isn't
it?

> I could integrate this code in the estimator component, but I
> don't think this would change much?

I think it will change everything :-)

> In the estimator component, in the updateHook, I thus do the process
> update. The measurements are coming from another component, which puts
> them on a Data port. My estimator component connects with this port, and
> I have coupled an event to this port, which performs the measurement
> update with the data on this port.

Fine! And what about the process update? Can't you do that in the same way?
(That is, via a time-triggered data port.)
And isn't your KF C++ class then "running" de facto inside of the estimator
component?

Herman

>>> Op 31/07/2011 20:13, S Roderick schreef:
>>>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
>>>>
>>>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
>>>>>
>>>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
>>>>>> <kurt [dot] geebelen [..] ...> wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> I have a component that is running a kalman filter, which has 2 main
>>>>>>> functions: propagate and update. I periodically propagate my kalman
>>>>>>> filter, and I update my kalman filter event-driven when data comes
>>>>>>> available on a port.
>>>>>>>
>>>>>>> I sometimes get a segmentation fault when running this component. I
>>>>>>> noticed that this is due to the problem that sometimes, while my
>>>>>>> component is performing the propagation, new data becomes available on a
>>>>>>> port, and the component will attempt to update the kalman filter while
>>>>>>> performing the propagation. I tried solving it by setting some booleans
>>>>>>> while doing the propagate/update. So something like this:
>>>>>>>
>>>>>>> For propagating:
>>>>>>>
>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>> Change to:
>>>>>>
>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;&gt;    os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;&gt;    propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>
>>>>>>> And for updating:
>>>>>>>
>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>> change to:
>>>>>>
>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;&gt;    os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;&gt;    update();&#10;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>
>>>>> Please, don't invite users to start introducing explicit locks in their
>>>>> applications! This brings us back to the times _before_ Orocos/RTT existed,
>>>>> and to the reasons _why_ it was developed: to shield users from these ugly,
>>>>> low-level, error-prone OS primitives. It is obvious that locks have _no_
>>>>> place in a real component based application, by definition almost.
>>>>>
>>>>> I am 100% sure Kurt's problem can be neatly solved with appropriate design
>>>>> of his application using the core primitives of RTT, namely Ports and
>>>>> simple Coordination with a state machine.
>>>>>
>>>>> In addition to providing good software, Orocos also has an educational
>>>>> vocation, and that is to stimulate best practice software engineering into
>>>>> the mechatronics and robotics communities...
>>>> True, but sometimes you need something to work first, before you make it correct. Peter's suggestion will fix his immediate needs _and_ we need to educate Kurt that this isn't the best approach and that he should consider doing it another way.
>>>> S
>>>>
>> --
>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
>> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
>> Open Realtime Control Services<http://www.orocos.org>
>> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>
>

--
K.U.Leuven, Mechanical Eng., Mechatronics & Robotics Research Group
<http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
EURON Coordinator (European Robotics Research Network) <http://www.euron.org>
Open Realtime Control Services <http://www.orocos.org>
Associate Editor JOSER <http://www.joser.org>, IJRR <http://www.ijrr.org>

prevent function from executing when other is executing

2011/8/1 Herman Bruyninckx <Herman [dot] Bruyninckx [..] ...>

> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>
> > Op 1/08/2011 10:00, Herman Bruyninckx schreef:
> >> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
> >>
> >>> Hi,
> >> (Please do not top post<http://en.wikipedia.org/wiki/Top_posting>)
> >
> > Sorry
> >
> >>
> >>> I have written a C+-class for the kalman filter, which has the 2
> >>> functions propagate and update (I didn't use the ExtendedKalmanFilter
> >>> class of the BLF-library because this way it was more clear to me what
> >>> was happening).
> >> Oops... What is not clear with the way the BFL integrates an EKF into
> >> Orocos?
> >> E.g.<http://comments.gmane.org/gmane.science.robotics.orocos.devel/8457
> >
> >
> > Nothing is wrong with it. I just thought it would be a better exercise
> > to implement it myself.
>
> That turns out to be true :-) There is no better schooling than to repeat
> the errors one _has_ to make before being able to appreciate better
> practice solutions :-)
>
> >>> The variables that are changed in both functions are the
> >>> covariance matrix and the state of the kalman filter. They are of type
> >>> Matrix of the Newmat library I am using
> >>> (http://www.robertnz.net/nm10.htm). The elements of these matrices are
> >>> of type double.
> >>>
> >>> My estimator component than creates an instance of this kalman filter
> >>> class, periodically propagates it (apply system model), and whenever a
> >>> measurement becomes available, updates the kalman filter with this
> >>> measurement. This is thus where it sometimes goes wrong, when these
> >>> functions coincide.
> >> Exactly. But they should not "coincide" :-) I mean, the component that
> >> contains the (E)KF code should run the process update and measurement
> >> update 'atomically', which could be realised by letting it read from
> Data
> >> ports (one for new timer data, one for new measurement data).
> >>
> >> I have the impression you have another design, in which you call an
> >> operation on the EKF component from two other components, and in this
> way
> >> it becomes very difficult for the EKF component to guarantee data
> >> consistency...
> >>
> >> Is my assumption about your architecture correct or not?
> >> In other words, what _is_ the architecture of your complete system?
> >
> > There is only one component communicating with the kalman filter, namely
> > the estimator component.
>
> Strange, since the Kalman Filter _is_ an estimator...
>
> > Note that the EKF is not a orocos-component,
> > but just a C++ class, on which the estimator-component is calling
> > functions.
>
> And where does the EKF class resides? It must be in some "component", isn't
> it?
>
> > I could integrate this code in the estimator component, but I
> > don't think this would change much?
>
> I think it will change everything :-)
>

Keeping your logic out of components is a nice practice because it separates
your working code from the "glue code" that integrates it into your
framework (here in an Orocos Component). I think Herman wants to say that
your problem is where the object is instanciated from your class (expecting
you don't have static variables).

>
> > In the estimator component, in the updateHook, I thus do the process
> > update. The measurements are coming from another component, which puts
> > them on a Data port. My estimator component connects with this port, and
> > I have coupled an event to this port, which performs the measurement
> > update with the data on this port.
>
> Fine! And what about the process update? Can't you do that in the same way?
> (That is, via a time-triggered data port.)
> And isn't your KF C++ class then "running" de facto inside of the estimator
> component?
>
> Herman
>
> >>> Op 31/07/2011 20:13, S Roderick schreef:
> >>>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
> >>>>
> >>>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
> >>>>>
> >>>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
> >>>>>> <kurt [dot] geebelen [..] ...> wrote:
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> I have a component that is running a kalman filter, which has 2
> main
> >>>>>>> functions: propagate and update. I periodically propagate my kalman
> >>>>>>> filter, and I update my kalman filter event-driven when data comes
> >>>>>>> available on a port.
> >>>>>>>
> >>>>>>> I sometimes get a segmentation fault when running this component. I
> >>>>>>> noticed that this is due to the problem that sometimes, while my
> >>>>>>> component is performing the propagation, new data becomes available
> on a
> >>>>>>> port, and the component will attempt to update the kalman filter
> while
> >>>>>>> performing the propagation. I tried solving it by setting some
> booleans
> >>>>>>> while doing the propagate/update. So something like this:
> >>>>>>>
> >>>>>>> For propagating:
> >>>>>>>
> >>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>> Change to:
> >>>>>>
> >>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;    os::MutexLock lock(m);&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;    propagate();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>
> >>>>>>> And for updating:
> >>>>>>>
> >>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>> change to:
> >>>>>>
> >>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;    os::MutexLock lock(m);&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;    update();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>
> >>>>> Please, don't invite users to start introducing explicit locks in
> their
> >>>>> applications! This brings us back to the times _before_ Orocos/RTT
> existed,
> >>>>> and to the reasons _why_ it was developed: to shield users from these
> ugly,
> >>>>> low-level, error-prone OS primitives. It is obvious that locks have
> _no_
> >>>>> place in a real component based application, by definition almost.
> >>>>>
> >>>>> I am 100% sure Kurt's problem can be neatly solved with appropriate
> design
> >>>>> of his application using the core primitives of RTT, namely Ports and
> >>>>> simple Coordination with a state machine.
> >>>>>
> >>>>> In addition to providing good software, Orocos also has an
> educational
> >>>>> vocation, and that is to stimulate best practice software engineering
> into
> >>>>> the mechatronics and robotics communities...
> >>>> True, but sometimes you need something to work first, before you make
> it correct. Peter's suggestion will fix his immediate needs _and_ we need to
> educate Kurt that this isn't the best approach and that he should consider
> doing it another way.
> >>>> S
> >>>>
> >> --
> >> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
> >> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> >> EURON Coordinator (European Robotics Research Network)<
> http://www.euron.org>
> >> Open Realtime Control Services<http://www.orocos.org>
> >> Associate Editor JOSER<http://www.joser.org>, IJRR<
> http://www.ijrr.org>
> >
>
> --
> K.U.Leuven, Mechanical Eng., Mechatronics & Robotics Research Group
> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> EURON Coordinator (European Robotics Research Network) <
> http://www.euron.org>
> Open Realtime Control Services <http://www.orocos.org>
> Associate Editor JOSER <http://www.joser.org>, IJRR <http://www.ijrr.org
> >
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>

prevent function from executing when other is executing

Op 1/08/2011 10:37, Herman Bruyninckx schreef:
> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>
>> Op 1/08/2011 10:00, Herman Bruyninckx schreef:
>>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>>>
>>>> Hi,
>>> (Please do not top post<http://en.wikipedia.org/wiki/Top_posting>)
>> Sorry
>>
>>>> I have written a C+-class for the kalman filter, which has the 2
>>>> functions propagate and update (I didn't use the ExtendedKalmanFilter
>>>> class of the BLF-library because this way it was more clear to me what
>>>> was happening).
>>> Oops... What is not clear with the way the BFL integrates an EKF into
>>> Orocos?
>>> E.g.<http://comments.gmane.org/gmane.science.robotics.orocos.devel/8457>
>> Nothing is wrong with it. I just thought it would be a better exercise
>> to implement it myself.
> That turns out to be true :-) There is no better schooling than to repeat
> the errors one _has_ to make before being able to appreciate better
> practice solutions :-)
>
>>>> The variables that are changed in both functions are the
>>>> covariance matrix and the state of the kalman filter. They are of type
>>>> Matrix of the Newmat library I am using
>>>> (http://www.robertnz.net/nm10.htm). The elements of these matrices are
>>>> of type double.
>>>>
>>>> My estimator component than creates an instance of this kalman filter
>>>> class, periodically propagates it (apply system model), and whenever a
>>>> measurement becomes available, updates the kalman filter with this
>>>> measurement. This is thus where it sometimes goes wrong, when these
>>>> functions coincide.
>>> Exactly. But they should not "coincide" :-) I mean, the component that
>>> contains the (E)KF code should run the process update and measurement
>>> update 'atomically', which could be realised by letting it read from Data
>>> ports (one for new timer data, one for new measurement data).
>>>
>>> I have the impression you have another design, in which you call an
>>> operation on the EKF component from two other components, and in this way
>>> it becomes very difficult for the EKF component to guarantee data
>>> consistency...
>>>
>>> Is my assumption about your architecture correct or not?
>>> In other words, what _is_ the architecture of your complete system?
>> There is only one component communicating with the kalman filter, namely
>> the estimator component.
> Strange, since the Kalman Filter _is_ an estimator...
>
>> Note that the EKF is not a orocos-component,
>> but just a C++ class, on which the estimator-component is calling
>> functions.
> And where does the EKF class resides? It must be in some "component", isn't
> it?
>
>> I could integrate this code in the estimator component, but I
>> don't think this would change much?
> I think it will change everything :-)
>
>> In the estimator component, in the updateHook, I thus do the process
>> update. The measurements are coming from another component, which puts
>> them on a Data port. My estimator component connects with this port, and
>> I have coupled an event to this port, which performs the measurement
>> update with the data on this port.
> Fine! And what about the process update? Can't you do that in the same way?
> (That is, via a time-triggered data port.)

I can do that. But won't this still give the same problems when this
coincides with the measurement update?

> And isn't your KF C++ class then "running" de facto inside of the estimator
> component?

Yes it is. That's why I thought moving it directly in the estimator
component wouldn't change that much.

>
> Herman

Kurt

>
>>>> Op 31/07/2011 20:13, S Roderick schreef:
>>>>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
>>>>>
>>>>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
>>>>>>
>>>>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
>>>>>>> <kurt [dot] geebelen [..] ...> wrote:
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I have a component that is running a kalman filter, which has 2 main
>>>>>>>> functions: propagate and update. I periodically propagate my kalman
>>>>>>>> filter, and I update my kalman filter event-driven when data comes
>>>>>>>> available on a port.
>>>>>>>>
>>>>>>>> I sometimes get a segmentation fault when running this component. I
>>>>>>>> noticed that this is due to the problem that sometimes, while my
>>>>>>>> component is performing the propagation, new data becomes available on a
>>>>>>>> port, and the component will attempt to update the kalman filter while
>>>>>>>> performing the propagation. I tried solving it by setting some booleans
>>>>>>>> while doing the propagate/update. So something like this:
>>>>>>>>
>>>>>>>> For propagating:
>>>>>>>>
>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>> Change to:
>>>>>>>
>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>
>>>>>>>> And for updating:
>>>>>>>>
>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>> change to:
>>>>>>>
>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     update();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>
>>>>>> Please, don't invite users to start introducing explicit locks in their
>>>>>> applications! This brings us back to the times _before_ Orocos/RTT existed,
>>>>>> and to the reasons _why_ it was developed: to shield users from these ugly,
>>>>>> low-level, error-prone OS primitives. It is obvious that locks have _no_
>>>>>> place in a real component based application, by definition almost.
>>>>>>
>>>>>> I am 100% sure Kurt's problem can be neatly solved with appropriate design
>>>>>> of his application using the core primitives of RTT, namely Ports and
>>>>>> simple Coordination with a state machine.
>>>>>>
>>>>>> In addition to providing good software, Orocos also has an educational
>>>>>> vocation, and that is to stimulate best practice software engineering into
>>>>>> the mechatronics and robotics communities...
>>>>> True, but sometimes you need something to work first, before you make it correct. Peter's suggestion will fix his immediate needs _and_ we need to educate Kurt that this isn't the best approach and that he should consider doing it another way.
>>>>> S
>>>>>
>>> --
>>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
>>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
>>> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
>>> Open Realtime Control Services<http://www.orocos.org>
>>> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>
> --
> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
> Open Realtime Control Services<http://www.orocos.org>
> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>

prevent function from executing when other is executing

On Mon, 1 Aug 2011, Kurt Geebelen wrote:

> Op 1/08/2011 10:37, Herman Bruyninckx schreef:
>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>>
>>> Op 1/08/2011 10:00, Herman Bruyninckx schreef:
>>>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>>>>
>>>>> Hi,
>>>> (Please do not top post<http://en.wikipedia.org/wiki/Top_posting>)
>>> Sorry
>>>
>>>>> I have written a C+-class for the kalman filter, which has the 2
>>>>> functions propagate and update (I didn't use the ExtendedKalmanFilter
>>>>> class of the BLF-library because this way it was more clear to me what
>>>>> was happening).
>>>> Oops... What is not clear with the way the BFL integrates an EKF into
>>>> Orocos?
>>>> E.g.<http://comments.gmane.org/gmane.science.robotics.orocos.devel/8457>
>>> Nothing is wrong with it. I just thought it would be a better exercise
>>> to implement it myself.
>> That turns out to be true :-) There is no better schooling than to repeat
>> the errors one _has_ to make before being able to appreciate better
>> practice solutions :-)
>>
>>>>> The variables that are changed in both functions are the
>>>>> covariance matrix and the state of the kalman filter. They are of type
>>>>> Matrix of the Newmat library I am using
>>>>> (http://www.robertnz.net/nm10.htm). The elements of these matrices are
>>>>> of type double.
>>>>>
>>>>> My estimator component than creates an instance of this kalman filter
>>>>> class, periodically propagates it (apply system model), and whenever a
>>>>> measurement becomes available, updates the kalman filter with this
>>>>> measurement. This is thus where it sometimes goes wrong, when these
>>>>> functions coincide.
>>>> Exactly. But they should not "coincide" :-) I mean, the component that
>>>> contains the (E)KF code should run the process update and measurement
>>>> update 'atomically', which could be realised by letting it read from Data
>>>> ports (one for new timer data, one for new measurement data).
>>>>
>>>> I have the impression you have another design, in which you call an
>>>> operation on the EKF component from two other components, and in this way
>>>> it becomes very difficult for the EKF component to guarantee data
>>>> consistency...
>>>>
>>>> Is my assumption about your architecture correct or not?
>>>> In other words, what _is_ the architecture of your complete system?
>>> There is only one component communicating with the kalman filter, namely
>>> the estimator component.
>> Strange, since the Kalman Filter _is_ an estimator...
>>
>>> Note that the EKF is not a orocos-component,
>>> but just a C++ class, on which the estimator-component is calling
>>> functions.
>> And where does the EKF class resides? It must be in some "component", isn't
>> it?
>>
>>> I could integrate this code in the estimator component, but I
>>> don't think this would change much?
>> I think it will change everything :-)
>>
>>> In the estimator component, in the updateHook, I thus do the process
>>> update. The measurements are coming from another component, which puts
>>> them on a Data port. My estimator component connects with this port, and
>>> I have coupled an event to this port, which performs the measurement
>>> update with the data on this port.
>> Fine! And what about the process update? Can't you do that in the same way?
>> (That is, via a time-triggered data port.)
>
> I can do that. But won't this still give the same problems when this
> coincides with the measurement update?

The component's TaskContext will 'serialize' the handling of the arrival of
data on the Ports. That's a major feature of RTT: no need to do locking
yourself anymore :-) The design problems are hence moved towards finding
the "best" component architecture and configuration of the individual
components.

>> And isn't your KF C++ class then "running" de facto inside of the estimator
>> component?
>
> Yes it is. That's why I thought moving it directly in the estimator
> component wouldn't change that much.

You are not "moving" anything :-) The compiler links your library to the
code that is being deployed inside your estimator component, so it _is_
already there :-)

Herman

>>>>> Op 31/07/2011 20:13, S Roderick schreef:
>>>>>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
>>>>>>
>>>>>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
>>>>>>>
>>>>>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
>>>>>>>> <kurt [dot] geebelen [..] ...> wrote:
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> I have a component that is running a kalman filter, which has 2 main
>>>>>>>>> functions: propagate and update. I periodically propagate my kalman
>>>>>>>>> filter, and I update my kalman filter event-driven when data comes
>>>>>>>>> available on a port.
>>>>>>>>>
>>>>>>>>> I sometimes get a segmentation fault when running this component. I
>>>>>>>>> noticed that this is due to the problem that sometimes, while my
>>>>>>>>> component is performing the propagation, new data becomes available on a
>>>>>>>>> port, and the component will attempt to update the kalman filter while
>>>>>>>>> performing the propagation. I tried solving it by setting some booleans
>>>>>>>>> while doing the propagate/update. So something like this:
>>>>>>>>>
>>>>>>>>> For propagating:
>>>>>>>>>
>>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>> Change to:
>>>>>>>>
>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>>
>>>>>>>>> And for updating:
>>>>>>>>>
>>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>> change to:
>>>>>>>>
>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     update();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>>
>>>>>>> Please, don't invite users to start introducing explicit locks in their
>>>>>>> applications! This brings us back to the times _before_ Orocos/RTT existed,
>>>>>>> and to the reasons _why_ it was developed: to shield users from these ugly,
>>>>>>> low-level, error-prone OS primitives. It is obvious that locks have _no_
>>>>>>> place in a real component based application, by definition almost.
>>>>>>>
>>>>>>> I am 100% sure Kurt's problem can be neatly solved with appropriate design
>>>>>>> of his application using the core primitives of RTT, namely Ports and
>>>>>>> simple Coordination with a state machine.
>>>>>>>
>>>>>>> In addition to providing good software, Orocos also has an educational
>>>>>>> vocation, and that is to stimulate best practice software engineering into
>>>>>>> the mechatronics and robotics communities...
>>>>>> True, but sometimes you need something to work first, before you make it correct. Peter's suggestion will fix his immediate needs _and_ we need to educate Kurt that this isn't the best approach and that he should consider doing it another way.
>>>>>> S
>>>>>>
>>>> --
>>>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
>>>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
>>>> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
>>>> Open Realtime Control Services<http://www.orocos.org>
>>>> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>
>> --
>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
>> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
>> Open Realtime Control Services<http://www.orocos.org>
>> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>
>

--
K.U.Leuven, Mechanical Eng., Mechatronics & Robotics Research Group
<http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
EURON Coordinator (European Robotics Research Network) <http://www.euron.org>
Open Realtime Control Services <http://www.orocos.org>
Associate Editor JOSER <http://www.joser.org>, IJRR <http://www.ijrr.org>

prevent function from executing when other is executing

--Boundary-01=_xgQROL2C+9IVlJ2
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

On Monday 01 August 2011 11:26:28 Herman Bruyninckx wrote:
> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
> > Op 1/08/2011 10:37, Herman Bruyninckx schreef:
> >> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
> >>> Op 1/08/2011 10:00, Herman Bruyninckx schreef:
> >>>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
> >>>>> Hi,
> >>>>
> >>>> (Please do not top post<http://en.wikipedia.org/wiki/Top_posting>)
> >>>
> >>> Sorry
> >>>
> >>>>> I have written a C+-class for the kalman filter, which has the 2
> >>>>> functions propagate and update (I didn't use the ExtendedKalmanFilter
> >>>>> class of the BLF-library because this way it was more clear to me
> >>>>> what was happening).
> >>>>
> >>>> Oops... What is not clear with the way the BFL integrates an EKF into
> >>>> Orocos?
> >>>> E.g.<http://comments.gmane.org/gmane.science.robotics.orocos.devel/845
> >>>> 7>
> >>>
> >>> Nothing is wrong with it. I just thought it would be a better exercise
> >>> to implement it myself.
> >>
> >> That turns out to be true :-) There is no better schooling than to
> >> repeat the errors one _has_ to make before being able to appreciate
> >> better practice solutions :-)
> >>
> >>>>> The variables that are changed in both functions are the
> >>>>> covariance matrix and the state of the kalman filter. They are of
> >>>>> type Matrix of the Newmat library I am using
> >>>>> (http://www.robertnz.net/nm10.htm). The elements of these matrices
> >>>>> are of type double.
> >>>>>
> >>>>> My estimator component than creates an instance of this kalman filter
> >>>>> class, periodically propagates it (apply system model), and whenever
> >>>>> a measurement becomes available, updates the kalman filter with this
> >>>>> measurement. This is thus where it sometimes goes wrong, when these
> >>>>> functions coincide.
> >>>>
> >>>> Exactly. But they should not "coincide" :-) I mean, the component that
> >>>> contains the (E)KF code should run the process update and measurement
> >>>> update 'atomically', which could be realised by letting it read from
> >>>> Data ports (one for new timer data, one for new measurement data).
> >>>>
> >>>> I have the impression you have another design, in which you call an
> >>>> operation on the EKF component from two other components, and in this
> >>>> way it becomes very difficult for the EKF component to guarantee data
> >>>> consistency...
> >>>>
> >>>> Is my assumption about your architecture correct or not?
> >>>> In other words, what _is_ the architecture of your complete system?
> >>>
> >>> There is only one component communicating with the kalman filter,
> >>> namely the estimator component.
> >>
> >> Strange, since the Kalman Filter _is_ an estimator...
> >>
> >>> Note that the EKF is not a orocos-component,
> >>> but just a C++ class, on which the estimator-component is calling
> >>> functions.
> >>
> >> And where does the EKF class resides? It must be in some "component",
> >> isn't it?
> >>
> >>> I could integrate this code in the estimator component, but I
> >>> don't think this would change much?
> >>
> >> I think it will change everything :-)
> >>
> >>> In the estimator component, in the updateHook, I thus do the process
> >>> update. The measurements are coming from another component, which puts
> >>> them on a Data port. My estimator component connects with this port,
> >>> and I have coupled an event to this port, which performs the
> >>> measurement update with the data on this port.
> >>
> >> Fine! And what about the process update? Can't you do that in the same
> >> way? (That is, via a time-triggered data port.)
> >
> > I can do that. But won't this still give the same problems when this
> > coincides with the measurement update?
>
> The component's TaskContext will 'serialize' the handling of the arrival of
> data on the Ports. That's a major feature of RTT: no need to do locking
> yourself anymore :-) The design problems are hence moved towards finding
> the "best" component architecture and configuration of the individual
> components.

Indeed!

I have been working with filter-components for a long time and I suggest the
following construction
* create an sysUpdate function and a measUpdate function
* run your component non periodically
* have the sysUpdate triggered periodically trough an eventPort triggered by a
timer component
* have the measUpdate triggered by the measurement port.

You can find an example of such a component at
http://git.mech.kuleuven.be/?p=robotics/camera_pose_estimation.git;a=sum...

If you need any extra explanation I will be glad to help you.

Tinne

>
> >> And isn't your KF C++ class then "running" de facto inside of the
> >> estimator component?
> >
> > Yes it is. That's why I thought moving it directly in the estimator
> > component wouldn't change that much.
>
> You are not "moving" anything :-) The compiler links your library to the
> code that is being deployed inside your estimator component, so it _is_
> already there :-)
>
> Herman
>
> >>>>> Op 31/07/2011 20:13, S Roderick schreef:
> >>>>>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
> >>>>>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
> >>>>>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
> >>>>>>>>
> >>>>>>>> <kurt [dot] geebelen [..] ...> wrote:
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>> I have a component that is running a kalman filter, which has 2
> >>>>>>>>> main functions: propagate and update. I periodically propagate
> >>>>>>>>> my kalman filter, and I update my kalman filter event-driven
> >>>>>>>>> when data comes available on a port.
> >>>>>>>>>
> >>>>>>>>> I sometimes get a segmentation fault when running this component.
> >>>>>>>>> I noticed that this is due to the problem that sometimes, while
> >>>>>>>>> my component is performing the propagation, new data becomes
> >>>>>>>>> available on a port, and the component will attempt to update
> >>>>>>>>> the kalman filter while performing the propagation. I tried
> >>>>>>>>> solving it by setting some booleans while doing the
> >>>>>>>>> propagate/update. So something like this:
> >>>>>>>>>
> >>>>>>>>> For propagating:
> >>>>>>>>>
> >>>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>>
> >>>>>>>> Change to:
> >>>>>>>>
> >>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     os::MutexLock lock(m);&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     propagate();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>>
> >>>>>>>>> And for updating:
> >>>>>>>>>
> >>>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>>
> >>>>>>>> change to:
> >>>>>>>>
> >>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     os::MutexLock lock(m);&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     update();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>
> >>>>>>> Please, don't invite users to start introducing explicit locks in
> >>>>>>> their applications! This brings us back to the times _before_
> >>>>>>> Orocos/RTT existed, and to the reasons _why_ it was developed: to
> >>>>>>> shield users from these ugly, low-level, error-prone OS
> >>>>>>> primitives. It is obvious that locks have _no_ place in a real
> >>>>>>> component based application, by definition almost.
> >>>>>>>
> >>>>>>> I am 100% sure Kurt's problem can be neatly solved with appropriate
> >>>>>>> design of his application using the core primitives of RTT, namely
> >>>>>>> Ports and simple Coordination with a state machine.
> >>>>>>>
> >>>>>>> In addition to providing good software, Orocos also has an
> >>>>>>> educational vocation, and that is to stimulate best practice
> >>>>>>> software engineering into the mechatronics and robotics
> >>>>>>> communities...
> >>>>>>
> >>>>>> True, but sometimes you need something to work first, before you
> >>>>>> make it correct. Peter's suggestion will fix his immediate needs
> >>>>>> _and_ we need to educate Kurt that this isn't the best approach and
> >>>>>> that he should consider doing it another way. S
> >>>>
> >>>> --
> >>>>
> >>>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research
> >>>> Group
> >>>>
> >>>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> >>>>
> >>>> EURON Coordinator (European Robotics Research
> >>>> Network)<http://www.euron.org> Open Realtime Control
> >>>> Services<http://www.orocos.org>
> >>>> Associate Editor JOSER<http://www.joser.org>,
> >>>> IJRR<http://www.ijrr.org>
> >>
> >> --
> >>
> >> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
> >>
> >> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> >>
> >> EURON Coordinator (European Robotics Research
> >> Network)<http://www.euron.org> Open Realtime Control
> >> Services<http://www.orocos.org>
> >> Associate Editor JOSER<http://www.joser.org>,
> >> IJRR<http://www.ijrr.org>
>
> --
> K.U.Leuven, Mechanical Eng., Mechatronics & Robotics Research Group
> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> EURON Coordinator (European Robotics Research Network)
> <http://www.euron.org> Open Realtime Control Services
> <http://www.orocos.org>
> Associate Editor JOSER <http://www.joser.org>, IJRR
> <http://www.ijrr.org>

--Boundary-01=_xgQROL2C+9IVlJ2
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Monospace'; font-size:9pt; font-weight:400; font-style:normal;">
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">On Monday 01 August 2011 11:26:28 Herman Bruyninckx wrote:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; On Mon, 1 Aug 2011, Kurt Geebelen wrote:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt; Op 1/08/2011 10:37, Herman Bruyninckx schreef:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; On Mon, 1 Aug 2011, Kurt Geebelen wrote:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; Op 1/08/2011 10:00, Herman Bruyninckx schreef:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; On Mon, 1 Aug 2011, Kurt Geebelen wrote:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; Hi,</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; (Please do not top post&lt;http://en.wikipedia.org/wiki/Top_posting&gt;)</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; Sorry</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; I have written a C+-class for the kalman filter, which has the 2</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; functions propagate and update (I didn't use the ExtendedKalmanFilter</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; class of the BLF-library because this way it was more clear to me</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; what was happening).</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; Oops... What is not clear with the way the BFL integrates an EKF into</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; Orocos?</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; E.g.&lt;http://comments.gmane.org/gmane.science.robotics.orocos.devel/845</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; 7&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; Nothing is wrong with it. I just thought it would be a better exercise</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; to implement it myself.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; That turns out to be true :-) There is no better schooling than to</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; repeat the errors one _has_ to make before being able to appreciate</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; better practice solutions :-)</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; The variables that are changed in both functions are the</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; covariance matrix and the state of the kalman filter. They are of</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; type Matrix of the Newmat library I am using</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; (http://www.robertnz.net/nm10.htm). The elements of these matrices</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; are of type double.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; My estimator component than creates an instance of this kalman filter</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; class, periodically propagates it (apply system model), and whenever</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; a measurement becomes available, updates the kalman filter with this</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; measurement. This is thus where it sometimes goes wrong, when these</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; functions coincide.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; Exactly. But they should not &quot;coincide&quot; :-) I mean, the component that</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; contains the (E)KF code should run the process update and measurement</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; update 'atomically', which could be realised by letting it read from</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; Data ports (one for new timer data, one for new measurement data).</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; I have the impression you have another design, in which you call an</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; operation on the EKF component from two other components, and in this</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; way it becomes very difficult for the EKF component to guarantee data</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; consistency...</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; Is my assumption about your architecture correct or not?</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; In other words, what _is_ the architecture of your complete system?</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; There is only one component communicating with the kalman filter,</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; namely the estimator component.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; Strange, since the Kalman Filter _is_ an estimator...</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; Note that the EKF is not a orocos-component,</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; but just a C++ class, on which the estimator-component is calling</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; functions.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; And where does the EKF class resides? It must be in some &quot;component&quot;,</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; isn't it?</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; I could integrate this code in the estimator component, but I</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; don't think this would change much?</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; I think it will change everything :-)</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; In the estimator component, in the updateHook, I thus do the process</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; update. The measurements are coming from another component, which puts</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; them on a Data port. My estimator component connects with this port,</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; and I have coupled an event to this port, which performs the</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt; measurement update with the data on this port.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; Fine! And what about the process update? Can't you do that in the same</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; way? (That is, via a time-triggered data port.)</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt; I can do that. But won't this still give the same problems when this</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt; coincides with the measurement update?</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; The component's TaskContext will 'serialize' the handling of the arrival of</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; data on the Ports. That's a major feature of RTT: no need to do locking</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; yourself anymore :-) The design problems are hence moved towards finding</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; the &quot;best&quot; component architecture and configuration of the individual</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; components.</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Indeed!</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">I have been working with filter-components for a long time and I suggest the following construction</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">* create an sysUpdate function and a measUpdate function</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">* run your component non periodically</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">* have the sysUpdate triggered periodically trough an eventPort triggered by a timer component</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">* have the measUpdate triggered by the measurement port.</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">You can find an example of such a component at http://git.mech.kuleuven.be/?p=robotics/camera_pose_estimation.git;a=sum...
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">If you need any extra explanation I will be glad to help you.</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">Tinne</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; And isn't your KF C++ class then &quot;running&quot; de facto inside of the</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; estimator component?</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt; Yes it is. That's why I thought moving it directly in the estimator</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt; component wouldn't change that much.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; You are not &quot;moving&quot; anything :-) The compiler links your library to the</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; code that is being deployed inside your estimator component, so it _is_</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; already there :-)</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; Herman</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt; Op 31/07/2011 20:13, S Roderick schreef:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt; On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; On Sun, 31 Jul 2011, Peter Soetens wrote:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;kurt [dot] geebelen [..] ...&gt; wrote:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Hi,</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; I have a component that is running a kalman filter, which has 2</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; main functions: propagate and update. I periodically propagate</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; my kalman filter, and I update my kalman filter event-driven</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; when data comes available on a port.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; I sometimes get a segmentation fault when running this component.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; I noticed that this is due to the problem that sometimes, while</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; my component is performing the propagation, new data becomes</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; available on a port, and the component will attempt to update</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; the kalman filter while performing the propagation. I tried</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; solving it by setting some booleans while doing the</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate/update. So something like this:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; For propagating:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;code&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;/code&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Change to:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;code&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; os::MutexLock lock(m);</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;/code&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; And for updating:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;code&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update();</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;/code&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; change to:</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;code&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; os::MutexLock lock(m);</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update();</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &lt;/code&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Please, don't invite users to start introducing explicit locks in</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; their applications! This brings us back to the times _before_</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Orocos/RTT existed, and to the reasons _why_ it was developed: to</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; shield users from these ugly, low-level, error-prone OS</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; primitives. It is obvious that locks have _no_ place in a real</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; component based application, by definition almost.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; I am 100% sure Kurt's problem can be neatly solved with appropriate</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; design of his application using the core primitives of RTT, namely</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; Ports and simple Coordination with a state machine.</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; In addition to providing good software, Orocos also has an</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; educational vocation, and that is to stimulate best practice</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; software engineering into the mechatronics and robotics</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt; communities...</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt; True, but sometimes you need something to work first, before you</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt; make it correct. Peter's suggestion will fix his immediate needs</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt; _and_ we need to educate Kurt that this isn't the best approach and</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt;&gt;&gt; that he should consider doing it another way. S</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; --</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; K.U.Leuven, Mechanical Eng., Mechatronics&amp; Robotics Research</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; Group</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; &lt;http://people.mech.kuleuven.be/~bruyninc&gt; Tel: +32 16 328056</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; EURON Coordinator (European Robotics Research</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; Network)&lt;http://www.euron.org&gt; Open Realtime Control</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; Services&lt;http://www.orocos.org&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; Associate Editor JOSER&lt;http://www.joser.org&gt;,</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt;&gt;&gt; IJRR&lt;http://www.ijrr.org&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; --</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; K.U.Leuven, Mechanical Eng., Mechatronics&amp; Robotics Research Group</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; &lt;http://people.mech.kuleuven.be/~bruyninc&gt; Tel: +32 16 328056</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; EURON Coordinator (European Robotics Research</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; Network)&lt;http://www.euron.org&gt; Open Realtime Control</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; Services&lt;http://www.orocos.org&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; Associate Editor JOSER&lt;http://www.joser.org&gt;,</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &gt;&gt; IJRR&lt;http://www.ijrr.org&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; </p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; --</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; K.U.Leuven, Mechanical Eng., Mechatronics &amp; Robotics Research Group</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &lt;http://people.mech.kuleuven.be/~bruyninc&gt; Tel: +32 16 328056</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; EURON Coordinator (European Robotics Research Network)</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &lt;http://www.euron.org&gt; Open Realtime Control Services</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &lt;http://www.orocos.org&gt;</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; Associate Editor JOSER &lt;http://www.joser.org&gt;, IJRR</p>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;">&gt; &lt;http://www.ijrr.org&gt;</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br /></p></body></html>
--Boundary-01=_xgQROL2C+9IVlJ2--

prevent function from executing when other is executing

On Monday 01 August 2011 11:26:28 Herman Bruyninckx wrote:
> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
> > Op 1/08/2011 10:37, Herman Bruyninckx schreef:
> >> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
> >>> Op 1/08/2011 10:00, Herman Bruyninckx schreef:
> >>>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
> >>>>> Hi,
> >>>>
> >>>> (Please do not top post<http://en.wikipedia.org/wiki/Top_posting>)
> >>>
> >>> Sorry
> >>>
> >>>>> I have written a C+-class for the kalman filter, which has the 2
> >>>>> functions propagate and update (I didn't use the ExtendedKalmanFilter
> >>>>> class of the BLF-library because this way it was more clear to me
> >>>>> what was happening).
> >>>>
> >>>> Oops... What is not clear with the way the BFL integrates an EKF into
> >>>> Orocos?
> >>>> E.g.<http://comments.gmane.org/gmane.science.robotics.orocos.devel/845
> >>>> 7>
> >>>
> >>> Nothing is wrong with it. I just thought it would be a better exercise
> >>> to implement it myself.
> >>
> >> That turns out to be true :-) There is no better schooling than to
> >> repeat the errors one _has_ to make before being able to appreciate
> >> better practice solutions :-)
> >>
> >>>>> The variables that are changed in both functions are the
> >>>>> covariance matrix and the state of the kalman filter. They are of
> >>>>> type Matrix of the Newmat library I am using
> >>>>> (http://www.robertnz.net/nm10.htm). The elements of these matrices
> >>>>> are of type double.
> >>>>>
> >>>>> My estimator component than creates an instance of this kalman filter
> >>>>> class, periodically propagates it (apply system model), and whenever
> >>>>> a measurement becomes available, updates the kalman filter with this
> >>>>> measurement. This is thus where it sometimes goes wrong, when these
> >>>>> functions coincide.
> >>>>
> >>>> Exactly. But they should not "coincide" :-) I mean, the component that
> >>>> contains the (E)KF code should run the process update and measurement
> >>>> update 'atomically', which could be realised by letting it read from
> >>>> Data ports (one for new timer data, one for new measurement data).
> >>>>
> >>>> I have the impression you have another design, in which you call an
> >>>> operation on the EKF component from two other components, and in this
> >>>> way it becomes very difficult for the EKF component to guarantee data
> >>>> consistency...
> >>>>
> >>>> Is my assumption about your architecture correct or not?
> >>>> In other words, what _is_ the architecture of your complete system?
> >>>
> >>> There is only one component communicating with the kalman filter,
> >>> namely the estimator component.
> >>
> >> Strange, since the Kalman Filter _is_ an estimator...
> >>
> >>> Note that the EKF is not a orocos-component,
> >>> but just a C++ class, on which the estimator-component is calling
> >>> functions.
> >>
> >> And where does the EKF class resides? It must be in some "component",
> >> isn't it?
> >>
> >>> I could integrate this code in the estimator component, but I
> >>> don't think this would change much?
> >>
> >> I think it will change everything :-)
> >>
> >>> In the estimator component, in the updateHook, I thus do the process
> >>> update. The measurements are coming from another component, which puts
> >>> them on a Data port. My estimator component connects with this port,
> >>> and I have coupled an event to this port, which performs the
> >>> measurement update with the data on this port.
> >>
> >> Fine! And what about the process update? Can't you do that in the same
> >> way? (That is, via a time-triggered data port.)
> >
> > I can do that. But won't this still give the same problems when this
> > coincides with the measurement update?
>
> The component's TaskContext will 'serialize' the handling of the arrival of
> data on the Ports. That's a major feature of RTT: no need to do locking
> yourself anymore :-) The design problems are hence moved towards finding
> the "best" component architecture and configuration of the individual
> components.

Indeed!

I have been working with filter-components for a long time and I suggest the
following construction
* create an sysUpdate function and a measUpdate function
* run your component non periodically
* have the sysUpdate triggered periodically trough an eventPort triggered by a
timer component
* have the measUpdate triggered by the measurement port.

You can find an example of such a component at
http://git.mech.kuleuven.be/?p=robotics/camera_pose_estimation.git;a=sum...

If you need any extra explanation I will be glad to help you.

Tinne

>
> >> And isn't your KF C++ class then "running" de facto inside of the
> >> estimator component?
> >
> > Yes it is. That's why I thought moving it directly in the estimator
> > component wouldn't change that much.
>
> You are not "moving" anything :-) The compiler links your library to the
> code that is being deployed inside your estimator component, so it _is_
> already there :-)
>
> Herman
>
> >>>>> Op 31/07/2011 20:13, S Roderick schreef:
> >>>>>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
> >>>>>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
> >>>>>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
> >>>>>>>>
> >>>>>>>> <kurt [dot] geebelen [..] ...> wrote:
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>> I have a component that is running a kalman filter, which has 2
> >>>>>>>>> main functions: propagate and update. I periodically propagate
> >>>>>>>>> my kalman filter, and I update my kalman filter event-driven
> >>>>>>>>> when data comes available on a port.
> >>>>>>>>>
> >>>>>>>>> I sometimes get a segmentation fault when running this component.
> >>>>>>>>> I noticed that this is due to the problem that sometimes, while
> >>>>>>>>> my component is performing the propagation, new data becomes
> >>>>>>>>> available on a port, and the component will attempt to update
> >>>>>>>>> the kalman filter while performing the propagation. I tried
> >>>>>>>>> solving it by setting some booleans while doing the
> >>>>>>>>> propagate/update. So something like this:
> >>>>>>>>>
> >>>>>>>>> For propagating:
> >>>>>>>>>
> >>>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>>
> >>>>>>>> Change to:
> >>>>>>>>
> >>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     os::MutexLock lock(m);&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     propagate();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>>
> >>>>>>>>> And for updating:
> >>>>>>>>>
> >>>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>>
> >>>>>>>> change to:
> >>>>>>>>
> >>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     os::MutexLock lock(m);&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     update();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>
> >>>>>>> Please, don't invite users to start introducing explicit locks in
> >>>>>>> their applications! This brings us back to the times _before_
> >>>>>>> Orocos/RTT existed, and to the reasons _why_ it was developed: to
> >>>>>>> shield users from these ugly, low-level, error-prone OS
> >>>>>>> primitives. It is obvious that locks have _no_ place in a real
> >>>>>>> component based application, by definition almost.
> >>>>>>>
> >>>>>>> I am 100% sure Kurt's problem can be neatly solved with appropriate
> >>>>>>> design of his application using the core primitives of RTT, namely
> >>>>>>> Ports and simple Coordination with a state machine.
> >>>>>>>
> >>>>>>> In addition to providing good software, Orocos also has an
> >>>>>>> educational vocation, and that is to stimulate best practice
> >>>>>>> software engineering into the mechatronics and robotics
> >>>>>>> communities...
> >>>>>>
> >>>>>> True, but sometimes you need something to work first, before you
> >>>>>> make it correct. Peter's suggestion will fix his immediate needs
> >>>>>> _and_ we need to educate Kurt that this isn't the best approach and
> >>>>>> that he should consider doing it another way. S
> >>>>
> >>>> --
> >>>>
> >>>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research
> >>>> Group
> >>>>
> >>>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> >>>>
> >>>> EURON Coordinator (European Robotics Research
> >>>> Network)<http://www.euron.org> Open Realtime Control
> >>>> Services<http://www.orocos.org>
> >>>> Associate Editor JOSER<http://www.joser.org>,
> >>>> IJRR<http://www.ijrr.org>
> >>
> >> --
> >>
> >> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
> >>
> >> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> >>
> >> EURON Coordinator (European Robotics Research
> >> Network)<http://www.euron.org> Open Realtime Control
> >> Services<http://www.orocos.org>
> >> Associate Editor JOSER<http://www.joser.org>,
> >> IJRR<http://www.ijrr.org>
>
> --
> K.U.Leuven, Mechanical Eng., Mechatronics & Robotics Research Group
> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> EURON Coordinator (European Robotics Research Network)
> <http://www.euron.org> Open Realtime Control Services
> <http://www.orocos.org>
> Associate Editor JOSER <http://www.joser.org>, IJRR
> <http://www.ijrr.org>

prevent function from executing when other is executing

On Monday 01 August 2011 11:26:28 Herman Bruyninckx wrote:
> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
> > Op 1/08/2011 10:37, Herman Bruyninckx schreef:
> >> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
> >>> Op 1/08/2011 10:00, Herman Bruyninckx schreef:
> >>>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
> >>>>> Hi,
> >>>>
> >>>> (Please do not top post<http://en.wikipedia.org/wiki/Top_posting>)
> >>>
> >>> Sorry
> >>>
> >>>>> I have written a C+-class for the kalman filter, which has the 2
> >>>>> functions propagate and update (I didn't use the ExtendedKalmanFilter
> >>>>> class of the BLF-library because this way it was more clear to me
> >>>>> what was happening).
> >>>>
> >>>> Oops... What is not clear with the way the BFL integrates an EKF into
> >>>> Orocos?
> >>>> E.g.<http://comments.gmane.org/gmane.science.robotics.orocos.devel/845
> >>>> 7>
> >>>
> >>> Nothing is wrong with it. I just thought it would be a better exercise
> >>> to implement it myself.
> >>
> >> That turns out to be true :-) There is no better schooling than to
> >> repeat the errors one _has_ to make before being able to appreciate
> >> better practice solutions :-)
> >>
> >>>>> The variables that are changed in both functions are the
> >>>>> covariance matrix and the state of the kalman filter. They are of
> >>>>> type Matrix of the Newmat library I am using
> >>>>> (http://www.robertnz.net/nm10.htm). The elements of these matrices
> >>>>> are of type double.
> >>>>>
> >>>>> My estimator component than creates an instance of this kalman filter
> >>>>> class, periodically propagates it (apply system model), and whenever
> >>>>> a measurement becomes available, updates the kalman filter with this
> >>>>> measurement. This is thus where it sometimes goes wrong, when these
> >>>>> functions coincide.
> >>>>
> >>>> Exactly. But they should not "coincide" :-) I mean, the component that
> >>>> contains the (E)KF code should run the process update and measurement
> >>>> update 'atomically', which could be realised by letting it read from
> >>>> Data ports (one for new timer data, one for new measurement data).
> >>>>
> >>>> I have the impression you have another design, in which you call an
> >>>> operation on the EKF component from two other components, and in this
> >>>> way it becomes very difficult for the EKF component to guarantee data
> >>>> consistency...
> >>>>
> >>>> Is my assumption about your architecture correct or not?
> >>>> In other words, what _is_ the architecture of your complete system?
> >>>
> >>> There is only one component communicating with the kalman filter,
> >>> namely the estimator component.
> >>
> >> Strange, since the Kalman Filter _is_ an estimator...
> >>
> >>> Note that the EKF is not a orocos-component,
> >>> but just a C++ class, on which the estimator-component is calling
> >>> functions.
> >>
> >> And where does the EKF class resides? It must be in some "component",
> >> isn't it?
> >>
> >>> I could integrate this code in the estimator component, but I
> >>> don't think this would change much?
> >>
> >> I think it will change everything :-)
> >>
> >>> In the estimator component, in the updateHook, I thus do the process
> >>> update. The measurements are coming from another component, which puts
> >>> them on a Data port. My estimator component connects with this port,
> >>> and I have coupled an event to this port, which performs the
> >>> measurement update with the data on this port.
> >>
> >> Fine! And what about the process update? Can't you do that in the same
> >> way? (That is, via a time-triggered data port.)
> >
> > I can do that. But won't this still give the same problems when this
> > coincides with the measurement update?
>
> The component's TaskContext will 'serialize' the handling of the arrival of
> data on the Ports. That's a major feature of RTT: no need to do locking
> yourself anymore :-) The design problems are hence moved towards finding
> the "best" component architecture and configuration of the individual
> components.

Indeed!

I have been working with filter-components for a long time and I suggest the
following construction
* create an sysUpdate function and a measUpdate function
* run your component non periodically
* have the sysUpdate triggered periodically trough an eventPort triggered by a
timer component
* have the measUpdate triggered by the measurement port.

You can find an example of such a component at
http://git.mech.kuleuven.be/?p=robotics/camera_pose_estimation.git;a=sum...

If you need any extra explanation I will be glad to help you.

Tinne

>
> >> And isn't your KF C++ class then "running" de facto inside of the
> >> estimator component?
> >
> > Yes it is. That's why I thought moving it directly in the estimator
> > component wouldn't change that much.
>
> You are not "moving" anything :-) The compiler links your library to the
> code that is being deployed inside your estimator component, so it _is_
> already there :-)
>
> Herman
>
> >>>>> Op 31/07/2011 20:13, S Roderick schreef:
> >>>>>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
> >>>>>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
> >>>>>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
> >>>>>>>>
> >>>>>>>> <kurt [dot] geebelen [..] ...> wrote:
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>> I have a component that is running a kalman filter, which has 2
> >>>>>>>>> main functions: propagate and update. I periodically propagate
> >>>>>>>>> my kalman filter, and I update my kalman filter event-driven
> >>>>>>>>> when data comes available on a port.
> >>>>>>>>>
> >>>>>>>>> I sometimes get a segmentation fault when running this component.
> >>>>>>>>> I noticed that this is due to the problem that sometimes, while
> >>>>>>>>> my component is performing the propagation, new data becomes
> >>>>>>>>> available on a port, and the component will attempt to update
> >>>>>>>>> the kalman filter while performing the propagation. I tried
> >>>>>>>>> solving it by setting some booleans while doing the
> >>>>>>>>> propagate/update. So something like this:
> >>>>>>>>>
> >>>>>>>>> For propagating:
> >>>>>>>>>
> >>>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>>
> >>>>>>>> Change to:
> >>>>>>>>
> >>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     os::MutexLock lock(m);&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     propagate();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>>
> >>>>>>>>> And for updating:
> >>>>>>>>>
> >>>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>>
> >>>>>>>> change to:
> >>>>>>>>
> >>>>>>>> &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     os::MutexLock lock(m);&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;     update();&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; &#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt; &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
> >>>>>>>
> >>>>>>> Please, don't invite users to start introducing explicit locks in
> >>>>>>> their applications! This brings us back to the times _before_
> >>>>>>> Orocos/RTT existed, and to the reasons _why_ it was developed: to
> >>>>>>> shield users from these ugly, low-level, error-prone OS
> >>>>>>> primitives. It is obvious that locks have _no_ place in a real
> >>>>>>> component based application, by definition almost.
> >>>>>>>
> >>>>>>> I am 100% sure Kurt's problem can be neatly solved with appropriate
> >>>>>>> design of his application using the core primitives of RTT, namely
> >>>>>>> Ports and simple Coordination with a state machine.
> >>>>>>>
> >>>>>>> In addition to providing good software, Orocos also has an
> >>>>>>> educational vocation, and that is to stimulate best practice
> >>>>>>> software engineering into the mechatronics and robotics
> >>>>>>> communities...
> >>>>>>
> >>>>>> True, but sometimes you need something to work first, before you
> >>>>>> make it correct. Peter's suggestion will fix his immediate needs
> >>>>>> _and_ we need to educate Kurt that this isn't the best approach and
> >>>>>> that he should consider doing it another way. S
> >>>>
> >>>> --
> >>>>
> >>>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research
> >>>> Group
> >>>>
> >>>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> >>>>
> >>>> EURON Coordinator (European Robotics Research
> >>>> Network)<http://www.euron.org> Open Realtime Control
> >>>> Services<http://www.orocos.org>
> >>>> Associate Editor JOSER<http://www.joser.org>,
> >>>> IJRR<http://www.ijrr.org>
> >>
> >> --
> >>
> >> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
> >>
> >> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> >>
> >> EURON Coordinator (European Robotics Research
> >> Network)<http://www.euron.org> Open Realtime Control
> >> Services<http://www.orocos.org>
> >> Associate Editor JOSER<http://www.joser.org>,
> >> IJRR<http://www.ijrr.org>
>
> --
> K.U.Leuven, Mechanical Eng., Mechatronics & Robotics Research Group
> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> EURON Coordinator (European Robotics Research Network)
> <http://www.euron.org> Open Realtime Control Services
> <http://www.orocos.org>
> Associate Editor JOSER <http://www.joser.org>, IJRR
> <http://www.ijrr.org>

prevent function from executing when other is executing

Op 1/08/2011 11:26, Herman Bruyninckx schreef:
> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>
>> Op 1/08/2011 10:37, Herman Bruyninckx schreef:
>>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>>>
>>>> Op 1/08/2011 10:00, Herman Bruyninckx schreef:
>>>>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>>>>>
>>>>>> Hi,
>>>>> (Please do not top post<http://en.wikipedia.org/wiki/Top_posting>)
>>>> Sorry
>>>>
>>>>>> I have written a C+-class for the kalman filter, which has the 2
>>>>>> functions propagate and update (I didn't use the ExtendedKalmanFilter
>>>>>> class of the BLF-library because this way it was more clear to me what
>>>>>> was happening).
>>>>> Oops... What is not clear with the way the BFL integrates an EKF into
>>>>> Orocos?
>>>>> E.g.<http://comments.gmane.org/gmane.science.robotics.orocos.devel/8457>
>>>> Nothing is wrong with it. I just thought it would be a better exercise
>>>> to implement it myself.
>>> That turns out to be true :-) There is no better schooling than to repeat
>>> the errors one _has_ to make before being able to appreciate better
>>> practice solutions :-)
>>>
>>>>>> The variables that are changed in both functions are the
>>>>>> covariance matrix and the state of the kalman filter. They are of type
>>>>>> Matrix of the Newmat library I am using
>>>>>> (http://www.robertnz.net/nm10.htm). The elements of these matrices are
>>>>>> of type double.
>>>>>>
>>>>>> My estimator component than creates an instance of this kalman filter
>>>>>> class, periodically propagates it (apply system model), and whenever a
>>>>>> measurement becomes available, updates the kalman filter with this
>>>>>> measurement. This is thus where it sometimes goes wrong, when these
>>>>>> functions coincide.
>>>>> Exactly. But they should not "coincide" :-) I mean, the component that
>>>>> contains the (E)KF code should run the process update and measurement
>>>>> update 'atomically', which could be realised by letting it read from Data
>>>>> ports (one for new timer data, one for new measurement data).
>>>>>
>>>>> I have the impression you have another design, in which you call an
>>>>> operation on the EKF component from two other components, and in this way
>>>>> it becomes very difficult for the EKF component to guarantee data
>>>>> consistency...
>>>>>
>>>>> Is my assumption about your architecture correct or not?
>>>>> In other words, what _is_ the architecture of your complete system?
>>>> There is only one component communicating with the kalman filter, namely
>>>> the estimator component.
>>> Strange, since the Kalman Filter _is_ an estimator...
>>>
>>>> Note that the EKF is not a orocos-component,
>>>> but just a C++ class, on which the estimator-component is calling
>>>> functions.
>>> And where does the EKF class resides? It must be in some "component", isn't
>>> it?
>>>
>>>> I could integrate this code in the estimator component, but I
>>>> don't think this would change much?
>>> I think it will change everything :-)
>>>
>>>> In the estimator component, in the updateHook, I thus do the process
>>>> update. The measurements are coming from another component, which puts
>>>> them on a Data port. My estimator component connects with this port, and
>>>> I have coupled an event to this port, which performs the measurement
>>>> update with the data on this port.
>>> Fine! And what about the process update? Can't you do that in the same way?
>>> (That is, via a time-triggered data port.)
>> I can do that. But won't this still give the same problems when this
>> coincides with the measurement update?
> The component's TaskContext will 'serialize' the handling of the arrival of
> data on the Ports. That's a major feature of RTT: no need to do locking
> yourself anymore :-) The design problems are hence moved towards finding
> the "best" component architecture and configuration of the individual
> components.

Ok, I will try that than.

Thanks!
Kurt

>
>>> And isn't your KF C++ class then "running" de facto inside of the estimator
>>> component?
>> Yes it is. That's why I thought moving it directly in the estimator
>> component wouldn't change that much.
> You are not "moving" anything :-) The compiler links your library to the
> code that is being deployed inside your estimator component, so it _is_
> already there :-)
>
> Herman
>
>>>>>> Op 31/07/2011 20:13, S Roderick schreef:
>>>>>>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
>>>>>>>
>>>>>>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
>>>>>>>>
>>>>>>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
>>>>>>>>> <kurt [dot] geebelen [..] ...> wrote:
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> I have a component that is running a kalman filter, which has 2 main
>>>>>>>>>> functions: propagate and update. I periodically propagate my kalman
>>>>>>>>>> filter, and I update my kalman filter event-driven when data comes
>>>>>>>>>> available on a port.
>>>>>>>>>>
>>>>>>>>>> I sometimes get a segmentation fault when running this component. I
>>>>>>>>>> noticed that this is due to the problem that sometimes, while my
>>>>>>>>>> component is performing the propagation, new data becomes available on a
>>>>>>>>>> port, and the component will attempt to update the kalman filter while
>>>>>>>>>> performing the propagation. I tried solving it by setting some booleans
>>>>>>>>>> while doing the propagate/update. So something like this:
>>>>>>>>>>
>>>>>>>>>> For propagating:
>>>>>>>>>>
>>>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>>> Change to:
>>>>>>>>>
>>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;      os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;      propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>>>
>>>>>>>>>> And for updating:
>>>>>>>>>>
>>>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>>> change to:
>>>>>>>>>
>>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;      os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;      update();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>>>
>>>>>>>> Please, don't invite users to start introducing explicit locks in their
>>>>>>>> applications! This brings us back to the times _before_ Orocos/RTT existed,
>>>>>>>> and to the reasons _why_ it was developed: to shield users from these ugly,
>>>>>>>> low-level, error-prone OS primitives. It is obvious that locks have _no_
>>>>>>>> place in a real component based application, by definition almost.
>>>>>>>>
>>>>>>>> I am 100% sure Kurt's problem can be neatly solved with appropriate design
>>>>>>>> of his application using the core primitives of RTT, namely Ports and
>>>>>>>> simple Coordination with a state machine.
>>>>>>>>
>>>>>>>> In addition to providing good software, Orocos also has an educational
>>>>>>>> vocation, and that is to stimulate best practice software engineering into
>>>>>>>> the mechatronics and robotics communities...
>>>>>>> True, but sometimes you need something to work first, before you make it correct. Peter's suggestion will fix his immediate needs _and_ we need to educate Kurt that this isn't the best approach and that he should consider doing it another way.
>>>>>>> S
>>>>>>>
>>>>> --
>>>>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
>>>>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
>>>>> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
>>>>> Open Realtime Control Services<http://www.orocos.org>
>>>>> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>
>>> --
>>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
>>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
>>> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
>>> Open Realtime Control Services<http://www.orocos.org>
>>> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>
> --
> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
> Open Realtime Control Services<http://www.orocos.org>
> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>

prevent function from executing when other is executing

On Mon, 1 Aug 2011, Kurt Geebelen wrote:

>
>
> Op 1/08/2011 11:26, Herman Bruyninckx schreef:
>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>>
>>> Op 1/08/2011 10:37, Herman Bruyninckx schreef:
>>>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>>>>
>>>>> Op 1/08/2011 10:00, Herman Bruyninckx schreef:
>>>>>> On Mon, 1 Aug 2011, Kurt Geebelen wrote:
>>>>>>
>>>>>>> Hi,
>>>>>> (Please do not top post<http://en.wikipedia.org/wiki/Top_posting>)
>>>>> Sorry
>>>>>
>>>>>>> I have written a C+-class for the kalman filter, which has the 2
>>>>>>> functions propagate and update (I didn't use the ExtendedKalmanFilter
>>>>>>> class of the BLF-library because this way it was more clear to me what
>>>>>>> was happening).
>>>>>> Oops... What is not clear with the way the BFL integrates an EKF into
>>>>>> Orocos?
>>>>>> E.g.<http://comments.gmane.org/gmane.science.robotics.orocos.devel/8457>
>>>>> Nothing is wrong with it. I just thought it would be a better exercise
>>>>> to implement it myself.
>>>> That turns out to be true :-) There is no better schooling than to repeat
>>>> the errors one _has_ to make before being able to appreciate better
>>>> practice solutions :-)
>>>>
>>>>>>> The variables that are changed in both functions are the
>>>>>>> covariance matrix and the state of the kalman filter. They are of type
>>>>>>> Matrix of the Newmat library I am using
>>>>>>> (http://www.robertnz.net/nm10.htm). The elements of these matrices are
>>>>>>> of type double.
>>>>>>>
>>>>>>> My estimator component than creates an instance of this kalman filter
>>>>>>> class, periodically propagates it (apply system model), and whenever a
>>>>>>> measurement becomes available, updates the kalman filter with this
>>>>>>> measurement. This is thus where it sometimes goes wrong, when these
>>>>>>> functions coincide.
>>>>>> Exactly. But they should not "coincide" :-) I mean, the component that
>>>>>> contains the (E)KF code should run the process update and measurement
>>>>>> update 'atomically', which could be realised by letting it read from Data
>>>>>> ports (one for new timer data, one for new measurement data).
>>>>>>
>>>>>> I have the impression you have another design, in which you call an
>>>>>> operation on the EKF component from two other components, and in this way
>>>>>> it becomes very difficult for the EKF component to guarantee data
>>>>>> consistency...
>>>>>>
>>>>>> Is my assumption about your architecture correct or not?
>>>>>> In other words, what _is_ the architecture of your complete system?
>>>>> There is only one component communicating with the kalman filter, namely
>>>>> the estimator component.
>>>> Strange, since the Kalman Filter _is_ an estimator...
>>>>
>>>>> Note that the EKF is not a orocos-component,
>>>>> but just a C++ class, on which the estimator-component is calling
>>>>> functions.
>>>> And where does the EKF class resides? It must be in some "component", isn't
>>>> it?
>>>>
>>>>> I could integrate this code in the estimator component, but I
>>>>> don't think this would change much?
>>>> I think it will change everything :-)
>>>>
>>>>> In the estimator component, in the updateHook, I thus do the process
>>>>> update. The measurements are coming from another component, which puts
>>>>> them on a Data port. My estimator component connects with this port, and
>>>>> I have coupled an event to this port, which performs the measurement
>>>>> update with the data on this port.
>>>> Fine! And what about the process update? Can't you do that in the same way?
>>>> (That is, via a time-triggered data port.)
>>> I can do that. But won't this still give the same problems when this
>>> coincides with the measurement update?
>> The component's TaskContext will 'serialize' the handling of the arrival of
>> data on the Ports. That's a major feature of RTT: no need to do locking
>> yourself anymore :-) The design problems are hence moved towards finding
>> the "best" component architecture and configuration of the individual
>> components.
>
> Ok, I will try that than.

Good! Keep the list informed, since your use case fits perfectly in the
scope of the newly started "Orocos Conrol Box"
<http://people.mech.kuleuven.be/~bruyninc/controltoolbox/>
Dirk Pirard started on the project today. Since both of you are rather
closely stationed together (the same building :-)) please feel free to
discuss the matter with him, and to "outsource" some coding maybe...

> Thanks!
You're welcome!

> Kurt

Herman

>>>> And isn't your KF C++ class then "running" de facto inside of the estimator
>>>> component?
>>> Yes it is. That's why I thought moving it directly in the estimator
>>> component wouldn't change that much.
>> You are not "moving" anything :-) The compiler links your library to the
>> code that is being deployed inside your estimator component, so it _is_
>> already there :-)
>>
>> Herman
>>
>>>>>>> Op 31/07/2011 20:13, S Roderick schreef:
>>>>>>>> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
>>>>>>>>
>>>>>>>>> On Sun, 31 Jul 2011, Peter Soetens wrote:
>>>>>>>>>
>>>>>>>>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
>>>>>>>>>> <kurt [dot] geebelen [..] ...> wrote:
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> I have a component that is running a kalman filter, which has 2 main
>>>>>>>>>>> functions: propagate and update. I periodically propagate my kalman
>>>>>>>>>>> filter, and I update my kalman filter event-driven when data comes
>>>>>>>>>>> available on a port.
>>>>>>>>>>>
>>>>>>>>>>> I sometimes get a segmentation fault when running this component. I
>>>>>>>>>>> noticed that this is due to the problem that sometimes, while my
>>>>>>>>>>> component is performing the propagation, new data becomes available on a
>>>>>>>>>>> port, and the component will attempt to update the kalman filter while
>>>>>>>>>>> performing the propagation. I tried solving it by setting some booleans
>>>>>>>>>>> while doing the propagate/update. So something like this:
>>>>>>>>>>>
>>>>>>>>>>> For propagating:
>>>>>>>>>>>
>>>>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>>>> Change to:
>>>>>>>>>>
>>>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;      os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;      propagate();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>>>>
>>>>>>>>>>> And for updating:
>>>>>>>>>>>
>>>>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=true;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; update();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; updating=false;&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>>>> change to:
>>>>>>>>>>
>>>>>>>>>> &#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;      os::MutexLock lock(m);&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;      update();&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;
>>>>>>>>>>
>>>>>>>>> Please, don't invite users to start introducing explicit locks in their
>>>>>>>>> applications! This brings us back to the times _before_ Orocos/RTT existed,
>>>>>>>>> and to the reasons _why_ it was developed: to shield users from these ugly,
>>>>>>>>> low-level, error-prone OS primitives. It is obvious that locks have _no_
>>>>>>>>> place in a real component based application, by definition almost.
>>>>>>>>>
>>>>>>>>> I am 100% sure Kurt's problem can be neatly solved with appropriate design
>>>>>>>>> of his application using the core primitives of RTT, namely Ports and
>>>>>>>>> simple Coordination with a state machine.
>>>>>>>>>
>>>>>>>>> In addition to providing good software, Orocos also has an educational
>>>>>>>>> vocation, and that is to stimulate best practice software engineering into
>>>>>>>>> the mechatronics and robotics communities...
>>>>>>>> True, but sometimes you need something to work first, before you make it correct. Peter's suggestion will fix his immediate needs _and_ we need to educate Kurt that this isn't the best approach and that he should consider doing it another way.
>>>>>>>> S
>>>>>>>>
>>>>>> --
>>>>>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
>>>>>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
>>>>>> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
>>>>>> Open Realtime Control Services<http://www.orocos.org>
>>>>>> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>
>>>> --
>>>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
>>>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
>>>> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
>>>> Open Realtime Control Services<http://www.orocos.org>
>>>> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>
>> --
>> K.U.Leuven, Mechanical Eng., Mechatronics& Robotics Research Group
>> <http://people.mech.kuleuven.be/~bruyninc> Tel: +32 16 328056
>> EURON Coordinator (European Robotics Research Network)<http://www.euron.org>
>> Open Realtime Control Services<http://www.orocos.org>
>> Associate Editor JOSER<http://www.joser.org>, IJRR<http://www.ijrr.org>
>

prevent function from executing when other is executing

On Sun, 31 Jul 2011, S Roderick wrote:

> On Jul 31, 2011, at 07:47 , Herman Bruyninckx wrote:
>
>> On Sun, 31 Jul 2011, Peter Soetens wrote:
>>
>>> On Fri, Jul 29, 2011 at 4:15 PM, Kurt Geebelen
>>> <kurt [dot] geebelen [..] ...> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have a component that is running a kalman filter, which has 2 main
>>>> functions: propagate and update. I periodically propagate my kalman
>>>> filter, and I update my kalman filter event-driven when data comes
>>>> available on a port.
>>>>
>>>> I sometimes get a segmentation fault when running this component. I
>>>> noticed that this is due to the problem that sometimes, while my
>>>> component is performing the propagation, new data becomes available on a
>>>> port, and the component will attempt to update the kalman filter while
>>>> performing the propagation. I tried solving it by setting some booleans
>>>> while doing the propagate/update. So something like this:
>>>>
>>>> For propagating:
>>>>
>>>> &#10;&gt;&gt;&gt;&gt; while(updating){}&#10;&gt;&gt;&gt;&gt; propagating=true;&#10;&gt;&gt;&gt;&gt; propagate();&#10;&gt;&gt;&gt;&gt; propagating=false;&#10;&gt;&gt;&gt;&gt;
>>>
>>> Change to:
>>>
>>> &#10;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;  os::MutexLock lock(m);&#10;&gt;&gt;&gt;  propagate();&#10;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;
>>>
>>>>
>>>> And for updating:
>>>>
>>>> &#10;&gt;&gt;&gt;&gt; while(propagating){}&#10;&gt;&gt;&gt;&gt; updating=true;&#10;&gt;&gt;&gt;&gt; update();&#10;&gt;&gt;&gt;&gt; updating=false;&#10;&gt;&gt;&gt;&gt;
>>>
>>> change to:
>>>
>>> &#10;&gt;&gt;&gt; {&#10;&gt;&gt;&gt;  os::MutexLock lock(m);&#10;&gt;&gt;&gt;  update();&#10;&gt;&gt;&gt; } // note these curly braces, they must be here !&#10;&gt;&gt;&gt;
>>>
>>
>> Please, don't invite users to start introducing explicit locks in their
>> applications! This brings us back to the times _before_ Orocos/RTT existed,
>> and to the reasons _why_ it was developed: to shield users from these ugly,
>> low-level, error-prone OS primitives. It is obvious that locks have _no_
>> place in a real component based application, by definition almost.
>>
>> I am 100% sure Kurt's problem can be neatly solved with appropriate design
>> of his application using the core primitives of RTT, namely Ports and
>> simple Coordination with a state machine.
>>
>> In addition to providing good software, Orocos also has an educational
>> vocation, and that is to stimulate best practice software engineering into
>> the mechatronics and robotics communities...
>
> True, but sometimes you need something to work first, before you make it correct. Peter's suggestion will fix his immediate needs _and_ we need to educate Kurt that this isn't the best approach and that he should consider doing it another way.

You've become too compassionate! :-) But of course you are right. Good
textbook like documentation about how to best develop component-based
applications is very much needed. It's on the agenda of the BRICS project
for the coming year, so please hold your breath :-)

> S

Herman

prevent function from executing when other is executing

On Fri, 29 Jul 2011, Kurt Geebelen wrote:

> Hi,
>
> I have a component that is running a kalman filter, which has 2 main
> functions: propagate and update. I periodically propagate my kalman
> filter, and I update my kalman filter event-driven when data comes
> available on a port.
>
> I sometimes get a segmentation fault when running this component. I
> noticed that this is due to the problem that sometimes, while my
> component is performing the propagation, new data becomes available on a
> port, and the component will attempt to update the kalman filter while
> performing the propagation. I tried solving it by setting some booleans
> while doing the propagate/update. So something like this:
>
> For propagating:
>
> &#10;&gt; while(updating){}&#10;&gt; propagating=true;&#10;&gt; propagate();&#10;&gt; propagating=false;&#10;&gt;
>
> And for updating:
>
> &#10;&gt; while(propagating){}&#10;&gt; updating=true;&#10;&gt; update();&#10;&gt; updating=false;&#10;&gt;
>
> But this didn't completely solve the issue.
> Is there a better solution to prevent one function from executing while
> the other is executing, and vise versa?

Oops! This is _definitely_ not the way to go! I mean, you are reinventing
bad practice of low level "locking" between different activities in which
each activity uses knowledge about what the other is doing; and that is
"Bad" :-)

In order to be able to explain a "better" practice, you should give a bit
more information about the overall structure of our application: what
activities do you _have_ to run concurrently? which data do you _have_ to
exchange between concurrent activities?

Herman

prevent function from executing when other is executing

Isn't it a mutex job ? If think both event are trigger simustaneously while
they are sharing a common ressource.

If think a nice solution in Orocos is to register the updatingRequest or the
propagatingRequest during the event handler (in a attribute for example ?),
and then in the updateHook do the stuff you have to do relating to the
attributes value. You still have a priority to choose between the 2, but you
are sure they won't be executed at the same time. It's a matter of
decoupling between event trigeers and event managing but others will explain
it by far better than I could :)

2011/7/29 Kurt Geebelen <kurt [dot] geebelen [..] ...>

> Hi,
>
> I have a component that is running a kalman filter, which has 2 main
> functions: propagate and update. I periodically propagate my kalman
> filter, and I update my kalman filter event-driven when data comes
> available on a port.
>
> I sometimes get a segmentation fault when running this component. I
> noticed that this is due to the problem that sometimes, while my
> component is performing the propagation, new data becomes available on a
> port, and the component will attempt to update the kalman filter while
> performing the propagation. I tried solving it by setting some booleans
> while doing the propagate/update. So something like this:
>
> For propagating:
>
> &#10;&gt; while(updating){}&#10;&gt; propagating=true;&#10;&gt; propagate();&#10;&gt; propagating=false;&#10;&gt;
>
> And for updating:
>
> &#10;&gt; while(propagating){}&#10;&gt; updating=true;&#10;&gt; update();&#10;&gt; updating=false;&#10;&gt;
>
> But this didn't completely solve the issue.
> Is there a better solution to prevent one function from executing while
> the other is executing, and vise versa?
>
> Kurt
> --
> Orocos-Users mailing list
> Orocos-Users [..] ...
> http://lists.mech.kuleuven.be/mailman/listinfo/orocos-users
>