mars_lib  0.1.0.3dc76ee85e09
Modular and Robust Sensor-Fusion
bind_sensor_data.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 BASESENSORDATA_H
12 #define BASESENSORDATA_H
13 
16 #include <Eigen/Dense>
17 
18 namespace mars
19 {
20 template <typename T>
29 {
30  static_assert(std::is_base_of<BaseStates, T>::value, "Type T must inherit from Class BaseStates");
31 
32 public:
33  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
34 
35  T state_;
37  Eigen::MatrixXd sensor_cov_;
38  Eigen::MatrixXd core_sensor_cross_cov_;
39 
41  {
42  core_sensor_cross_cov_ = Eigen::MatrixXd::Zero(CoreStateType::size_error_, state_.cov_size_);
43  sensor_cov_ = Eigen::MatrixXd::Zero(state_.cov_size_, state_.cov_size_);
45  }
46 
51  void set_cov(const Eigen::MatrixXd& cov)
52  {
53  // TODO(chb) allow this with changing sensor state sizes
56  }
57 
63  Eigen::MatrixXd get_full_cov() const
64  {
65  // TODO(chb) allow this with changing sensor state sizes
66  Eigen::MatrixXd full_cov;
67  full_cov.resize(full_cov_size_, full_cov_size_);
68 
69  // Set core elements to zero
72 
73  // Fill sensor covariance
74  full_cov.block(CoreStateType::size_error_, CoreStateType::size_error_, state_.cov_size_, state_.cov_size_) =
76 
77  // Fill cross covariance
78  full_cov.block(0, CoreStateType::size_error_, CoreStateType::size_error_, state_.cov_size_) =
80  full_cov.block(CoreStateType::size_error_, 0, state_.cov_size_, CoreStateType::size_error_) =
81  core_sensor_cross_cov_.transpose();
82 
83  return full_cov;
84  }
85 };
86 } // namespace mars
87 
88 #endif // BASESENSORDATA_H
The BaseSensorData class binds the sensor state and covariance matrix.
Definition: bind_sensor_data.h:29
EIGEN_MAKE_ALIGNED_OPERATOR_NEW T state_
Definition: bind_sensor_data.h:30
BindSensorData()
Definition: bind_sensor_data.h:40
int full_cov_size_
size of the full covariance
Definition: bind_sensor_data.h:36
void set_cov(const Eigen::MatrixXd &cov)
set_cov Takes a full covariance and separates sensor covariance and sensor-core cross-correlation
Definition: bind_sensor_data.h:51
Eigen::MatrixXd get_full_cov() const
get_full_cov builds the full covariance matrix
Definition: bind_sensor_data.h:63
Eigen::MatrixXd core_sensor_cross_cov_
cross-correlation between sensor states and the core
Definition: bind_sensor_data.h:38
Eigen::MatrixXd sensor_cov_
covariance of the sensor states
Definition: bind_sensor_data.h:37
static constexpr int size_error_
Definition: core_state_type.h:38
Definition: buffer.h:27