Bayes Filters Library
SimulatedStateModel.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 #include <iostream>
11 
12 using namespace bfl;
13 using namespace Eigen;
14 
15 
17 (
18  std::unique_ptr<StateModel> state_model,
19  const Ref<const VectorXd>& initial_state,
20  const unsigned int simulation_time
21 ) :
22  simulation_time_(simulation_time),
23  state_model_(std::move(state_model))
24 {
25  target_ = MatrixXd(initial_state.rows(), simulation_time_);
26  target_.col(0) = initial_state;
27 
28  for (int k = 1; k < simulation_time_; ++k)
29  state_model_->motion(target_.col(k - 1), target_.col(k));
30 }
31 
32 
34 {
35  ++current_simulation_time_;
36 
37  log();
38 
39  MatrixXd process_information = target_.col(current_simulation_time_ - 1);
40 
41  data_simulated_state_model_ = std::move(process_information);
42 
43  return true;
44 }
45 
46 
48 {
49  return data_simulated_state_model_;
50 }
51 
52 
53 bool SimulatedStateModel::setProperty(const std::string& property)
54 {
55  if (property == "reset")
56  {
57  current_simulation_time_ = 0;
58  std::cout << "Successfully reset state model." << std::endl;
59 
60  return true;
61  }
62 
63  return false;
64 }
65 
66 
68 {
69  return *state_model_;
70 }
71 
72 
74 {
75  logger(target_.col(current_simulation_time_ - 1).transpose());
76 }
bfl
Port of boost::any for C++11 compilers.
Definition: AdditiveMeasurementModel.h:13
SimulatedStateModel.h
bfl::SimulatedStateModel::setProperty
bool setProperty(const std::string &property) override
Definition: SimulatedStateModel.cpp:53
bfl::SimulatedStateModel::getStateModel
StateModel & getStateModel()
Definition: SimulatedStateModel.cpp:67
bfl::SimulatedStateModel::SimulatedStateModel
SimulatedStateModel(std::unique_ptr< StateModel > state_model, const Eigen::Ref< const Eigen::VectorXd > &initial_state, const unsigned int simulation_time)
Definition: SimulatedStateModel.cpp:17
bfl::StateModel
Definition: StateModel.h:22
bfl::SimulatedStateModel::getData
Data getData() const override
Definition: SimulatedStateModel.cpp:47
bfl::SimulatedStateModel::bufferData
bool bufferData() override
Definition: SimulatedStateModel.cpp:33
bfl::any::any
The class any describes a type-safe container for single values of any type.
Definition: any.h:77
bfl::SimulatedStateModel::log
void log() override
Definition: SimulatedStateModel.cpp:73