ekf_cal  0.4.0
A Kalman filter-based sensor calibration package
imu_updater.hpp
1 // Copyright 2023 Jacob Hartzer
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <https://www.gnu.org/licenses/>.
15 
16 #ifndef EKF__UPDATE__IMU_UPDATER_HPP_
17 #define EKF__UPDATE__IMU_UPDATER_HPP_
18 
19 #include <eigen3/Eigen/Eigen>
20 
21 #include <memory>
22 #include <string>
23 
24 #include "ekf/update/updater.hpp"
25 #include "infrastructure/data_logger.hpp"
26 
31 class ImuUpdater : public Updater
32 {
33 public:
43  ImuUpdater(
44  unsigned int imu_id,
45  bool is_extrinsic,
46  bool is_intrinsic,
47  const std::string & log_file_directory,
48  double data_log_rate,
49  std::shared_ptr<DebugLogger> logger
50  );
51 
57  Eigen::VectorXd PredictMeasurement(EKF & ekf);
58 
64  Eigen::MatrixXd GetZeroAccelerationJacobian(EKF & ekf);
65 
75  void UpdateEKF(
76  EKF & ekf,
77  double time,
78  const Eigen::Vector3d & acceleration,
79  const Eigen::Matrix3d & acceleration_covariance,
80  const Eigen::Vector3d & angular_rate,
81  const Eigen::Matrix3d & angular_rate_covariance
82  );
83 
94  EKF & ekf,
95  double local_time,
96  const Eigen::Vector3d & acceleration,
97  const Eigen::Matrix3d & acceleration_covariance,
98  const Eigen::Vector3d & angular_rate,
99  const Eigen::Matrix3d & angular_rate_covariance
100  );
101 
109  Eigen::MatrixXd GetMeasurementJacobian(EKF & ekf);
110 
117  void AngularUpdate(
118  EKF & ekf,
119  const Eigen::Vector3d & angular_rate,
120  const Eigen::Matrix3d & angular_rate_covariance
121  );
122 
123 private:
124  Eigen::Vector3d m_pos_i_in_g {0.0, 0.0, 0.0};
125  Eigen::Quaterniond m_ang_i_to_b {1.0, 0.0, 0.0, 0.0};
126  bool m_is_extrinsic;
127  bool m_is_intrinsic;
128  bool m_initial_motion_detected{false};
129  // bool m_correct_heading_rotation{true};
130 
131  DataLogger m_data_logger;
132 };
133 
134 #endif // EKF__UPDATE__IMU_UPDATER_HPP_
DataLogger class.
Definition: data_logger.hpp:26
Calibration EKF class.
Definition: ekf.hpp:39
EKF Updater Class for IMU Sensors.
Definition: imu_updater.hpp:32
Eigen::VectorXd PredictMeasurement(EKF &ekf)
Predict acceleration measurement.
Definition: imu_updater.cpp:301
void UpdateEKF(EKF &ekf, double time, const Eigen::Vector3d &acceleration, const Eigen::Matrix3d &acceleration_covariance, const Eigen::Vector3d &angular_rate, const Eigen::Matrix3d &angular_rate_covariance)
EKF update method for IMU measurements.
Definition: imu_updater.cpp:66
bool ZeroAccelerationUpdate(EKF &ekf, double local_time, const Eigen::Vector3d &acceleration, const Eigen::Matrix3d &acceleration_covariance, const Eigen::Vector3d &angular_rate, const Eigen::Matrix3d &angular_rate_covariance)
Check for and perform a zero-acceleration update.
Definition: imu_updater.cpp:182
Eigen::MatrixXd GetZeroAccelerationJacobian(EKF &ekf)
Zero acceleration Jacobian method.
Definition: imu_updater.cpp:155
void AngularUpdate(EKF &ekf, const Eigen::Vector3d &angular_rate, const Eigen::Matrix3d &angular_rate_covariance)
IMU state angular rate updater.
Definition: imu_updater.cpp:389
Eigen::MatrixXd GetMeasurementJacobian(EKF &ekf)
Calculate measurement jacobian.
Definition: imu_updater.cpp:328
ImuUpdater(unsigned int imu_id, bool is_extrinsic, bool is_intrinsic, const std::string &log_file_directory, double data_log_rate, std::shared_ptr< DebugLogger > logger)
IMU EKF Updater Constructor.
Definition: imu_updater.cpp:35
Base class for EKF updater classes.
Definition: updater.hpp:29