mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
kalman_filter.h
Go to the documentation of this file.
1// clang: MatousFormat
7#ifndef SYSTEMMODEL_H
8#define SYSTEMMODEL_H
9
10#include <Eigen/Dense>
11#include <rclcpp/rclcpp.hpp>
12
13namespace mrs_lib
14{
15 /* KalmanFilter virtual class //{ */
24 template <int n_states, int n_inputs, int n_measurements>
26 {
27 public:
28 /* states, inputs etc. definitions (typedefs, constants etc) //{ */
29 static const int n = n_states;
30 static const int m = n_inputs;
31 static const int p = n_measurements;
33 typedef Eigen::Matrix<double, n, 1> x_t;
34 typedef Eigen::Matrix<double, m, 1> u_t;
35 typedef Eigen::Matrix<double, p, 1> z_t;
37 typedef Eigen::Matrix<double, n, n> P_t;
38 typedef Eigen::Matrix<double, p, p> R_t;
39 typedef Eigen::Matrix<double, n, n> Q_t;
40 //}
41
42 /* statecov_t struct //{ */
47 {
50 rclcpp::Time stamp = rclcpp::Time(0);
51 };
52 //}
53
54 public:
67 virtual statecov_t correct(const statecov_t& sc, const z_t& z, const R_t& R) const = 0;
68
83 virtual statecov_t predict(const statecov_t& sc, const u_t& u, const Q_t& Q, double dt) const = 0;
84 };
85 //}
86} // namespace mrs_lib
87
88#endif // SYSTEMMODEL_H
This abstract class defines common interfaces and types for a generic Kalman filter.
Definition kalman_filter.h:26
Eigen::Matrix< double, p, 1 > z_t
Measurement vector type .
Definition kalman_filter.h:35
Eigen::Matrix< double, p, p > R_t
Measurement noise covariance matrix type .
Definition kalman_filter.h:38
static const int n
Length of the state vector of the system.
Definition kalman_filter.h:29
static const int m
Length of the input vector of the system.
Definition kalman_filter.h:30
Eigen::Matrix< double, n, 1 > x_t
State vector type .
Definition kalman_filter.h:33
virtual statecov_t correct(const statecov_t &sc, const z_t &z, const R_t &R) const =0
Applies the correction (update, measurement, data) step of the Kalman filter.
static const int p
Length of the measurement vector of the system.
Definition kalman_filter.h:31
virtual statecov_t predict(const statecov_t &sc, const u_t &u, const Q_t &Q, double dt) const =0
Applies the prediction (time) step of the Kalman filter.
Eigen::Matrix< double, n, n > P_t
State uncertainty covariance matrix type .
Definition kalman_filter.h:37
Eigen::Matrix< double, n, n > Q_t
Process noise covariance matrix type .
Definition kalman_filter.h:39
Eigen::Matrix< double, m, 1 > u_t
Input vector type .
Definition kalman_filter.h:34
All mrs_lib functions, classes, variables and definitions are contained in this namespace.
Definition attitude_converter.h:24
Helper struct for passing around the state and its covariance in one variable.
Definition kalman_filter.h:47
x_t x
State vector.
Definition kalman_filter.h:48
P_t P
State covariance matrix.
Definition kalman_filter.h:49