| 10 | using namespace PLPSLAM; |
| 11 | |
| 12 | TEST(essential_solver, linear_solve) |
| 13 | { |
| 14 | // create 3D points |
| 15 | const unsigned int num_landmarks = 100; |
| 16 | const auto landmarks = create_random_landmarks_in_space(num_landmarks, 100); |
| 17 | |
| 18 | // create two-view poses |
| 19 | const Mat33_t rot_1 = util::converter::to_rot_mat(205.0 * M_PI / 180.0 * Vec3_t{4, -6, 2}.normalized()); |
| 20 | const Vec3_t trans_1 = Vec3_t(-28.1, -63.3, 43.4); |
| 21 | const Mat33_t rot_2 = util::converter::to_rot_mat(-15.0 * M_PI / 180.0 * Vec3_t{5, 1, -3}.normalized()); |
| 22 | const Vec3_t trans_2 = Vec3_t(-30.4, -45.5, -49.6); |
| 23 | |
| 24 | // create bearing vectors from two-view poses and 3D points |
| 25 | eigen_alloc_vector<Vec3_t> bearings_1; |
| 26 | eigen_alloc_vector<Vec3_t> bearings_2; |
| 27 | create_bearing_vectors(rot_1, trans_1, landmarks, bearings_1); |
| 28 | create_bearing_vectors(rot_2, trans_2, landmarks, bearings_2); |
| 29 | |
| 30 | // create a true essential matrix |
| 31 | Mat33_t true_E_21 = solve::essential_solver::create_E_21(rot_1, trans_1, rot_2, trans_2); |
| 32 | |
| 33 | // solve with SVD |
| 34 | Mat33_t E_21 = solve::essential_solver::compute_E_21(bearings_1, bearings_2); |
| 35 | |
| 36 | // align scale and sign |
| 37 | true_E_21 /= true_E_21.norm(); |
| 38 | E_21 /= E_21.norm(); |
| 39 | if (true_E_21(0, 0) * E_21(0, 0) < 0) |
| 40 | { |
| 41 | true_E_21 *= -1.0; |
| 42 | } |
| 43 | |
| 44 | EXPECT_LT((true_E_21 - E_21).norm(), 1e-4); |
| 45 | } |
| 46 | |
| 47 | TEST(essential_solver, ransac_solve_without_noise) |
| 48 | { |
nothing calls this directly
no test coverage detected