Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discussion on strategies towards multi-threading particle filter algorithms #610

Open
jlblancoc opened this issue Nov 7, 2017 · 6 comments

Comments

@jlblancoc
Copy link
Member

(Follow-up from mrpt-users mailing list here)

Things to bear in mind:


virtual void | prediction_and_update_pfStandardProposal (const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options)
-- | --
  | Performs the particle filter prediction/update stages for the algorithm "pfStandardProposal" (if not implemented in heritated class, it will raise a 'non-implemented' exception). More...
 
virtual void | prediction_and_update_pfAuxiliaryPFStandard (const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options)
  | Performs the particle filter prediction/update stages for the algorithm "pfAuxiliaryPFStandard" (if not implemented in heritated class, it will raise a 'non-implemented' exception). More...
 
virtual void | prediction_and_update_pfOptimalProposal (const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options)
  | Performs the particle filter prediction/update stages for the algorithm "pfOptimalProposal" (if not implemented in heritated class, it will raise a 'non-implemented' exception). More...
 
virtual void | prediction_and_update_pfAuxiliaryPFOptimal (const mrpt::obs::CActionCollection *action, const mrpt::obs::CSensoryFrame *observation, const bayes::CParticleFilter::TParticleFilterOptions &PF_options)
  | Performs the particle filter prediction/update stages for the algorithm "pfAuxiliaryPFOptimal" (if not implemented in heritated class, it will raise a 'non-implemented' exception). More...

Let's use this thread to further discuss possible strategies on how to address this feature.

@jolting
Copy link
Member

jolting commented Nov 20, 2017

I think to start with the particle filter algorithms could be a little bit more generalized and the particle filter algorithms need to be separated into their own classes.

Here's a start of some of my ideas:
https://github.com/jolting/mrpt/tree/refactorPF

@jlblancoc
Copy link
Member Author

jlblancoc commented Nov 20, 2017

Great! I'll merge in an experimental branch to continue testing there, ok?

Here it is: https://github.com/MRPT/mrpt/tree/dev-PF-refactor

@jolting
Copy link
Member

jolting commented Nov 20, 2017

Ok. I broke the python bindings. I can fix them later if you like those changes.

@jlblancoc
Copy link
Member Author

No problem for the bindings. I'll take a closer look at the changes (the entire set of classes for PF is really intertwined and a bit intricate, honestly...) and come back.
Will not be today or tomorrow! ;-)

@jlblancoc
Copy link
Member Author

Hmm... after a first "in depth" (not enough, tough) look at the changes, I have some comments:

  • it seems there are two signatures for executeOn()... is this on purpose?

https://github.com/MRPT/mrpt/blob/dev-PF-refactor/libs/base/include/mrpt/bayes/CParticleFilter.h#L208-L218

  • I see and like the idea of using a templ. param for selecting the PF algorithm. However, since the algorithms are "general", I think it would be better to have all their "trait classes" together into one header (probably CParticleFilter.h itself?). Enums as t.param was another idea, but it's actually more flexible to use classes, so it could be extended in the future, or by user code, etc. right?

  • The main problem right now is that most code seems to still be calling this signature, which seems not to be implemented (?):

https://github.com/MRPT/mrpt/blob/dev-PF-refactor/libs/base/include/mrpt/bayes/CParticleFilter.h#L214-L218

I couldn't build it for testing, so perhaps I'm wrong. Anyhow, allowing such a signature without PF_ALGORITHM is mandatory if algorithms are to be selected dynamically via a configuration file, etc.
I imagine writing the impl. of this version of executeOn<> with a switch inside, calling executeOn<PFCapable,PF_Algorithm>() for each PF_Algorithm... or does exist any alternative?

@jolting
Copy link
Member

jolting commented Nov 22, 2017

I probably should have called those two separate things
executeOn picks the one set by PF_options and which calls a specific executeOn<PARTICLEFILTERCAPABLE, PF_ALGORITHM>.

The one template version needs to be pushed down into the individual classes and called something else
executeOn

I realized too late that template instantiation is probably overkill for this. I was jumbling things around trying to get things to compile and I went a little crazy.

void CParticleFilter::executeOn<CMonteCarloLocalization2D>(

void CParticleFilter::executeOn<CMonteCarloLocalization3D>(

I think also about a factory pattern to fix this.

The two template version seems powerful though. You can use your own version of the algorithm. If you made processActionObservation templated as well you could have as many variations of particle filters as you want and the algorithms would be fairly loosely coupled. Hopefully this can improve reuse.

void CMetricMapBuilderRBPF::processActionObservation(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants