test/common.h
Go to the documentation of this file.
1 #include "test_board.h"
2 
3 #include "rosflight.h"
4 
5 #include <turbomath/turbomath.h>
6 
7 #include <eigen3/Eigen/Core>
8 #include <eigen3/Eigen/Dense>
9 #include <eigen3/Eigen/Geometry>
10 #include <gtest/gtest.h>
11 
12 #include <cstdint>
13 
14 #define EXPECT_VEC3_SUPERCLOSE(vec, eig) \
15  EXPECT_NEAR((vec).x, (eig).x(), 0.0001); \
16  EXPECT_NEAR((vec).y, (eig).y(), 0.0001); \
17  EXPECT_NEAR((vec).z, (eig).z(), 0.0001)
18 #define EXPECT_QUAT_SUPERCLOSE(q, q_eig) \
19  { \
20  double e1 = quaternion_error((q_eig), (q)); \
21  Eigen::Quaternionf q_eig_neg = q_eig; \
22  q_eig_neg.coeffs() *= -1.0; \
23  double e2 = quaternion_error(q_eig_neg, (q)); \
24  double error = (e1 < e2) ? e1 : e2; \
25  EXPECT_LE(error, 0.0001); \
26  }
27 #define ASSERT_QUAT_SUPERCLOSE(q, q_eig) \
28  { \
29  double e1 = quaternion_error((q_eig), (q)); \
30  Eigen::Quaternionf q_eig_neg = q_eig; \
31  q_eig_neg.coeffs() *= -1.0; \
32  double e2 = quaternion_error(q_eig_neg, (q)); \
33  double error = (e1 < e2) ? e1 : e2; \
34  EXPECT_LE(error, 0.0001); \
35  }
36 
37 #define ASSERT_TURBOQUAT_SUPERCLOSE(q, q2) \
38  { \
39  double e1 = quaternion_error(q, q2); \
40  turbomath::Quaternion q2_neg = q2; \
41  q2_neg.w *= -1.0; \
42  q2_neg.x *= -1.0; \
43  q2_neg.y *= -1.0; \
44  q2_neg.z *= -1.0; \
45  double e2 = quaternion_error(q, q2_neg); \
46  double error = (e1 < e2) ? e1 : e2; \
47  ASSERT_LE(error, 0.0001); \
48  }
49 
50 #define EXPECT_BASICALLYTHESAME(x, y) EXPECT_NEAR(x, y, 0.00001)
51 #define EXPECT_SUPERCLOSE(x, y) EXPECT_NEAR(x, y, 0.0001)
52 #define EXPECT_CLOSE(x, y) EXPECT_NEAR(x, y, 0.01)
53 #define EXPECT_INTHESAMEBALLPARK(x, y) EXPECT_NEAR(x, y, 0.1)
54 
55 #define ASSERT_BASICALLYTHESAME(x, y) ASSERT_NEAR(x, y, 0.00001)
56 #define ASSERT_SUPERCLOSE(x, y) ASSERT_NEAR(x, y, 0.0001)
57 #define ASSERT_CLOSE(x, y) ASSERT_NEAR(x, y, 0.01)
58 #define ASSERT_INTHESAMEBALLPARK(x, y) ASSERT_NEAR(x, y, 0.1)
59 
61 double quaternion_error(Eigen::Quaternionf q_eig, turbomath::Quaternion q);
62 
void step_firmware(rosflight_firmware::ROSflight &rf, rosflight_firmware::testBoard &board, uint32_t us)
Definition: common.cpp:30
double quaternion_error(turbomath::Quaternion q0, turbomath::Quaternion q)
Definition: common.cpp:16


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Sat May 9 2020 03:16:52