Bayes Filters Library
ParticleFilter.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016-2019 Istituto Italiano di Tecnologia (IIT)
3  *
4  * This software may be modified and distributed under the terms of the
5  * BSD 3-Clause license. See the accompanying LICENSE file for details.
6  */
7 
9 
10 using namespace bfl;
11 
12 
14 (
15  std::unique_ptr<ParticleSetInitialization> initialization,
16  std::unique_ptr<PFPrediction> prediction,
17  std::unique_ptr<PFCorrection> correction,
18  std::unique_ptr<Resampling> resampling
19 )
20 noexcept :
21  initialization_(std::move(initialization)),
22  prediction_(std::move(prediction)),
23  correction_(std::move(correction)),
24  resampling_(std::move(resampling))
25 { }
26 
27 
28 bool ParticleFilter::skip(const std::string& what_step, const bool status)
29 {
30  if (what_step == "prediction" ||
31  what_step == "state" ||
32  what_step == "exogenous" )
33  return prediction_->skip(what_step, status);
34 
35  if (what_step == "correction")
36  return correction_->skip(status);
37 
38  if (what_step == "all")
39  {
40  bool return_status = true;
41 
42  return_status &= prediction_->skip("prediction", status);
43 
44  return_status &= correction_->skip(status);
45 
46  return return_status;
47  }
48 
49  return false;
50 }
51 
52 
54 {
55  return *initialization_;
56 }
57 
58 
60 {
61  return *prediction_;
62 }
63 
64 
66 {
67  return *correction_;
68 }
69 
70 
72 {
73  return *resampling_;
74 }
bfl
Port of boost::any for C++11 compilers.
Definition: AdditiveMeasurementModel.h:13
bfl::PFCorrection
Definition: PFCorrection.h:25
bfl::ParticleFilter::correction
PFCorrection & correction()
Definition: ParticleFilter.cpp:65
bfl::ParticleFilter::prediction
PFPrediction & prediction()
Definition: ParticleFilter.cpp:59
bfl::PFPrediction
Definition: PFPrediction.h:25
bfl::ParticleFilter::ParticleFilter
ParticleFilter(std::unique_ptr< ParticleSetInitialization > initialization, std::unique_ptr< PFPrediction > prediction, std::unique_ptr< PFCorrection > correction, std::unique_ptr< Resampling > resampling) noexcept
Definition: ParticleFilter.cpp:14
bfl::ParticleFilter::initialization
ParticleSetInitialization & initialization()
Definition: ParticleFilter.cpp:53
bfl::ParticleFilter::resampling
Resampling & resampling()
Definition: ParticleFilter.cpp:71
bfl::ParticleFilter::initialization_
std::unique_ptr< ParticleSetInitialization > initialization_
Definition: ParticleFilter.h:54
bfl::ParticleFilter::correction_
std::unique_ptr< PFCorrection > correction_
Definition: ParticleFilter.h:58
bfl::ParticleFilter::skip
bool skip(const std::string &what_step, const bool status) override
Definition: ParticleFilter.cpp:28
bfl::Resampling
Definition: Resampling.h:22
ParticleFilter.h
bfl::ParticleSetInitialization
Definition: ParticleSetInitialization.h:20
bfl::ParticleFilter::prediction_
std::unique_ptr< PFPrediction > prediction_
Definition: ParticleFilter.h:56
bfl::ParticleFilter::resampling_
std::unique_ptr< Resampling > resampling_
Definition: ParticleFilter.h:60