Bayes Filters Library
KFPrediction.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 using namespace Eigen;
12 
13 
14 KFPrediction::KFPrediction(std::unique_ptr<LinearStateModel> state_model) noexcept :
15  state_model_(std::move(state_model))
16 { }
17 
18 
20  GaussianPrediction(std::move(prediction)),
21  state_model_(std::move(prediction.state_model_))
22 { }
23 
24 
26 {
27  if (this == &prediction)
28  return *this;
29 
30  GaussianPrediction::operator=(std::move(prediction));
31 
32  state_model_ = std::move(prediction.state_model_);
33 
34  return *this;
35 }
36 
37 
39 {
40  return *state_model_;
41 }
42 
43 
44 void KFPrediction::predictStep(const GaussianMixture& prev_state, GaussianMixture& pred_state)
45 {
46  if (getStateModel().is_skipping())
47  {
48  pred_state = prev_state;
49 
50  return;
51  }
52 
53  /* Evaluate predicted mean
54  x_{k+1} = F_{k} x_{k} */
55  getStateModel().propagate(prev_state.mean(), pred_state.mean());
56 
57  /* Evaluate predicted covariance.
58  P_{k+1} = F_{k} * P_{k} * F_{k}' + Q */
59  MatrixXd F = state_model_->getStateTransitionMatrix();
60 
61  for (size_t i=0; i < prev_state.components; i++)
62  pred_state.covariance(i).noalias() = F * prev_state.covariance(i) * F.transpose() + state_model_->getNoiseCovarianceMatrix();
63 }
bfl
Port of boost::any for C++11 compilers.
Definition: AdditiveMeasurementModel.h:13
bfl::GaussianMixture::components
std::size_t components
Definition: GaussianMixture.h:67
bfl::GaussianPrediction::operator=
GaussianPrediction & operator=(const GaussianPrediction &prediction) noexcept=delete
bfl::GaussianMixture::mean
Eigen::Ref< Eigen::MatrixXd > mean()
Definition: GaussianMixture.cpp:94
bfl::KFPrediction::operator=
KFPrediction & operator=(const KFPrediction &prediction) noexcept=delete
bfl::GaussianMixture::covariance
Eigen::Ref< Eigen::MatrixXd > covariance()
Definition: GaussianMixture.cpp:130
bfl::GaussianPrediction
Definition: GaussianPrediction.h:23
bfl::KFPrediction::getStateModel
StateModel & getStateModel() noexcept override
Definition: KFPrediction.cpp:38
bfl::StateModel
Definition: StateModel.h:22
KFPrediction.h
bfl::KFPrediction::KFPrediction
KFPrediction(std::unique_ptr< LinearStateModel > state_model) noexcept
Definition: KFPrediction.cpp:14
bfl::KFPrediction::predictStep
void predictStep(const GaussianMixture &prev_state, GaussianMixture &pred_state) override
Definition: KFPrediction.cpp:44
bfl::KFPrediction
Definition: KFPrediction.h:23
bfl::GaussianMixture
Definition: GaussianMixture.h:20