7 #include <eigen3/Eigen/Core> 8 #include <eigen3/Eigen/Dense> 9 #include <eigen3/Eigen/Geometry> 10 #include <gtest/gtest.h> 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) \ 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); \ 27 #define ASSERT_QUAT_SUPERCLOSE(q, q_eig) \ 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); \ 37 #define ASSERT_TURBOQUAT_SUPERCLOSE(q, q2) \ 39 double e1 = quaternion_error(q, q2); \ 40 turbomath::Quaternion q2_neg = q2; \ 45 double e2 = quaternion_error(q, q2_neg); \ 46 double error = (e1 < e2) ? e1 : e2; \ 47 ASSERT_LE(error, 0.0001); \ 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) 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)
void step_firmware(rosflight_firmware::ROSflight &rf, rosflight_firmware::testBoard &board, uint32_t us)
double quaternion_error(turbomath::Quaternion q0, turbomath::Quaternion q)