angle_histogram_test.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 #include <cmath>
3 
4 #include "../../../src/core/states/sensor_data.h"
5 #include "../../../src/core/features/angle_histogram.h"
6 
7 class AHAngleEstimationTest : public ::testing::Test {
8 protected:
9  void test_angle_estimation(const Point2D &p1, const Point2D &p2, double exp) {
10  auto sp1 = ScanPoint2D::make_cartesian({p1.x, p1.y}, false);
11  auto sp2 = ScanPoint2D::make_cartesian({p2.x, p2.y}, false);
13  }
14 
15  void verify_angle(double expected_deg, double actual_rad) {
16  ASSERT_NEAR(expected_deg, rad2deg(actual_rad), 0.1);
17  }
18 };
19 
21  test_angle_estimation({5, 3}, {7, 3}, 0);
22 }
23 
25  test_angle_estimation({5, 3}, {6, 3 + std::tan(deg2rad(30))}, 30);
26 }
27 
29  test_angle_estimation({5, 3}, {15, 13}, 45);
30 }
31 
33  test_angle_estimation({5, 3}, {5, 10}, 90);
34 }
35 
37  test_angle_estimation({5, 3}, {-5, 13}, 135);
38 }
39 
41  // NB: the estimated angle must be 0 (not 180),
42  // since 180 is equivalent to 0 according to the AH logic.
43  test_angle_estimation({5, 3}, {0, 3}, 0);
44 }
45 
47  test_angle_estimation({5, 3}, {-5, -7}, 45);
48 }
49 
51  test_angle_estimation({5, 3}, {5, -10}, 90);
52 }
53 
55  test_angle_estimation({5, 3}, {15, -7}, 135);
56 }
57 
59  test_angle_estimation({5, 3}, {6, 3 - std::tan(deg2rad(30))}, 150);
60 }
61 
62 //----------------------------------------------------------------------------//
63 
64 int main (int argc, char *argv[]) {
65  ::testing::InitGoogleTest(&argc, argv);
66  return RUN_ALL_TESTS();
67 }
static double estimate_ox_based_angle(const LaserScan2D::Points::value_type &base, const LaserScan2D::Points::value_type &sp)
static ScanPoint2D make_cartesian(const Point2D &p, bool is_occ)
Definition: sensor_data.h:23
int main(int argc, char *argv[])
void verify_angle(double expected_deg, double actual_rad)
TEST_F(AHAngleEstimationTest, angle0)
constexpr double rad2deg(double angle_rad)
Definition: math_utils.h:60
void test_angle_estimation(const Point2D &p1, const Point2D &p2, double exp)
constexpr double deg2rad(double angle_deg)
Definition: math_utils.h:56


slam_constructor
Author(s): JetBrains Research, OSLL team
autogenerated on Mon Jun 10 2019 15:08:25