mars_lib  0.1.0.3dc76ee85e09
Modular and Robust Sensor-Fusion
utils.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 UTILS_H
12 #define UTILS_H
13 
15 #include <Eigen/Dense>
16 #include <string>
17 #include <vector>
18 
19 namespace mars
20 {
21 class Utils
22 {
23 public:
24  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
25 
26  Utils();
27 
32  static std::string get_mars_version_string();
33 
37  static void PrintMarsVersion();
38 
51  static void TransformImu(const mars::IMUMeasurementType& prev, const mars::IMUMeasurementType& now, const double& dt,
52  const Eigen::Vector3d& p_ab, const Eigen::Quaterniond& q_ab,
53  mars::IMUMeasurementType& result);
54 
66  static void TransformImu(const mars::IMUMeasurementType& now, const Eigen::Vector3d& p_ab,
67  const Eigen::Quaterniond& q_ab, mars::IMUMeasurementType& result);
68 
74  static Eigen::Matrix3d Skew(const Eigen::Vector3d& v);
75 
82  static Eigen::Matrix4d MatExp(const Eigen::Matrix4d& A, const int& order = 4);
83 
91  static Eigen::Matrix4d OmegaMat(const Eigen::Vector3d& v);
92 
98  static Eigen::Quaterniond QuatFromSmallAngle(const Eigen::Vector3d& d_theta_vec);
99 
106  static Eigen::Quaterniond ApplySmallAngleQuatCorr(const Eigen::Quaterniond& q_prior,
107  const Eigen::Vector3d& correction);
108 
114  static Eigen::Vector3d RPYFromRotMat(const Eigen::Matrix3d& rot_mat);
115 
123  static bool CheckCov(const Eigen::MatrixXd& cov_mat, const std::string& description, const bool& check_cond = false);
124 
130  static Eigen::MatrixXd EnforceMatrixSymmetry(const Eigen::Ref<const Eigen::MatrixXd>& mat_in);
131 
140  static Eigen::Quaterniond quaternionAverage(const std::vector<Eigen::Quaterniond>& quats);
141 
148  template <typename T, typename A>
149  static std::vector<T> VecExtractEveryNthElm(std::vector<T, A> const& data, const int& nth)
150  {
151  std::vector<T> every_nth_data;
152  const int len = data.size();
153 
154  for (int k = 0; k < len - nth; k += nth)
155  {
156  every_nth_data.push_back(data[k]);
157  }
158  return every_nth_data;
159  }
160 
161  static Eigen::Quaterniond NormalizeQuaternion(const Eigen::Quaterniond& quat, std::string note = "");
162  static Eigen::Quaterniond NormalizeQuaternion(const double& w, const double& x, const double& y, const double& z,
163  std::string note = "");
164 };
165 } // namespace mars
166 
167 #endif // UTILS_H
Definition: imu_measurement_type.h:21
Definition: utils.h:22
static Eigen::Matrix4d OmegaMat(const Eigen::Vector3d &v)
omega_mat ight multiplication
static Eigen::Quaterniond NormalizeQuaternion(const Eigen::Quaterniond &quat, std::string note="")
static Eigen::MatrixXd EnforceMatrixSymmetry(const Eigen::Ref< const Eigen::MatrixXd > &mat_in)
EnforceMatrixSymmetry.
static bool CheckCov(const Eigen::MatrixXd &cov_mat, const std::string &description, const bool &check_cond=false)
check_cov Performs tests for the properties of a given covariance matrix
static Eigen::Matrix3d Skew(const Eigen::Vector3d &v)
skew generate the skew symmetric matrix of v
static Eigen::Quaterniond quaternionAverage(const std::vector< Eigen::Quaterniond > &quats)
quaternionAverage without weights
static void TransformImu(const mars::IMUMeasurementType &now, const Eigen::Vector3d &p_ab, const Eigen::Quaterniond &q_ab, mars::IMUMeasurementType &result)
TransformImu Transform IMU measurements from current frame A to frame B.
static Eigen::Matrix4d MatExp(const Eigen::Matrix4d &A, const int &order=4)
mat_exp Calculation of the matrix exponential, Taylor series cut-off at specified order
static Eigen::Vector3d RPYFromRotMat(const Eigen::Matrix3d &rot_mat)
RPYFromRotMat derives the roll pitch and yaw angle from a rotation matrix (in that order)
static void TransformImu(const mars::IMUMeasurementType &prev, const mars::IMUMeasurementType &now, const double &dt, const Eigen::Vector3d &p_ab, const Eigen::Quaterniond &q_ab, mars::IMUMeasurementType &result)
TransformImu Transform IMU measurements from current frame A to frame B.
static Eigen::Quaterniond NormalizeQuaternion(const double &w, const double &x, const double &y, const double &z, std::string note="")
static std::string get_mars_version_string()
get_mars_version_string
static Eigen::Quaterniond QuatFromSmallAngle(const Eigen::Vector3d &d_theta_vec)
QuatFromSmallAngle.
static std::vector< T > VecExtractEveryNthElm(std::vector< T, A > const &data, const int &nth)
VecExtractEveryNthElm Takes a vector and returns a new vector which only contains every n'th element.
Definition: utils.h:149
static void PrintMarsVersion()
PrintMarsVersion.
EIGEN_MAKE_ALIGNED_OPERATOR_NEW Utils()
static Eigen::Quaterniond ApplySmallAngleQuatCorr(const Eigen::Quaterniond &q_prior, const Eigen::Vector3d &correction)
ApplySmallAngleQuatCorr.
Definition: buffer.h:27