[Bug 479] New: Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

           Summary: Some filters will break real-time
           Product: BFL
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: blocker
          Priority: P1
         Component: core
        AssignedTo: bfl [..] 
        ReportedBy: klaas gadeyne [..] 
                CC: bfl [..] 
   Estimated Hours: 0.0

HistogramFilter::SysUpdate(SystemModel<int>* const sysmodel, const int& u)

  {

...

    vector<Probability> old_prob = ( (DiscretePdf*)_post )->ProbabilitiesGet();
    vector<Probability> new_prob(num_states);

...

  }

If I'm not mistaken, this will lead to allocations on the heap and make the
historgram filter unsuited for use in real-time applications.
I noticed similar code in the MeasUpdate function of HistogramFilter and the
KalmanFilter code also seems to suffer from a similar issue:

  void
  KalmanFilter::CalculateSysUpdate(ColumnVector J, Matrix F, SymmetricMatrix Q)
  {

...

    Matrix temp = F * (Matrix)_post->CovarianceGet() * F.transpose() +

(Matrix)Q;

    SymmetricMatrix Sigma_new(_post->DimensionGet());

...

  }

Idem dito for the IEKF code and the SRIEKF. Particle Filter code seems to be
fine. I guess people@PMA should have noticed this when using this filters
under LXRT?

Damned, I should have noticed this long ago :-(

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #1 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-08 19:36:31 ---

(In reply to comment #0)
> HistogramFilter::SysUpdate(SystemModel<int>* const sysmodel, const int& u)
> {
> ...
> vector<Probability> old_prob = ( (DiscretePdf*)_post )->ProbabilitiesGet();
> vector<Probability> new_prob(num_states);
> ...
> }
>
> If I'm not mistaken, this will lead to allocations on the heap and make the
> historgram filter unsuited for use in real-time applications.

It appears I am not mistaken. Consider the following example

kgad@ampere /tmpTeX Embedding failed!

 cat main_efficient.cpp
  1. include <vector>
  1. define NUM_TRIES 10
  2. define SIZE 1000

int main()
{

  std::vector<double> a(SIZE,1.0);
  std::vector<double> b(SIZE);
  for (int i=0; i< NUM_TRIES; i++)
    {
      b[1]=2.0;
      b=a;
    }
  return 0;

}

When performing some heap profiling action using valgrind's massif
tool on these executables, e.g.

valgrind --tool=massif --time-unit=B ./a.out

and then print some result using ms_print, we get the following chart
for the "naive" implementation

    KB

15.64^ # : : : : @ : : : :

     |   #      :       :      :      :      @      :       :      :      :
     |   #      :       :      :      :      @      :       :      :      :
     |   #      :       :      :      :      @      :       :      :      :
     |   #      :       :      :      :      @      :       :      :      :
     |   #      :       :      :      :      @      :       :      :      :
     |   #      :       :      :      :      @      :       :      :      :
     |   #      :       :      :      :      @      :       :      :      :
     |   #      :       :      :      :      @      :       :      :      :
     |   #      :       :      :      :      @      :       :      :      :
     | : # :   :: :   : ::   : : :  : : :  : @ :   :: :   : ::   : : :  : : :
     | : # :   :: :   : ::   : : :  : : :  : @ :   :: :   : ::   : : :  : : :
     | : # :   :: :   : ::   : : :  : : :  : @ :   :: :   : ::   : : :  : : :
     | : # :   :: :   : ::   : : :  : : :  : @ :   :: :   : ::   : : :  : : :
     | : # :   :: :   : ::   : : :  : : :  : @ :   :: :   : ::   : : :  : : :
     | : # :   :: :   : ::   : : :  : : :  : @ :   :: :   : ::   : : :  : : :
     | : # :   :: :   : ::   : : :  : : :  : @ :   :: :   : ::   : : :  : : :
     | : # :   :: :   : ::   : : :  : : :  : @ :   :: :   : ::   : : :  : : :
     | : # :   :: :   : ::   : : :  : : :  : @ :   :: :   : ::   : : :  : : :
     | : # :   :: :   : ::   : : :  : : :  : @ :   :: :   : ::   : : :  : : :
   0
+----------------------------------------------------------------------->KB
     0                                                                   312.8

You can consider the x-axis to be some kind of "time", and the y-axis the heap
size. You can see very nicely that the allocation happens every time in the
for loop (10 times).

the following plot is produced for the "efficient" main

    KB

15.64^ #

     |                                    #
     |                                    #
     |                                    #
     |                                    #
     |                                    #
     |                                    #
     |                                    #
     |                                    #
     |                                    #
     |                  :                 #                 :
     |                  :                 #                 :
     |                  :                 #                 :
     |                  :                 #                 :
     |                  :                 #                 :
     |                  :                 #                 :
     |                  :                 #                 :
     |                  :                 #                 :
     |                  :                 #                 :
     |                  :                 #                 :
   0
+----------------------------------------------------------------------->KB
     0                                                                   31.28

I hope bugzilla doesn't mangle this ascii art...

Increasing the defines in both programs also shows the performancy decrease.

regards,

Klaas

Ps. Unfortunately, AFAIK valgrind does not yet work for xenomai or
lxrt :-(

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
   Target Milestone|---                         |0.6.2
--- Comment #2 from Tinne De Laet <tinne delaet [..] >  2008-01-09 17:14:33 ---

I accept this bug, but any help is welcome of course.
I will propose patches for all filters/pdf seperately to prevent an unreadable
patch-file.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #3 from Tinne De Laet <tinne delaet [..] >  2008-01-09 17:20:36 ---

Created an attachment (id=183)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=183)

Patch to solve allocation issues for EKparticlefilter

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #4 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-09 17:42:52 ---

(In reply to comment #3)
> Created an attachment (id=183)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=183) details

> Patch to solve allocation issues for EKparticlefilter

Source code wise, I think this solves some issues, but not all of them. Since
this is a particle filter involving a KF step, I think you should also
_preallocate_ the matrices, and not only the lists, e.g. in the constructor
instead of just
doing

  _sampleCov.resize(prior->NumSamplesGet());    

you should add something like (note: this is only pseudo code)

   _cov_it = _sampleCov.begin();
   while (_cov_it != _sampleCov.end())
   {
      (*_cov_it).resize(this->StateSizeGet());
   }

For the rest, this seems fine. However, when running make check, I get a nasty
error

  • glibc detected ***

/home/kgad/SVN/bfl-trunk/build-boost/tests/test_complete_filter: corrupted
double-linked list: 0x080c5bb8 ***
======= Backtrace: =========
/lib/i686/cmov/libc.so.60x40340df9
/lib/i686/cmov/libc.so.60x4034253e
/lib/i686/cmov/libc.so.6(cfree+0x90)0x403461a0
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)0x40271e41
/home/kgad/SVN/bfl-trunk/build-boost/tests/test_complete_filter(_ZN9__gnu_cxx13new_allocatorIN3BFL14WeightedSampleIN13MatrixWrapper12ColumnVectorEEEE10deallocateEPS5_j+0x11)0x8062927
/home/kgad/SVN/bfl-trunk/build-boost/tests/test_complete_filter(_ZNSt12_Vector_baseIN3BFL14WeightedSampleIN13MatrixWrapper12ColumnVectorEEESaIS4_EE13_M_deallocateEPS4_j+0x27)0x8062951
/home/kgad/SVN/bfl-trunk/build-boost/tests/test_complete_filter(_ZNSt12_Vector_baseIN3BFL14WeightedSampleIN13MatrixWrapper12ColumnVectorEEESaIS4_EED2Ev+0x36)0x806298a
/home/kgad/SVN/bfl-trunk/build-boost/tests/test_complete_filter(_ZNSt6vectorIN3BFL14WeightedSampleIN13MatrixWrapper12ColumnVectorEEESaIS4_EED1Ev+0x5b)0x8062d9d
/home/kgad/SVN/bfl-trunk/build-boost/src/liborocos-bfl.so(_ZN3BFL16EKParticleFilterD0Ev+0x117)0x4012551b
/home/kgad/SVN/bfl-trunk/build-boost/tests/test_complete_filter(_ZN19Complete_FilterTest29testComplete_FilterValue_ContEv+0x21d2)0x805fcba
/home/kgad/SVN/bfl-trunk/build-boost/tests/test_complete_filter(_ZN7CppUnit10TestCallerI19Complete_FilterTestE7runTestEv+0x55)0x806192d
/usr/lib/libcppunit-1.12.so.0(_ZNK7CppUnit21TestCaseMethodFunctorclEv+0x29)0x40195e49
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit16DefaultProtector7protectERKNS_7FunctorERKNS_16ProtectorContextE+0x2e)0x4018742e
/usr/lib/libcppunit-1.12.so.0(_ZNK7CppUnit14ProtectorChain14ProtectFunctorclEv+0x23)0x40191a43
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit14ProtectorChain7protectERKNS_7FunctorERKNS_16ProtectorContextE+0x1d4)0x40191764
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit10TestResult7protectERKNS_7FunctorEPNS_4TestERKSs+0x51)0x4019e2b1
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit8TestCase3runEPNS_10TestResultE+0x10d)0x40195b4d
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit13TestComposite15doRunChildTestsEPNS_10TestResultE+0x3d)0x401964bd
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit13TestComposite3runEPNS_10TestResultE+0x2a)0x401963ea
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit13TestComposite15doRunChildTestsEPNS_10TestResultE+0x3d)0x401964bd
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit13TestComposite3runEPNS_10TestResultE+0x2a)0x401963ea
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit10TestRunner13WrappingSuite3runEPNS_10TestResultE+0x40)0x401a0960
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit10TestResult7runTestEPNS_4TestE+0x2a)0x4019e04a
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit10TestRunner3runERNS_10TestResultERKSs+0x50)0x401a07a0
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit14TextTestRunner3runERNS_10TestResultERKSs+0x2b)0x401a3f7b
/usr/lib/libcppunit-1.12.so.0(_ZN7CppUnit14TextTestRunner3runESsbbb+0x62)0x401a3ff2
/home/kgad/SVN/bfl-trunk/build-boost/tests/test_complete_filter(main+0x1f2)0x805c442
/lib/i686/cmov/libc.so.6(__libc_start_main+0xe0)0x402ed450
/home/kgad/SVN/bfl-trunk/build-boost/tests/test_complete_filter(_ZNK7CppUnit4Test12findTestPathEPKS0_RN

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
 Attachment #183 is|0                           |1
           obsolete|                            |
--- Comment #5 from Tinne De Laet <tinne delaet [..] >  2008-01-10 11:04:04 ---

Created an attachment (id=184)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=184)

Patch to solve allocation issues for EKparticlefilter - bis

> Source code wise, I think this solves some issues, but not all of them.
> Since this is a particle filter involving a KF step, I think you should
> also _preallocate_ the matrices, and not only the lists, e.g. in the
> constructor instead of just
> doing
>
> _sampleCov.resize(prior->NumSamplesGet());
>
> you should add something like (note: this is only pseudo code)
>
> _cov_it = _sampleCov.begin();
> while (_cov_it != _sampleCov.end())
> {
> (*_cov_it).resize(this->StateSizeGet());
> }
>
Ack, I think the new patch also preallocates the matrices,... but using the
assign function in stead of iterating over the list.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #6 from Tinne De Laet <tinne delaet [..] >  2008-01-10 14:04:33 ---

Created an attachment (id=187)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=187)

Patch to solve allocation issues for kalmanfilter

...
notice the work-around-solution for initializing some of the variables needed
in measupdate.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #7 from Tinne De Laet <tinne delaet [..] >  2008-01-10 14:10:15 ---

Created an attachment (id=188)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=188)

Patch to solve allocation issues for extendedKalmanFilter

same remark as with kalmanfilter-patch

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #8 from Tinne De Laet <tinne delaet [..] >  2008-01-10 14:11:40 ---

Created an attachment (id=189)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=189)

Patch to solve allocation issues for itereatedExtendedKalmanFilter

... same remark as with kalmanfilter

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #9 from Tinne De Laet <tinne delaet [..] >  2008-01-10 14:13:01 ---

Created an attachment (id=190)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=190)

Patch to solve allocation issues for SRitereatedExtendedKalmanFilter

... same remark as with kalmanfilter

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #10 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-10 14:17:56 ---

(In reply to comment #5)
> Created an attachment (id=184)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=184) details

> Patch to solve allocation issues for EKparticlefilter - bis

Patch seems ok (2 minor issues, (i) a small and minor indentation thingie, and
(ii) by adding the delete statement in the destructor, I guess your fixing
another bug, but "who cares" :-)

> Ack, I think the new patch also preallocates the matrices,... but using the
> assign function in stead of iterating over the list.

Excellent.

Apart from the above, I still think we have to figure out a way of
automagically detecting these kind of errors in the unit testing (or at least
somewhere else)
Now we actually _think_ the bug is fixed, and we need to investigate valgrind
traces in order to be sure, which is not a good thing.

Klaas

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #11 from Tinne De Laet <tinne delaet [..] >  2008-01-10 14:22:11 ---

Created an attachment (id=191)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=191)

Patch to solve allocation issues for histogramfilter

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #12 from Tinne De Laet <tinne delaet [..] >  2008-01-10 14:59:17 ---

Created an attachment (id=193)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=193)

Patch to solve allocation issues for particlefilter

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
                 CC|                            |tinne delaet [..] en.b
                   |                            |e
--- Comment #13 from Tinne De Laet <tinne delaet [..] >  2008-01-10 17:34:05 ---

A small question:

To obtain real-timeness
I think I should change some things to the function sampleFrom (pdf.h ...)

 84       virtual bool SampleFrom (vector<Sample<T> >& list_samples,
 85                    const unsigned int num_samples,
 86                    int method = DEFAULT,
 87                    void * args = NULL) const;

In the implementation in for instance gaussian.cpp, the list_samples is first
resized to num_samples which breaks the real-timeness.
Could I add a precondition (and an assert) to make sure that the list_samples
already has the correct size?
Or do you see another, more suitable, solution.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #14 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-10 17:50:40 ---

(In reply to comment #13)
> A small question:
>
> To obtain real-timeness
> I think I should change some things to the function sampleFrom (pdf.h ...)
> 84 virtual bool SampleFrom (vector<Sample<T> >& list_samples,
> 85 const unsigned int num_samples,
> 86 int method = DEFAULT,
> 87 void * args = NULL) const;
> In the implementation in for instance gaussian.cpp, the list_samples is first
> resized to num_samples which breaks the real-timeness.
> Could I add a precondition (and an assert) to make sure that the list_samples
> already has the correct size?

If I understand it correctly, the resize operation only breaks realtime if

list_samples.size() != num_samples

If not, the resize() operation does not break real-time.
So the user of this function _can_ have real-time evaluation if he wants to.
IMO, what should be done is adding a warning to the API documentation of Pdf
about this.

This should allow people creating BFL filters meant for real-time use obtaining
real-time behavior, but it should not hinder people that are not interested in
real-time behavior of writing simple applications like

gaussian g(mu,sigma)
vector<Sample<ColumnVector> > v;
g.samplefrom(v,100);

The BFL logger (which does currently not exist, and whom ? I'd like to share
with the other Orocos subprojects (hence, reusing the RTT logger) could then
print a warning about the real-timeness.

Klaas

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #15 from Tinne De Laet <tinne delaet [..] >  2008-01-10 18:43:58 ---

Any suggestions how to get the sampleFrom(list ) in discretepdf realtime?
The rescaling of the uniform samples is causing my difficulties.

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #17 from Tinne De Laet <tinne delaet [..] >  2008-01-10 18:46:24 ---

Created an attachment (id=195)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=195)

Patch to solve allocation issues for discreteconditionalpdf

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #16 from Tinne De Laet <tinne delaet [..] >  2008-01-10 18:45:56 ---

Created an attachment (id=194)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=194)

Patch to solve allocation issues for conditionalgaussian

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #18 from Tinne De Laet <tinne delaet [..] >  2008-01-10 18:46:56 ---

Created an attachment (id=196)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=196)

Patch to solve allocation issues for gaussian

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #19 from Tinne De Laet <tinne delaet [..] >  2008-01-10 18:47:29 ---

Created an attachment (id=197)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=197)

Patch to solve allocation issues for linearanalyticconditionalgaussian

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #20 from Tinne De Laet <tinne delaet [..] >  2008-01-11 10:20:10 ---

Created an attachment (id=199)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=199)

Patch to solve allocation issues for uniform

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #21 from Tinne De Laet <tinne delaet [..] >  2008-01-11 10:20:48 ---

Created an attachment (id=200)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=200)

Patch to solve allocation issues for rauchtungstriebel

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #22 from Tinne De Laet <tinne delaet [..] >  2008-01-11 14:48:30 ---

Created an attachment (id=204)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=204)

Patch to solve allocation issues for mcpdf

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
 Attachment #196 is|0                           |1
           obsolete|                            |
--- Comment #23 from Tinne De Laet <tinne delaet [..] >  2008-01-11 16:31:31 ---

Created an attachment (id=205)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=205)

Patch to solve allocation issues for gaussian - bis

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #24 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-11 20:04:56 ---

(In reply to comment #6)
> Created an attachment (id=187)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=187) details

> Patch to solve allocation issues for kalmanfilter
>
> ...
> notice the work-around-solution for initializing some of the variables needed
> in measupdate.

The calculatesysupdate and calculatemeasupdate functions should use references
for passing the matrix arguments, otherwise the local copies will also result
in allocations.
So I think you need function references like

void CalculateMeasUpdate(const ColumnVector & z, const ColumnVector & Z, const
Matrix & H, const SymmetricMatrix & R)

etc.

Concerning the workaround: suppose you have a system with measurements from 2
sources which generate measurements approximately randomly, in that case, you
will allocate each time.

What about turning _S and _K as a vectors of ColumnVectors/Matrices, which you
can initialize using an allocateMeasModel function?

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #25 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-13 19:57:50 ---

(In reply to comment #24)
> (In reply to comment #6)
> > Created an attachment (id=187)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=187) details details

> > Patch to solve allocation issues for kalmanfilter
> >
> > ...
> > notice the work-around-solution for initializing some of the variables needed
> > in measupdate.
>
> The calculatesysupdate and calculatemeasupdate functions should use references
> for passing the matrix arguments, otherwise the local copies will also result
> in allocations.
> So I think you need function references like
>
> void CalculateMeasUpdate(const ColumnVector & z, const ColumnVector & Z, const
> Matrix & H, const SymmetricMatrix & R)
>
> etc.
>
> Concerning the workaround: suppose you have a system with measurements from 2
> sources which generate measurements approximately randomly, in that case, you
> will allocate each time.
>
> What about turning _S and _K as a vectors of ColumnVectors/Matrices, which you
> can initialize using an allocateMeasModel function?

While trying to do a 5 minute implementation of the above, I discovered we
would need something like stl::hash_set() in order to implement this efficient
(i.e. make the lookup of which vectors to use very fast)

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
 Attachment #187 is|0                           |1
           obsolete|                            |
--- Comment #26 from Tinne De Laet <tinne delaet [..] >  2008-01-16 14:28:34 ---

Created an attachment (id=207)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=207)

Patch to solve allocation issues for kalmanfilter - bis

(In reply to comment #24 and #25)

> The calculatesysupdate and calculatemeasupdate functions should use references
> for passing the matrix arguments, otherwise the local copies will also result
> in allocations.
> So I think you need function references like
>
> void CalculateMeasUpdate(const ColumnVector & z, const ColumnVector & Z, const
> Matrix & H, const SymmetricMatrix & R)
>
> etc.

Ok.

> Concerning the workaround: suppose you have a system with measurements from 2
> sources which generate measurements approximately randomly, in that case, you
> will allocate each time.
>
> What about turning _S and _K as a vectors of ColumnVectors/Matrices, which you
> can initialize using an allocateMeasModel function?

> While trying to do a 5 minute implementation of the above, I discovered we
> would need something like stl::hash_set() in order to implement this efficient
> (i.e. make the lookup of which vectors to use very fast)
I used a map to implement the behavior you suggested.
Furthermore I made a struct of variables which need to be allocated during the
call of MeasUpdate.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
 Attachment #204 is|0                           |1
           obsolete|                            |
--- Comment #27 from Tinne De Laet <tinne delaet [..] >  2008-01-18 16:37:47 ---

Created an attachment (id=212)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=212)

Solves issue explained in bug #497

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
 Attachment #212 is|0                           |1
           obsolete|                            |
--- Comment #28 from Tinne De Laet <tinne delaet [..] >  2008-01-18 19:30:53 ---

Created an attachment (id=215)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=215)

Solves issue explained in bug #497, this time with a patch an not just the
mcpdf

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #29 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-19 17:46:14 ---

(In reply to comment #17)
> Created an attachment (id=195)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=195) details

> Patch to solve allocation issues for discreteconditionalpdf

patch ok, although these constructions

-  int DiscreteConditionalPdf::IndexGet(int input,                              
-                                      std::vector<int> condargs) const         
+  int DiscreteConditionalPdf::IndexGet(const int& input,                       
+                                      const std::vector<int>& condargs) const  

are somewhat unnecessary, since the copy will be on the stack.

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #30 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-19 17:52:37 ---

(In reply to comment #11)
> Created an attachment (id=191)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=191) details

> Patch to solve allocation issues for histogramfilter

Patch ok

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #31 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-19 18:05:18 ---

(In reply to comment #12)
> Created an attachment (id=193)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=193) details

> Patch to solve allocation issues for particlefilter

apart from some whitespace cluttering, patch seems ok.

Klaas

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #32 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-19 18:26:40 ---

(In reply to comment #16)
> Created an attachment (id=194)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=194) details

> Patch to solve allocation issues for conditionalgaussian

Patch seems ok

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #33 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-19 18:33:43 ---

(In reply to comment #19)
> Created an attachment (id=197)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=197) details

> Patch to solve allocation issues for linearanalyticconditionalgaussian

patch seems ok (again :-)

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #34 from Klaas Gadeyne <klaas gadeyne [..] >  2008-01-19 18:41:42 ---

(In reply to comment #20)
> Created an attachment (id=199)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=199) details

> Patch to solve allocation issues for uniform

this patch is ok, but it seems that there is an unused (and unnecessary)
variable _rit defined in the header file.

some minor remark (I've seen this in a couple of the patches). Don't add
doxygen style comment for the helper variables (they should be hidden for the
user)

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
 Attachment #184 is|0                           |1
           obsolete|                            |
--- Comment #35 from Tinne De Laet <tinne delaet [..] >  2008-01-21 09:05:26 ---

Created an attachment (id=219)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=219)
 Patch to solve allocation issues for EKparticlefilter - bis2

Final patch for EKparticlefilter. (?)

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #36 from Tinne De Laet <tinne delaet [..] >  2008-01-21 09:06:36 ---

(In reply to comment #35)
> Created an attachment (id=219)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=219) details

> Patch to solve allocation issues for EKparticlefilter - bis2
>
> Final patch for EKparticlefilter. (?)
>
Patch applied in revision 28848:

Sending filter/EKparticlefilter.cpp
Sending filter/EKparticlefilter.h
Transmitting file data ..
Committed revision 28848.

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
 Attachment #188 is|0                           |1
           obsolete|                            |
--- Comment #37 from Tinne De Laet <tinne delaet [..] >  2008-01-23 08:44:00 ---

Created an attachment (id=226)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=226)

Patch to solve allocation issues for extendedKalmanFilter - bis

This patch also adds a map to the extendedKalmanFilter to allocate memory
needed during the measurement updat (see comment #24, #25, #26)

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
 Attachment #189 is|0                           |1
           obsolete|                            |
--- Comment #38 from Tinne De Laet <tinne delaet [..] >  2008-01-23 09:49:02 ---

Created an attachment (id=227)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=227)

Patch to solve allocation issues for iteratedextendedKalmanFilter - bis

This patch also adds a map to the iteratedExtendedKalmanFilter to allocate
memory needed during the measurement update (see comment #24, #25, #26)

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #39 from Tinne De Laet <tinne delaet [..] >  2008-01-23 10:52:18 ---

(In reply to comment #30)
> (In reply to comment #11)
> > Created an attachment (id=191)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=191) details details

> > Patch to solve allocation issues for histogramfilter
>
> Patch ok
>

Patch (attachement #191) applied in revision 28868.

Sending histogramfilter.cpp
Sending histogramfilter.h
Transmitting file data ..
Committed revision 28868.

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #40 from Tinne De Laet <tinne delaet [..] >  2008-01-23 11:01:50 ---

> (In reply to comment #12)
> > Created an attachment (id=193)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=193) details details

> > Patch to solve allocation issues for particlefilter
>
> apart from some whitespace cluttering, patch seems ok.

Patch (attachment (id=193)) applied in revision 28869:

Sending particlefilter.cpp
Sending particlefilter.h
Transmitting file data ..
Committed revision 28869

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #41 from Tinne De Laet <tinne delaet [..] >  2008-01-23 11:12:55 ---

(In reply to comment #32)
> (In reply to comment #16)
> > Created an attachment (id=194)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=194) details details

> > Patch to solve allocation issues for conditionalgaussian
>
> Patch seems ok
>

Patch (attachment (id=194)) applied in revision 28870.

Sending conditionalgaussian.cpp
Sending conditionalgaussian.h
Transmitting file data ..
Committed revision 28870.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #43 from Tinne De Laet <tinne delaet [..] >  2008-01-23 11:29:15 ---

(In reply to comment #23)
> Created an attachment (id=205)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=205) details

> Patch to solve allocation issues for gaussian - bis
>

Patch (attachment (id=205)) applied in revision

Sending gaussian.cpp
Sending gaussian.h
Transmitting file data ..
Committed revision 28872.

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #44 from Tinne De Laet <tinne delaet [..] >  2008-01-23 11:36:29 ---

(In reply to comment #33)
> (In reply to comment #19)
> > Created an attachment (id=197)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=197) details details

> > Patch to solve allocation issues for linearanalyticconditionalgaussian
>
> patch seems ok (again :-)
>
Patch (attachment (id=197)) applied in revision 28873:

Sending linearanalyticconditionalgaussian.cpp
Sending linearanalyticconditionalgaussian.h
Transmitting file data ..
Committed revision 28873.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #42 from Tinne De Laet <tinne delaet [..] >  2008-01-23 11:23:25 ---

(In reply to comment #29)
> (In reply to comment #17)
> > Created an attachment (id=195)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=195) details details

> > Patch to solve allocation issues for discreteconditionalpdf
>
> patch ok, although these constructions
> - int DiscreteConditionalPdf::IndexGet(int input,
> - std::vector<int> condargs) const
> + int DiscreteConditionalPdf::IndexGet(const int& input,
> + const std::vector<int>& condargs) const
>
> are somewhat unnecessary, since the copy will be on the stack.
>

Patch (attachment (id=195)) applied in revision 28871:

Sending pdf/discreteconditionalpdf.cpp
Sending pdf/discreteconditionalpdf.h
Transmitting file data ..
Committed revision 28871.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #46 from Tinne De Laet <tinne delaet [..] >  2008-01-23 11:43:28 ---

(In reply to comment #45)
> Created an attachment (id=228)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=228) details

> Patch to solve allocation issues for uniform - bis
the user)
>
> Your suggestions are applied in the new patch.

Patch (attachment (id=228)) applied in revision 28874:

Sending uniform.cpp
Sending uniform.h
Transmitting file data ..
Committed revision 28874.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

Tinne De Laet <tinne delaet [..] > changed:

           What    |Removed                     |Added
 --------------------------------------------------------------------------
 Attachment #199 is|0                           |1
           obsolete|                            |
--- Comment #45 from Tinne De Laet <tinne delaet [..] >  2008-01-23 11:42:02 ---

Created an attachment (id=228)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=228)

Patch to solve allocation issues for uniform - bis

(In reply to comment #24)
> > Created an attachment (id=199)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=199) details details

> > Patch to solve allocation issues for uniform

> this patch is ok, but it seems that there is an unused (and unnecessary)
> variable _rit defined in the header file.

> some minor remark (I've seen this in a couple of the patches). Don't add
> doxygen style comment for the helper variables (they should be hidden for
> the user)

Your suggestions are applied in the new patch.

tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #47 from Tinne De Laet <tinne delaet [..] >  2008-01-23 15:26:08 ---

(In reply to comment #21)
> Created an attachment (id=200)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=200) details

> Patch to solve allocation issues for rauchtungstriebel
>

Patch (attachment (id=200)) applied in revision 28875:

Sending rauchtungstriebel.cpp
Sending rauchtungstriebel.h
Transmitting file data ..
Committed revision 28875.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #48 from Tinne De Laet <tinne delaet [..] >  2008-01-23 17:19:15 ---

(In reply to comment #28)
> Created an attachment (id=215)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=215) details

> Solves issue explained in bug #497, this time with a patch an not just the
> mcpdf
>

Patch (attachment (id=215)) applied in revision 28876

Sending mcpdf.cpp
Sending mcpdf.h
Transmitting file data ..
Committed revision 28876.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #49 from Tinne De Laet <tinne delaet [..] >  2008-01-23 17:39:22 ---

> (In reply to comment #12)
> > Created an attachment (id=193)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=193) details details details

> > Patch to solve allocation issues for particlefilt(In reply to comment #26)
> Created an attachment (id=207)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=207) details

> Patch to solve allocation issues for kalmanfilter - bis
..

Patch (attachment (id=207)) applied in revision 28877:

Sending kalmanfilter.cpp
Sending kalmanfilter.h
Transmitting file data ..
Committed revision 28877.

Tinne

[Bug 479] Some filters will break real-time

For more infomation about this bug, visit <https://www.fmtc.be/bugzilla/orocos/show_bug.cgi?id=479>

--- Comment #50 from Tinne De Laet <tinne delaet [..] >  2008-01-23 17:44:29 ---

(In reply to comment #37)
> Created an attachment (id=226)

 --> (https://www.fmtc.be/bugzilla/orocos/attachment.cgi?id=226) details

> Patch to solve allocation issues for extendedKalmanFilter - bis
>
> This patch also adds a map to the extendedKalmanFilter to allocate memory
> needed during the measurement updat (see comment #24, #25, #26)

Patch applied in revision 28878

Sending extendedkalmanfilter.cpp
Sending extendedkalmanfilter.h
Transmitting file data ..
Committed revision 28878.

Tinne