-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor with latest iteration of design based on Ivan's proposal
- Loading branch information
Showing
22 changed files
with
552 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 0 additions & 54 deletions
54
beluga/include/beluga/algorithm/resampling_policies/resample_interval_policy.hpp
This file was deleted.
Oops, something went wrong.
50 changes: 0 additions & 50 deletions
50
beluga/include/beluga/algorithm/resampling_policies/resampling_policy_poller.hpp
This file was deleted.
Oops, something went wrong.
59 changes: 0 additions & 59 deletions
59
beluga/include/beluga/algorithm/resampling_policies/selective_resampling_policy.hpp
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2022 Ekumen, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef BELUGA_RESAMPLING_POLICIES_HPP | ||
#define BELUGA_RESAMPLING_POLICIES_HPP | ||
|
||
#include <beluga/resampling_policies/resample_interval_policy.hpp> | ||
#include <beluga/resampling_policies/resample_on_motion_policy.hpp> | ||
#include <beluga/resampling_policies/resampling_policies_poller.hpp> | ||
#include <beluga/resampling_policies/selective_resampling_policy.hpp> | ||
|
||
/** | ||
* \file | ||
* \brief Includes all resampling policy related headers. | ||
*/ | ||
|
||
/** | ||
* \page ResamplePolicyPage beluga named requirements: ResamplePolicy | ||
* Requirements for a resampling policy to be used a beluga `ParticleFilter`. | ||
* | ||
* \section ResamplePolicyRequirements Requirements | ||
* A type `T` satisfies the `ResamplePolicy` requirements if the following is satisfied. | ||
* | ||
* Given: | ||
* - An instance `p` of `T`. | ||
* - An instance `c` of `C`, where is a particle filter that meets the requirements listed in the policy. | ||
* | ||
* Then: | ||
* - `p.do_resampling(c)` will return true if resampling must be done according to the policy, false otherwise. This | ||
* function is called in cascade when multiple policies are installed in the filter, and a given filters do_resampling() | ||
* function may not be called if a previously queried policy has already voted "false" (short-circuit evaluation of | ||
* policies). | ||
* */ | ||
|
||
#endif |
67 changes: 67 additions & 0 deletions
67
beluga/include/beluga/resampling_policies/resample_interval_policy.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Copyright 2023 Ekumen, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef BELUGA_RESAMPLING_POLICIES_RESAMPLE_INTERVAL_POLICY_HPP | ||
#define BELUGA_RESAMPLING_POLICIES_RESAMPLE_INTERVAL_POLICY_HPP | ||
|
||
#include <optional> | ||
|
||
#include <beluga/type_traits/resampling_policy_traits.hpp> | ||
|
||
namespace beluga { | ||
|
||
/// Parameters used to construct a ResampleIntervalPolicy instance. | ||
struct ResampleIntervalPolicyParam { | ||
/// Interval of calls to do_resampling() out of which only the last iteration will do resampling. | ||
std::size_t resample_interval_count{1}; | ||
}; | ||
|
||
/// Implementation of the Resample Interval algorithm for resampling. | ||
/** | ||
* ResampleIntervalPolicy is an implementation of the \ref ResamplePolicyPage "ResamplePolicy" named requirements. | ||
* */ | ||
struct ResampleIntervalPolicy { | ||
public: | ||
/// Parameter type that the constructor uses to configure the policy | ||
using param_type = ResampleIntervalPolicyParam; | ||
|
||
/// @brief Constructor | ||
/// @param configuration Policy configuration data. | ||
explicit ResampleIntervalPolicy(const param_type& configuration) : configuration_{configuration} {} | ||
|
||
/// Vote whether resampling must be done according to this policy./ | ||
/** | ||
* \tparam Concrete Type representing the concrete implementation of the filter. | ||
*/ | ||
template <typename Concrete> | ||
[[nodiscard]] bool do_resampling([[maybe_unused]] Concrete& filter) { | ||
filter_update_counter_ = (filter_update_counter_ + 1) % configuration_.resample_interval_count; | ||
return (filter_update_counter_ == 0); | ||
} | ||
|
||
private: | ||
param_type configuration_; //< Policy configuration | ||
std::size_t filter_update_counter_{0}; //< Current cycle phase | ||
}; | ||
|
||
/// Specialization for a ResampleIntervalPolicy, see also \ref resampling_policy_traits.hpp. | ||
template <> | ||
struct resampling_policy_traits<ResampleIntervalPolicy> { | ||
/// configuration struct type associated to the policy | ||
using config_type = ResampleIntervalPolicyParam; | ||
}; | ||
|
||
} // namespace beluga | ||
|
||
#endif |
Oops, something went wrong.