2 #include <old_calibrationn.h>
3 #include <Eigen/Cholesky>
22 Vector3f accelSamples[],
size_t n_samples)
44 Matrix<double, Dynamic, 4> H(n_samples, 4);
46 Matrix<double, Dynamic, 3> Y(n_samples, 3);
47 for (
unsigned i = 0;
i < n_samples; ++
i) {
48 H.row(
i) << accelSamples[
i].transpose().cast<
double>(), 1.0;
49 Y.row(
i) << gyroSamples[
i].transpose().cast<
double>();
53 Matrix<double, 4, 3> result;
55 (H.transpose() * H).ldlt().solve(H.transpose() * Y, &result);
59 bias = result.row(3).transpose().cast<
float>();
60 accelSensitivity = result.block<3, 3>(0, 0).transpose().cast<
float>();
64 Matrix<double, Dynamic, 7> C;
66 SVD<Matrix<double, Dynamic, 7>> usv(C);
67 Matrix<double, 4, 3> V_ab = usv.matrixV().block<4, 3>(0,
n);
68 Matrix<double, Dynamic, 3> V_bb = usv.matrixV().corner(BottomRight, n_samples - 4, 3);
75 Matrix<double, 3, 4> result;
76 V_bb.transpose().qr().solve(-V_ab.transpose(), &result);
79 bias = result.col(3).cast<
float>();
80 accelSensitivity = result.block<3, 3>(0, 0).cast<float>();
void gyroscope_calibration(Vector3f &bias, Matrix3f &accelSensitivity, Vector3f gyroSamples[], Vector3f accelSamples[], size_t n_samples)