-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add new resampling policies #119
Conversation
@nahueespinosa @ivanpauno this is open for feedback. |
f3b390e
to
3522036
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glpuga This looks awesome! I just have a design question for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work Gera!
I'm a bit concerned about the scalability of the proposal though.
See my review comments for concrete examples.
I understand though, this is not super easy to solve.
Ideally, I would have a ResampleIntervalPolicy
, ResampleOnMotionPolicy
and SelectiveResamplingPolicy
classes that implement the same "interface", and another class ComposableResamplingPolicy
that as well implements the same "interface" and allows registering multiple of the others resampling policies.
In that way, you could use one resampling policy in particular or a combination.
This is not so simply with the mixin though, and its harder considering that some of the resampling policies need access to other parts of the mixin.
Some concrete ideas:
- We could use the observer pattern for any component to observe motion updates.
The resampling policies that need that will need to register there.
Currently, the "update_motion()" method is part of the "MotionModel", but we could move it out of there and make also the motion model an "observer" of motion updates. - Same concept could be applied to sensor measurements, though that's not needed here.
- Maybe instead of making the resampling policy a mixin, make it independient and it composes with the
BootstrapParticleFilter
(the component type will be a new template parameter).
With that change, it's easier to makeResampleIntervalPolicy
,ResampleOnMotionPolicy
,SelectiveResamplingPolicy
andComposableResamplingPolicy
all have the same interface.
In the ros node, we always useComposableResamplingPolicy
, so the resampling policy will not change the final particle filter type.
I think the |
The difference is that if it's in the mixin, then you still need a new particle filter type, even if you use the It makes sense to me to make the resampling policy a component of |
@ivanpauno @nahueespinosa thank you for the comments. Feel free to continue discussing; I'll be able to take a look late today, I'll catch up with your comments then. |
I walked this line of thought too, and eventually discarded it for the reasons I explained above, but the code is available to scavenge it if we want in a copy branch I created before changing direction:
|
I think it can work, but at least for the three policies that we have now it would require:
An itch with this is that, say a hypothetical policy is only meant to be used with a given motion model, and that they are coupled through a particular interface that only that motion model provides, then this design would not allow for this model/policy to be implemented in a straight way, because the virtual interface would have to be made to open access to a method that only one particular motion model provides in benefit of a single policy. |
@nahueespinosa @ivanpauno Thanks for looking, I'll update the PR tomorrow to address your first round of comments and lets iterate from there. |
I think it doesn't need to be abstract, it could be templated. You would have something like class MyResamplePolicy
{
template<typename ParticleFilter>
bool do_resampling(ParticleFilter& self) {...}
};
template<
...
ResamplePolicy,
...
>
class BootstrapParticleFilter
{
void resample() {
if (resample_policy.template do_resampling(this->self())) {
...
}
...
}
...
private:
ResamplePolicy resample_policy;
};
Something like the above solve boths issues, as you also can access the motion updates that way. I'm not sure if what I'm proposing above is a better solution honestly, but it would work. |
3522036
to
90a493d
Compare
beluga/test/build_failure_tests/cmake/beluga_add_build_failure_test.cmake
Outdated
Show resolved
Hide resolved
beluga/test/build_failure_tests/cmake/beluga_add_build_failure_test.cmake
Outdated
Show resolved
Hide resolved
@nahueespinosa @ivanpauno I updated the branch with the first round of review comments. Some post-thoughts on the approach, something that is fine for now but may need rethinking is registering the resampler from their constructor:
|
beluga/include/beluga/algorithm/resampling_rate_policies/resample_interval_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/algorithm/resampling_rate_policies/resample_on_motion_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/algorithm/resampling_rate_policies/resample_interval_policy.hpp
Outdated
Show resolved
Hide resolved
7f43e6e
to
b70597f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glpuga This is fantastic! I did another pass.
beluga/include/beluga/algorithm/resampling_rate_policies/resample_on_motion_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/algorithm/resampling_rate_policies/resample_interval_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/algorithm/resampling_rate_policies/selective_resampling_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/algorithm/resampling_rate_policies/resample_on_motion_policy.hpp
Outdated
Show resolved
Hide resolved
0dcaa6d
to
96d0154
Compare
Feel free to ignore this, but I came up with an alternative that I wanted to give it a try.
I basically added a feature to ciabiatta to allow "combining" mixins into one. Ciabatta diff: glpuga/add_resampling_interval_policies...ivanpauno/add_resampling_interval_policies#diff-aa8386abc68af06e069cccdabc6bc7a9f0a8b5524b82731249d99dfc9added62 It's kinda tricky, but I thought it was an interesting approach, and the tricky details are hidden in ciabatta. |
I think that the implementation is cool. It adds a level of complexity though, so I'd like to discuss the original concerns first here.
I think it does make complete sense for them to be active just because they were added to the mix. In the end, the goal that I want to pursue is: "here is a couple of combinations that work for localization, if you want something different, define your own mix, take the mixins you want from beluga, add some custom ones and compose your own type at compile time". I have a change in the works for ciabatta that will allow us to do something like: using CustomLocalization = ciabatta::mixin<
Component1,
Component2,
ciabatta::curry<Component3, TemplateParameterForComponent3>::mixin,
ciabatta::provides<CustomLocalizationInterface>::mixin>;
I'd go for adding an "enabled" parameter for the three of them, setting them to true unconditionally in beluga_amcl. |
It adds complexity to
I agree with that idea, but I think that's exactly what this PR is not allowing.
To add to the previous concerns, the current "ResampleIntervalPolicy", "ResampleOnMotionPolicy", "SelectiveResamplingPolicy" are implemented using the mixin pattern, but are not a really mixin conceptually. i.e. I think mixins are meant to provide orthogonal functionality. |
@ivanpauno I love this idea 100%. The template @glpuga Please take a look when you can, this is great! |
1840182
to
9bc7915
Compare
@ivanpauno @nahueespinosa I like the new proposal! please check the implementation now when you have a moment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glpuga Awesome! Left a couple minor comments and super minor documentation suggestions.
beluga/include/beluga/resampling_policies/resampling_policies_poller.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/resampling_policies/selective_resampling_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/resampling_policies/resample_interval_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/resampling_policies/resample_on_motion_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/resampling_policies/selective_resampling_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/resampling_policies/selective_resampling_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/resampling_policies/selective_resampling_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/resampling_policies/selective_resampling_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/resampling_policies/resample_on_motion_policy.hpp
Outdated
Show resolved
Hide resolved
beluga/include/beluga/resampling_policies/resample_on_motion_policy.hpp
Outdated
Show resolved
Hide resolved
I just applied the punctuation and minor documentation comments using the GitHub commit batch interface. |
…a policy Signed-off-by: Gerardo Puga <[email protected]>
160389a
to
f8cae71
Compare
Latest commented addressed, I'll wait to have @ivanpauno ok to merge. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks for all the iterations @glpuga !!!!
Related to #57
Summary
Checklist