testAHRS.cpp
Go to the documentation of this file.
1 /*
2  * @file testAHRS.cpp
3  * @brief Test AHRS
4  * @author Frank Dellaert
5  * @author Chris Beall
6  */
7 
8 #include "../AHRS.h"
9 #include <gtsam/geometry/Rot3.h>
10 #include <gtsam/base/Vector.h>
11 #include <gtsam/base/Testable.h>
13 #include <list>
14 
15 using namespace std;
16 using namespace gtsam;
17 
18 // stationary interval of gyro U and acc F
19 Matrix stationaryU = trans((Matrix(3, 3) << -0.0004,-0.0002,-0.0014,0.0006,-0.0003,0.0007,0.0006,-0.0002,-0.0003).finished());
20 Matrix stationaryF = trans((Matrix(3, 3) << 0.1152,-0.0188,9.7419,-0.0163,0.0146,9.7753,-0.0283,-0.0428,9.9021).finished());
21 double g_e = 9.7963; // Atlanta
22 
23 /* ************************************************************************* */
24 TEST (AHRS, cov) {
25 
26  // samples stored by row
27  Matrix A = (Matrix(4, 3) <<
28  1.0, 2.0, 3.0,
29  5.0, 7.0, 0.0,
30  9.0, 4.0, 7.0,
31  6.0, 3.0, 2.0).finished();
32 
33  Matrix actual = AHRS::Cov(trans(A));
34  Matrix expected = (Matrix(3, 3) <<
35  10.9167, 2.3333, 5.0000,
36  2.3333, 4.6667, -2.6667,
37  5.0000, -2.6667, 8.6667).finished();
38 
39  EXPECT(assert_equal(expected, actual, 1e-4));
40 }
41 
42 /* ************************************************************************* */
43 TEST (AHRS, covU) {
44 
45  Matrix actual = AHRS::Cov(10000*stationaryU);
46  Matrix expected = (Matrix(3, 3) <<
47  33.3333333, -1.66666667, 53.3333333,
48  -1.66666667, 0.333333333, -5.16666667,
49  53.3333333, -5.16666667, 110.333333).finished();
50 
51  EXPECT(assert_equal(expected, actual, 1e-4));
52 }
53 
54 /* ************************************************************************* */
55 TEST (AHRS, covF) {
56 
57  Matrix actual = AHRS::Cov(100*stationaryF);
58  Matrix expected = (Matrix(3, 3) <<
59  63.3808333, -0.432166667, -48.1706667,
60  -0.432166667, 8.31053333, -16.6792667,
61  -48.1706667, -16.6792667, 71.4297333).finished();
62 
63  EXPECT(assert_equal(expected, actual, 1e-4));
64 }
65 
66 /* ************************************************************************* */
69 }
70 
71 /* ************************************************************************* */
72 // TODO make a testMechanization_bRn2
73 TEST(AHRS, Mechanization_integrate) {
75  // const auto [mech, state] = ahrs.initialize(g_e);
76  // Vector u = Vector3(0.05, 0.0, 0.0);
77  // double dt = 2;
78  // Rot3 expected;
79  // Mechanization_bRn2 mech2 = mech.integrate(u, dt);
80  // Rot3 actual = mech2.bRn();
81  // EXPECT(assert_equal(expected, actual));
82 }
83 
84 /* ************************************************************************* */
85 /* TODO: currently fails because of problem with ill-conditioned system
86 TEST (AHRS, init) {
87  AHRS ahrs = AHRS(stationaryU,stationaryF,g_e);
88  std::pair<Mechanization_bRn2, KalmanFilter::State> result = ahrs.initialize(g_e);
89 }
90 */
91 /* ************************************************************************* */
92 int main() {
93  TestResult tr;
94  return TestRegistry::runAllTests(tr);
95 }
96 /* ************************************************************************* */
97 
TestRegistry::runAllTests
static int runAllTests(TestResult &result)
Definition: TestRegistry.cpp:27
main
int main()
Definition: testAHRS.cpp:92
g_e
double g_e
Definition: testAHRS.cpp:21
Vector.h
typedef and functions to augment Eigen's VectorXd
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Testable.h
Concept check for values that can be used in unit tests.
EXPECT
#define EXPECT(condition)
Definition: Test.h:150
TestHarness.h
gtsam::AHRS
Definition: AHRS.h:16
trans
static char trans
Definition: blas_interface.hh:58
gtsam::Matrix
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
A
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition: bench_gemm.cpp:48
Rot3.h
3D rotation represented as a rotation matrix or quaternion
ceres::Matrix
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > Matrix
Definition: gtsam/3rdparty/ceres/eigen.h:42
cholesky::expected
Matrix expected
Definition: testMatrix.cpp:971
TestResult
Definition: TestResult.h:26
gtsam
traits
Definition: SFMdata.h:40
constructor
Definition: init.h:200
std
Definition: BFloat16.h:88
TEST
TEST(AHRS, cov)
Definition: testAHRS.cpp:24
gtsam::assert_equal
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Definition: Matrix.cpp:41
stationaryU
Matrix stationaryU
Definition: testAHRS.cpp:19
stationaryF
Matrix stationaryF
Definition: testAHRS.cpp:20


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:16:02