dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
alignment-calibration.cpp
Go to the documentation of this file.
1 #include "calibration.h"
2 #include <Eigen/Core>
3 #include <Eigen/Cholesky>
4 #include <Eigen/Geometry>
5 
6 using namespace Eigen;
7 
23 void calibration_misalignment(Vector3f &rotationVector, const Vector3f samples0[],
24  const Vector3f &reference0, const Vector3f samples1[],
25  const Vector3f &reference1, size_t n_samples)
26 {
27  // Note that this implementation makes the assumption that the angular
28  // misalignment is small. Something based on QUEST would be needed to
29  // account for errors larger than a few degrees.
30  Matrix<double, Dynamic, 3> X(n_samples, 3);
31  Matrix<double, Dynamic, 1> y(n_samples, 1);
32 
33  AngleAxisd reference(
34  Quaterniond().setFromTwoVectors(reference0.cast<double>(), reference1.cast<double>()));
35  for (size_t i = 0; i < n_samples; ++i) {
36  AngleAxisd observation(Quaterniond().setFromTwoVectors(samples0[i].cast<double>(),
37  samples1[i].cast<double>()));
38 
39  X.row(i) = observation.axis();
40  y[i] = reference.angle() - observation.angle();
41  }
42 
43  // Run linear least squares over the result.
44  Vector3d result;
45  (X.transpose() * X).ldlt().solve(X.transpose() * y, &result);
46  rotationVector = result.cast<float>();
47 }
for i
Definition: OPPlots.m:140
void calibration_misalignment(Vector3f &rotationVector, const Vector3f samples0[], const Vector3f &reference0, const Vector3f samples1[], const Vector3f &reference1, size_t n_samples)
Gui-less support class for calibration.
y
Definition: OPPlots.m:101