mars_lib  0.1.0.3dc76ee85e09
Modular and Robust Sensor-Fusion
core_state.h
Go to the documentation of this file.
1 // Copyright (C) 2021 Christian Brommer, Control of Networked Systems, University of Klagenfurt, Austria.
2 //
3 // All rights reserved.
4 //
5 // This software is licensed under the terms of the BSD-2-Clause-License with
6 // no commercial use allowed, the full terms of which are made available
7 // in the LICENSE file. No license in patents is granted.
8 //
9 // You can contact the author at <christian.brommer@ieee.org>
10 
11 #ifndef CORESTATE_H
12 #define CORESTATE_H
13 
16 #include <mars/time.h>
19 #include <Eigen/Dense>
20 
21 namespace mars
22 {
23 class CoreState
24 {
25 private:
26  bool fixed_acc_bias_{ false };
27  bool fixed_gyro_bias_{ false };
28 
29 public:
30  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
31 
33 
34  // Noise (STD)
35  Eigen::Vector3d n_a_{ Eigen::Vector3d::Zero() };
36  Eigen::Vector3d n_ba_{ Eigen::Vector3d::Zero() };
37  Eigen::Vector3d n_w_{ Eigen::Vector3d::Zero() };
38  Eigen::Vector3d n_bw_{ Eigen::Vector3d::Zero() };
39 
40  const Eigen::Vector3d g_{ 0, 0, 9.81 };
41 
43 
44  std::shared_ptr<SensorAbsClass> propagation_sensor_{ nullptr };
45 
46  bool test_state_transition_{ false };
47  bool verbose_{ false };
48 
53 
58  void set_fixed_acc_bias(const bool& value);
59 
64  void set_fixed_gyro_bias(const bool& value);
65 
70  void set_propagation_sensor(std::shared_ptr<SensorAbsClass> propagation_sensor);
71 
79  void set_noise_std(const Eigen::Vector3d& n_w, const Eigen::Vector3d& n_bw, const Eigen::Vector3d& n_a,
80  const Eigen::Vector3d& n_ba);
81 
93  CoreStateType InitializeState(const Eigen::Vector3d& ang_vel, const Eigen::Vector3d& lin_acc,
94  const Eigen::Vector3d& p_wi, const Eigen::Vector3d& v_wi,
95  const Eigen::Quaterniond& q_wi, const Eigen::Vector3d& b_w, const Eigen::Vector3d& b_a);
96 
101  void set_initial_covariance(const Eigen::Vector3d& p, const Eigen::Vector3d& v, const Eigen::Vector3d& q,
102  const Eigen::Vector3d& bw, const Eigen::Vector3d& ba);
103 
109 
123  CoreStateType PropagateState(const CoreStateType& prior_state, const IMUMeasurementType& measurement,
124  const double& dt);
133  CoreType PredictProcessCovariance(const CoreType& prior_core_state, const IMUMeasurementType& system_input,
134  const double& dt);
135 
136  // Static
142 
149 
162  static CoreStateMatrix GenerateFdSmallAngleApprox(const Eigen::Quaterniond& q_wi, const Eigen::Vector3d& a_est,
163  const Eigen::Vector3d& w_est, const double& dt);
164  static CoreStateMatrix CalcQSmallAngleApprox(const double& dt, const Eigen::Quaterniond& q_wi,
165  const Eigen::Vector3d& a_m, const Eigen::Vector3d& n_a,
166  const Eigen::Vector3d& b_a, const Eigen::Vector3d& n_ba,
167  const Eigen::Vector3d& w_m, const Eigen::Vector3d& n_w,
168  const Eigen::Vector3d& b_w, const Eigen::Vector3d& n_bw);
169 };
170 } // namespace mars
171 
172 #endif // CORESTATE_H
Definition: core_state.h:24
Eigen::Vector3d n_bw_
random walk for angular velocity bias
Definition: core_state.h:38
CoreStateMatrix InitializeCovariance()
InitializeCovariance Returnes the initialized core covariance.
bool fixed_acc_bias_
bias are not estimated if fixed_bias = true
Definition: core_state.h:26
bool verbose_
increased output of information
Definition: core_state.h:47
bool fixed_gyro_bias_
bias are not estimated if fixed_bias = true
Definition: core_state.h:27
Eigen::Vector3d n_ba_
random walk for linear acceleration bias
Definition: core_state.h:36
void set_noise_std(const Eigen::Vector3d &n_w, const Eigen::Vector3d &n_bw, const Eigen::Vector3d &n_a, const Eigen::Vector3d &n_ba)
set_noise_std Sets the noise and bias of the propagation sensor
void set_fixed_gyro_bias(const bool &value)
set_fixed_gyro_bias disable or enable the estimation of the gyro bias
void set_initial_covariance(const Eigen::Vector3d &p, const Eigen::Vector3d &v, const Eigen::Vector3d &q, const Eigen::Vector3d &bw, const Eigen::Vector3d &ba)
set_initial_covariance used to set the initial covariance of the core states
EIGEN_MAKE_ALIGNED_OPERATOR_NEW CoreStateType state
Core State elements.
Definition: core_state.h:32
static CoreStateMatrix GenerateFdSmallAngleApprox(const Eigen::Quaterniond &q_wi, const Eigen::Vector3d &a_est, const Eigen::Vector3d &w_est, const double &dt)
GenerateFdSmallAngleApprox Generates the state-transition matrix with small angle approximation.
CoreState()
CoreState Default constructor.
static CoreStateMatrix CalcQSmallAngleApprox(const double &dt, const Eigen::Quaterniond &q_wi, const Eigen::Vector3d &a_m, const Eigen::Vector3d &n_a, const Eigen::Vector3d &b_a, const Eigen::Vector3d &n_ba, const Eigen::Vector3d &w_m, const Eigen::Vector3d &n_w, const Eigen::Vector3d &b_w, const Eigen::Vector3d &n_bw)
CoreStateType InitializeState(const Eigen::Vector3d &ang_vel, const Eigen::Vector3d &lin_acc, const Eigen::Vector3d &p_wi, const Eigen::Vector3d &v_wi, const Eigen::Quaterniond &q_wi, const Eigen::Vector3d &b_w, const Eigen::Vector3d &b_a)
InitializeState Initializes the core state.
void set_fixed_acc_bias(const bool &value)
set_fixed_acc_bias disable or enable the estimation of the accelerometer bias
CoreStateType PropagateState(const CoreStateType &prior_state, const IMUMeasurementType &measurement, const double &dt)
PropagateState Performs the state propagation.
static CoreStateMatrix GenerateFdClosedForm()
GenerateFdClosedForm Generates the state-transition matrix in closed-form.
Eigen::Vector3d n_a_
noise for linear acceleration measurement
Definition: core_state.h:35
bool test_state_transition_
If true, the class performs tests on the state-transition properties.
Definition: core_state.h:46
static CoreStateMatrix GenerateFdTaylor()
GenerateFdTaylor Generates the state-transition matrix with cut-off Taylor series.
Eigen::Vector3d n_w_
noise for angular velocity measurement
Definition: core_state.h:37
void set_propagation_sensor(std::shared_ptr< SensorAbsClass > propagation_sensor)
set_propagation_sensor Stores a reference to the propagation sensor
CoreStateMatrix initial_covariance_
Definition: core_state.h:42
std::shared_ptr< SensorAbsClass > propagation_sensor_
Reference to the propagation sensor.
Definition: core_state.h:44
CoreType PredictProcessCovariance(const CoreType &prior_core_state, const IMUMeasurementType &system_input, const double &dt)
PredictProcessCovariance Predicted core state covariance and generate the state transition matrix.
const Eigen::Vector3d g_
defined gravity
Definition: core_state.h:40
Definition: core_state_type.h:21
Definition: core_type.h:19
Definition: imu_measurement_type.h:21
Definition: buffer.h:27
Eigen::Matrix< double, CoreStateType::size_error_, CoreStateType::size_error_ > CoreStateMatrix
Definition: core_state_type.h:134