- 3.0.2 optimal control module.
ExtendedKalmanFilter.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 "EstimatorBase.h"
9 
10 namespace ct {
11 namespace optcon {
12 
13 template <size_t STATE_DIM, typename SCALAR>
15 
22 template <size_t STATE_DIM, size_t CONTROL_DIM, size_t OUTPUT_DIM, typename SCALAR = double>
23 class ExtendedKalmanFilter final : public EstimatorBase<STATE_DIM, CONTROL_DIM, OUTPUT_DIM, SCALAR>
24 {
25 public:
26  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
27 
29  using typename Base::control_vector_t;
30  using typename Base::output_matrix_t;
31  using typename Base::output_vector_t;
32  using typename Base::state_matrix_t;
33  using typename Base::state_vector_t;
34 
38  const state_matrix_t& Q,
39  const output_matrix_t& R,
40  const state_vector_t& x0 = state_vector_t::Zero(),
41  const state_matrix_t& P0 = state_matrix_t::Zero());
42 
47 
50  const ct::core::Time& dt,
51  const ct::core::Time& t) override;
52 
54  const state_vector_t& update(const output_vector_t& y, const ct::core::Time& dt, const ct::core::Time& t) override;
55 
56  // return current covariance matrix
58 
60  void setQ(const state_matrix_t& Q) { Q_ = Q; }
62  void setR(const output_matrix_t& R) { R_ = R; }
63 protected:
66 
69 
72 };
73 
74 } // namespace optcon
75 } // namespace ct
void setQ(const state_matrix_t &Q)
update Q matrix
Definition: ExtendedKalmanFilter.h:60
ct::core::OutputVector< OUTPUT_DIM, SCALAR > output_vector_t
Definition: EstimatorBase.h:29
ct::core::StateMatrix< STATE_DIM, SCALAR > state_matrix_t
Definition: EstimatorBase.h:28
const state_vector_t & update(const output_vector_t &y, const ct::core::Time &dt, const ct::core::Time &t) override
Estimator update method.
Definition: ExtendedKalmanFilter-impl.h:54
ct::core::ControlVector< control_dim > u
Definition: LoadFromFileTest.cpp:21
ct::core::OutputMatrix< OUTPUT_DIM, SCALAR > output_matrix_t
Definition: EstimatorBase.h:30
output_matrix_t R_
Filter R matrix.
Definition: ExtendedKalmanFilter.h:68
ct::core::StateVector< STATE_DIM, SCALAR > state_vector_t
Definition: EstimatorBase.h:27
clear all close all load ct GNMSLog0 mat reformat t
Definition: gnmsPlot.m:6
const double dt
Definition: LQOCSolverTiming.cpp:18
Linear Measurement Model is an interface for linear measurement models most commonly used in practice...
Definition: LinearMeasurementModel.h:23
ExtendedKalmanFilter(std::shared_ptr< SystemModelBase< STATE_DIM, CONTROL_DIM, SCALAR >> f, std::shared_ptr< LinearMeasurementModel< OUTPUT_DIM, STATE_DIM, SCALAR >> h, const state_matrix_t &Q, const output_matrix_t &R, const state_vector_t &x0=state_vector_t::Zero(), const state_matrix_t &P0=state_matrix_t::Zero())
Constructor.
Definition: ExtendedKalmanFilter-impl.h:12
state_matrix_t P_
Covariance estimate.
Definition: ExtendedKalmanFilter.h:71
System model is an interface that encapsulates the integrator to be able to propagate the system...
Definition: SystemModelBase.h:21
Settings for setting up an ExtendedKF.
Definition: ExtendedKalmanFilter.h:14
const state_matrix_t & getCovarianceMatrix()
Definition: ExtendedKalmanFilter-impl.h:76
Estimator base.
Definition: EstimatorBase.h:21
Extended Kalman Filter implementation. For an algorithmic overview, see also https://en.wikipedia.org/wiki/Extended_Kalman_filter.
Definition: ExtendedKalmanFilter.h:23
StateVector< state_dim > x0
Definition: ConstrainedNLOCTest.cpp:14
void setR(const output_matrix_t &R)
update R matrix
Definition: ExtendedKalmanFilter.h:62
ct::core::ControlVector< CONTROL_DIM, SCALAR > control_vector_t
Definition: EstimatorBase.h:26
const state_vector_t & predict(const control_vector_t &u, const ct::core::Time &dt, const ct::core::Time &t) override
Estimator predict method.
Definition: ExtendedKalmanFilter-impl.h:33
state_matrix_t Q_
Filter Q matrix.
Definition: ExtendedKalmanFilter.h:65
double Time