ekf_cal  0.4.0
A Kalman filter-based sensor calibration package
msckf_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__MSCKF_UPDATER_HPP_
17 #define EKF__UPDATE__MSCKF_UPDATER_HPP_
18 
19 #include <eigen3/Eigen/Eigen>
20 
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 #include "ekf/types.hpp"
26 #include "ekf/update/updater.hpp"
27 #include "infrastructure/data_logger.hpp"
28 
33 class MsckfUpdater : public Updater
34 {
35 public:
45  explicit MsckfUpdater(
46  int cam_id,
47  bool is_cam_extrinsic,
48  const std::string & log_file_directory,
49  double data_log_rate,
50  double min_feat_dist,
51  std::shared_ptr<DebugLogger> logger
52  );
53 
62  bool TriangulateFeature(
63  double local_time,
64  EKF & ekf,
65  FeatureTrack & feature_track,
66  Eigen::Vector3d & pos_f_in_l);
67 
75  void UpdateEKF(
76  EKF & ekf,
77  double time,
78  FeatureTracks feature_tracks,
79  double px_error);
80 
88  const Eigen::Vector2d & uv_norm,
89  const Intrinsics & intrinsics,
90  Eigen::MatrixXd & H_d);
91 
97  void projection_jacobian(const Eigen::Vector3d & position, Eigen::MatrixXd & jacobian);
98 
99 private:
100  bool m_is_cam_extrinsic;
101  DataLogger m_msckf_logger;
102  DataLogger m_triangulation_logger;
103  double m_min_feat_dist{1.0};
104  double m_max_feat_dist{100.0};
105  bool m_is_first_estimate{true};
106  bool m_use_true_triangulation{true};
107  Intrinsics m_intrinsics;
108  Eigen::Vector3d m_pos_c_in_b{0.0, 0.0, 0.0};
109  Eigen::Quaterniond m_ang_c_to_b{1.0, 0.0, 0.0, 0.0};
110 };
111 
112 #endif // EKF__UPDATE__MSCKF_UPDATER_HPP_
DataLogger class.
Definition: data_logger.hpp:26
Calibration EKF class.
Definition: ekf.hpp:39
Camera intrinsics data structure.
Definition: types.hpp:49
EKF Updater Class for MSCKF Camera Measurements.
Definition: msckf_updater.hpp:34
MsckfUpdater(int cam_id, bool is_cam_extrinsic, const std::string &log_file_directory, double data_log_rate, double min_feat_dist, std::shared_ptr< DebugLogger > logger)
MSCKF EKF Updater constructor.
Definition: msckf_updater.cpp:39
bool TriangulateFeature(double local_time, EKF &ekf, FeatureTrack &feature_track, Eigen::Vector3d &pos_f_in_l)
Triangulate feature seen from multiple camera frames.
Definition: msckf_updater.cpp:71
void distortion_jacobian(const Eigen::Vector2d &uv_norm, const Intrinsics &intrinsics, Eigen::MatrixXd &H_d)
Computes the derivative of raw distorted to normalized coordinate.
Definition: msckf_updater.cpp:168
void UpdateEKF(EKF &ekf, double time, FeatureTracks feature_tracks, double px_error)
EKF updater function.
Definition: msckf_updater.cpp:214
void projection_jacobian(const Eigen::Vector3d &position, Eigen::MatrixXd &jacobian)
Function to calculate jacobian for camera projection function.
Definition: msckf_updater.cpp:157
Base class for EKF updater classes.
Definition: updater.hpp:29
FeatureTrack structure.
Definition: types.hpp:275