Bayes Filters Library
LinearModel.h
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 
8 #ifndef LINEARMODEL_H
9 #define LINEARMODEL_H
10 
12 
13 #include <initializer_list>
14 #include <fstream>
15 #include <functional>
16 #include <random>
17 #include <string>
18 
19 namespace bfl {
20  class LinearModel;
21 }
22 
23 
25 {
26 public:
37  using LinearMatrixComponent = std::pair<std::size_t, std::vector<std::size_t>>;
38 
39  LinearModel(const LinearMatrixComponent& linear_matrix_component, const Eigen::Ref<const Eigen::MatrixXd>& noise_covariance_matrix, const unsigned int seed);
40 
41  LinearModel(const LinearMatrixComponent& linear_matrix_component, const Eigen::Ref<const Eigen::MatrixXd>& noise_covariance_matrix);
42 
43  virtual ~LinearModel() noexcept = default;
44 
45  std::pair<bool, Eigen::MatrixXd> getNoiseCovarianceMatrix() const override;
46 
47  Eigen::MatrixXd getMeasurementMatrix() const override;
48 
49 
50 protected:
51  std::pair<bool, Eigen::MatrixXd> getNoiseSample(const int num) const;
52 
56  double T_;
57 
61  Eigen::MatrixXd sqrt_R_;
62 
67  std::function<double()> gauss_rnd_sample_;
68 
69  std::vector<std::string> log_file_names(const std::string& folder_path, const std::string& file_name_prefix) override
70  {
71  return {folder_path + "/" + file_name_prefix + "_measurements"};
72  }
73 
74 
75 private:
76  std::mt19937_64 generator_;
77 
78  std::normal_distribution<double> distribution_;
79 
80  bool log_enabled_ = false;
81 
82  mutable std::ofstream log_file_measurements_;
83 };
84 
85 #endif /* LINEARMODEL_H */
bfl::LinearModel
Definition: LinearModel.h:24
bfl::LinearModel::LinearMatrixComponent
std::pair< std::size_t, std::vector< std::size_t > > LinearMatrixComponent
Pair of data representing.
Definition: LinearModel.h:37
bfl::LinearModel::T_
double T_
The Sampling interval in [time].
Definition: LinearModel.h:56
bfl::LTIMeasurementModel
This class represent an linear measurement model Hx + w, where H is a time-invariant measurement matr...
Definition: LTIMeasurementModel.h:23
bfl::LinearModel::LinearModel
LinearModel(const LinearMatrixComponent &linear_matrix_component, const Eigen::Ref< const Eigen::MatrixXd > &noise_covariance_matrix, const unsigned int seed)
bfl::LinearModel::distribution_
std::normal_distribution< double > distribution_
Definition: LinearModel.h:78
bfl
Port of boost::any for C++11 compilers.
Definition: AdditiveMeasurementModel.h:13
bfl::LinearModel::gauss_rnd_sample_
std::function< double()> gauss_rnd_sample_
Random number generator function from a Normal distribution.
Definition: LinearModel.h:67
bfl::LinearModel::log_enabled_
bool log_enabled_
Definition: LinearModel.h:80
bfl::LinearModel::~LinearModel
virtual ~LinearModel() noexcept=default
bfl::LinearModel::sqrt_R_
Eigen::MatrixXd sqrt_R_
Square root matrix of R_.
Definition: LinearModel.h:61
bfl::LinearModel::getNoiseCovarianceMatrix
std::pair< bool, Eigen::MatrixXd > getNoiseCovarianceMatrix() const override
Definition: LinearModel.cpp:63
bfl::LinearModel::log_file_measurements_
std::ofstream log_file_measurements_
Definition: LinearModel.h:82
bfl::LinearModel::getNoiseSample
std::pair< bool, Eigen::MatrixXd > getNoiseSample(const int num) const
Definition: LinearModel.cpp:51
LTIMeasurementModel.h
bfl::LinearModel::generator_
std::mt19937_64 generator_
Definition: LinearModel.h:76
bfl::LinearModel::log_file_names
std::vector< std::string > log_file_names(const std::string &folder_path, const std::string &file_name_prefix) override
Definition: LinearModel.h:69
bfl::LinearModel::getMeasurementMatrix
Eigen::MatrixXd getMeasurementMatrix() const override
Definition: LinearModel.cpp:69