- 3.0.2 optimal control module.
EstimatorBase.h
Go to the documentation of this file.
1 /**********************************************************************************************************************
2 This file is part of the Control Toolbox (https://github.com/ethz-adrl/control-toolbox), copyright by ETH Zurich.
3 Licensed under the BSD-2 license (see LICENSE file in main directory)
4 **********************************************************************************************************************/
5 
6 #pragma once
7 
8 #include "FilterSettings.h"
9 #include "SystemModelBase.h"
10 #include "LinearMeasurementModel.h"
11 
12 namespace ct {
13 namespace optcon {
14 
20 template <size_t STATE_DIM, size_t CONTROL_DIM, size_t OUTPUT_DIM, typename SCALAR = double>
22 {
23 public:
24  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
25 
31 
35  const state_vector_t& x0 = state_vector_t::Zero())
36  : f_(f), h_(h), x_est_(x0)
37  {
38  }
39 
41  EstimatorBase(const EstimatorBase& arg) : f_(arg.f_->clone()), h_(arg.h_->clone()), x_est_(arg.x_est_) {}
42  virtual ~EstimatorBase() = default;
43 
45  virtual const state_vector_t& predict(const control_vector_t& u,
46  const ct::core::Time& dt,
47  const ct::core::Time& t) = 0;
48 
50  virtual const state_vector_t& update(const output_vector_t& y,
51  const ct::core::Time& dt,
52  const ct::core::Time& t) = 0;
53 
59  const state_vector_t& getEstimate() const { return x_est_; }
61  void setEstimate(const state_vector_t& x) { x_est_ = x; }
62 protected:
64  std::shared_ptr<SystemModelBase<STATE_DIM, CONTROL_DIM, SCALAR>> f_;
65 
67  std::shared_ptr<LinearMeasurementModel<OUTPUT_DIM, STATE_DIM, SCALAR>> h_;
68 
71 };
72 
73 } // namespace optcon
74 } // namespace ct
std::shared_ptr< SystemModelBase< STATE_DIM, CONTROL_DIM, SCALAR > > f_
System model for propagating the system.
Definition: EstimatorBase.h:64
void setMeasurementModel(std::shared_ptr< LinearMeasurementModel< OUTPUT_DIM, STATE_DIM, SCALAR >> h)
update the measurement model
Definition: EstimatorBase.h:57
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
const state_vector_t & getEstimate() const
Estimate getter.
Definition: EstimatorBase.h:59
void setEstimate(const state_vector_t &x)
Estimate setter.
Definition: EstimatorBase.h:61
std::shared_ptr< LinearMeasurementModel< OUTPUT_DIM, STATE_DIM, SCALAR > > h_
Observation model used to calculate the output error.
Definition: EstimatorBase.h:67
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
const double dt
Definition: LQOCSolverTiming.cpp:18
virtual const state_vector_t & predict(const control_vector_t &u, const ct::core::Time &dt, const ct::core::Time &t)=0
Estimator predict method.
Linear Measurement Model is an interface for linear measurement models most commonly used in practice...
Definition: LinearMeasurementModel.h:23
virtual ~EstimatorBase()=default
state_vector_t x_est_
State estimate.
Definition: EstimatorBase.h:70
void setSystemModel(std::shared_ptr< SystemModelBase< STATE_DIM, CONTROL_DIM, SCALAR >> f)
update the system model
Definition: EstimatorBase.h:55
ct::core::StateVector< state_dim > x
Definition: LoadFromFileTest.cpp:20
System model is an interface that encapsulates the integrator to be able to propagate the system...
Definition: SystemModelBase.h:21
EstimatorBase(const EstimatorBase &arg)
Copy constructor.
Definition: EstimatorBase.h:41
Estimator base.
Definition: EstimatorBase.h:21
StateVector< state_dim > x0
Definition: ConstrainedNLOCTest.cpp:14
virtual const state_vector_t & update(const output_vector_t &y, const ct::core::Time &dt, const ct::core::Time &t)=0
Estimator update method.
EstimatorBase(std::shared_ptr< SystemModelBase< STATE_DIM, CONTROL_DIM, SCALAR >> f, std::shared_ptr< LinearMeasurementModel< OUTPUT_DIM, STATE_DIM, SCALAR >> h, const state_vector_t &x0=state_vector_t::Zero())
Constructor.
Definition: EstimatorBase.h:33
double Time