mars_lib  0.1.0.3dc76ee85e09
Modular and Robust Sensor-Fusion
mag_utils.h
Go to the documentation of this file.
1 // Copyright (C) 2022 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 MAG_UTILS_H
12 #define MAG_UTILS_H
13 
14 #include <Eigen/Dense>
15 #include <vector>
16 
17 namespace mars
18 {
20 {
21 public:
22  MagnetometerInit() = default;
23 
30  void AddElement(const Eigen::Vector3d& mag_vector, const Eigen::Vector3d& imu_linear_acc_vector);
31 
36  Eigen::Matrix3d get_rot() const;
37 
42  Eigen::Quaterniond get_quat() const;
43 
48  int get_size() const;
49 
53  void set_done();
54 
59  bool IsDone() const;
60 
66  void Reset();
67 
78  static Eigen::Vector3d mag_var_ang_to_vec(const double& dec, const double& inc, const double& r = 1);
79 
83  class MagImuData
84  {
85  public:
91  MagImuData(const Eigen::Vector3d& mag_vec, const Eigen::Vector3d& imu_vec) : mag_vec_(mag_vec), imu_vec_(imu_vec)
92  {
93  }
97  Eigen::Vector3d mag_vec_;
98 
102  Eigen::Vector3d imu_vec_;
103  };
104 
110 
111 private:
115  std::vector<MagImuData> rot_init_vec_;
116 
120  bool once_{ false };
121 };
122 } // namespace mars
123 
124 #endif // MAG_UTILS_H
The MagImuData class keeps a pair of magnetometer and imu linear acceleration measurements.
Definition: mag_utils.h:84
MagImuData(const Eigen::Vector3d &mag_vec, const Eigen::Vector3d &imu_vec)
MagImuData.
Definition: mag_utils.h:91
Eigen::Vector3d imu_vec_
imu_vec_ Single vector of an IMU linear acceleration measurement
Definition: mag_utils.h:102
Eigen::Vector3d mag_vec_
mag_vec_ Single vector of a magnetometer measurement
Definition: mag_utils.h:97
Definition: mag_utils.h:20
void Reset()
Reset Reset the initialization module.
Eigen::Matrix3d get_rot() const
get_rot Get the rotation matrix for the vector pairs in the buffer
void AddElement(const Eigen::Vector3d &mag_vector, const Eigen::Vector3d &imu_linear_acc_vector)
AddElement Add magnetometer and imu measurement pairs to buffer IMU and Magnetometer vectors nee to b...
void set_done()
set_done Set if the rotation initialization was done
bool IsDone() const
IsDone Check if the initialization was done.
int get_size() const
get_size Get the current size of the buffer
MagImuData get_vec_mean() const
get_vec_mean Get the mean of the Mag and IMU vectors in the measurement buffer
std::vector< MagImuData > rot_init_vec_
rot_init_vec_ Measurement buffer
Definition: mag_utils.h:115
static Eigen::Vector3d mag_var_ang_to_vec(const double &dec, const double &inc, const double &r=1)
mag_var_ang_to_vec Perform Spherical to Cartesian conversion for a vector in the GNSS world frame
bool once_
once_ Indicate if the intialization was done
Definition: mag_utils.h:120
Eigen::Quaterniond get_quat() const
get_quat Same as 'get_rot' but as quaternion
Definition: buffer.h:27