AlignUtils.h
Go to the documentation of this file.
1 /*
2  * OpenVINS: An Open Platform for Visual-Inertial Research
3  * Copyright (C) 2018-2023 Patrick Geneva
4  * Copyright (C) 2018-2023 Guoquan Huang
5  * Copyright (C) 2018-2023 OpenVINS Contributors
6  * Copyright (C) 2018-2019 Kevin Eckenhoff
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef OV_EVAL_ALIGNUTILS_H
23 #define OV_EVAL_ALIGNUTILS_H
24 
25 #include <Eigen/Eigen>
26 #include <iostream>
27 #include <sstream>
28 #include <string>
29 #include <vector>
30 
31 #include "utils/colors.h"
32 #include "utils/print.h"
33 #include "utils/quat_ops.h"
34 
35 namespace ov_eval {
36 
45 class AlignUtils {
46 
47 public:
53  static inline double get_best_yaw(const Eigen::Matrix<double, 3, 3> &C) {
54  double A = C(0, 1) - C(1, 0);
55  double B = C(0, 0) + C(1, 1);
56  // return M_PI_2 - atan2(B, A);
57  return atan2(A, B);
58  }
59 
65  static inline Eigen::Matrix<double, 3, 1> get_mean(const std::vector<Eigen::Matrix<double, 3, 1>> &data) {
66  Eigen::Matrix<double, 3, 1> mean = Eigen::Matrix<double, 3, 1>::Zero();
67  for (size_t i = 0; i < data.size(); i++) {
68  mean.noalias() += data[i];
69  }
70  mean /= data.size();
71  return mean;
72  }
73 
86  static void align_umeyama(const std::vector<Eigen::Matrix<double, 3, 1>> &data, const std::vector<Eigen::Matrix<double, 3, 1>> &model,
87  Eigen::Matrix<double, 3, 3> &R, Eigen::Matrix<double, 3, 1> &t, double &s, bool known_scale, bool yaw_only);
88 
94  static void perform_association(double offset, double max_difference, std::vector<double> &est_times, std::vector<double> &gt_times,
95  std::vector<Eigen::Matrix<double, 7, 1>> &est_poses, std::vector<Eigen::Matrix<double, 7, 1>> &gt_poses);
96 
102  static void perform_association(double offset, double max_difference, std::vector<double> &est_times, std::vector<double> &gt_times,
103  std::vector<Eigen::Matrix<double, 7, 1>> &est_poses, std::vector<Eigen::Matrix<double, 7, 1>> &gt_poses,
104  std::vector<Eigen::Matrix3d> &est_covori, std::vector<Eigen::Matrix3d> &est_covpos,
105  std::vector<Eigen::Matrix3d> &gt_covori, std::vector<Eigen::Matrix3d> &gt_covpos);
106 };
107 
108 } // namespace ov_eval
109 
110 #endif // OV_EVAL_ALIGNUTILS_H
static void perform_association(double offset, double max_difference, std::vector< double > &est_times, std::vector< double > &gt_times, std::vector< Eigen::Matrix< double, 7, 1 >> &est_poses, std::vector< Eigen::Matrix< double, 7, 1 >> &gt_poses)
Will intersect our loaded data so that we have common timestamps.
Definition: AlignUtils.cpp:95
XmlRpcServer s
Evaluation and recording utilities.
static Eigen::Matrix< double, 3, 1 > get_mean(const std::vector< Eigen::Matrix< double, 3, 1 >> &data)
Gets mean of the vector of data.
Definition: AlignUtils.h:65
Helper functions for the trajectory alignment class.
Definition: AlignUtils.h:45
static void align_umeyama(const std::vector< Eigen::Matrix< double, 3, 1 >> &data, const std::vector< Eigen::Matrix< double, 3, 1 >> &model, Eigen::Matrix< double, 3, 3 > &R, Eigen::Matrix< double, 3, 1 > &t, double &s, bool known_scale, bool yaw_only)
Given a set of points in a model frame and a set of points in a data frame, finds best transform betw...
Definition: AlignUtils.cpp:26
static double get_best_yaw(const Eigen::Matrix< double, 3, 3 > &C)
Gets best yaw from Frobenius problem. Equation (17)-(18) in Zhang et al. 2018 IROS paper...
Definition: AlignUtils.h:53


ov_eval
Author(s): Patrick Geneva , Kevin Eckenhoff , Guoquan Huang
autogenerated on Wed Jun 21 2023 03:05:40