bf_multi_res_sm_smoke_test.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 
3 #include <limits>
4 
5 #include "../mock_grid_cell.h"
7 
8 #include "../../../src/core/scan_matchers/occupancy_observation_probability.h"
9 #include "../../../src/core/scan_matchers/bf_multi_res_scan_matcher.h"
10 #include "../../../src/core/maps/plain_grid_map.h"
11 #include "../../../src/core/maps/lazy_tiled_grid_map.h"
12 #include "../../../src/core/maps/rescalable_caching_grid_map.h"
13 
14 template <typename Map>
16  : public ScanMatcherTestBase<Map> {
17 protected: // names
20  using SPW = EvenSPW;
21 protected: // methods
23  : ScanMatcherTestBase<Map>{std::make_shared<SPE>(std::make_shared<OOPE>(),
24  std::make_shared<SPW>()),
30  }
31 protected: // consts
32  // map patching params
33  static constexpr int Cecum_Patch_W = 15, Cecum_Patch_H = 13;
34  static constexpr int Patch_Scale = 1;
35 
36  // NB: use 1/2^n is order to increase perfromance
37  static constexpr double Map_Scale = 0.125;
38  static constexpr int Map_Width = 100;
39  static constexpr int Map_Height = 100;
40 
41  // laser scanner params
42  static constexpr double LS_Max_Dist = 15;
43  static constexpr int LS_FoW = 270;
44  static constexpr int LS_Pts_Nm = 5000;
45 
46  // scan matcher
47  static constexpr double SM_Max_Rotation_Error = deg2rad(5);
48  static constexpr double SM_Max_Translation_Error = Map_Scale * 10; // meters
49  static constexpr double SM_Ang_Step = deg2rad(0.5);
50  static constexpr double SM_Transl_Step = Map_Scale / 2;
51 
52 protected: // fields
53 
54  GridScanMatcher& scan_matcher() override { return bfmrsm; };
55 
57  return {SM_Transl_Step, SM_Transl_Step, SM_Ang_Step};
58  }
59 
61  using CecumMp = CecumTextRasterMapPrimitive;
62  auto bnd_pos = CecumMp::BoundPosition::Top;
63  auto cecum_mp = CecumMp{Cecum_Patch_W, Cecum_Patch_H, bnd_pos};
64  this->add_primitive_to_map(cecum_mp, {}, Patch_Scale, Patch_Scale);
65 
66  this->rpose += RobotPoseDelta{
67  (cecum_mp.width() * Patch_Scale / 2) * this->map.scale(),
68  (-cecum_mp.height() * Patch_Scale + 1) * this->map.scale(),
69  deg2rad(90)
70  };
71  }
72 
73 protected: // fields
75 };
76 
77 
78 //------------------------------------------------------------------------------
79 // Smoke Tests Suite
80 // NB: the suit checks _fundamental_ abilities to find a correction.
81 // The suit check raw (w/o a map approximator speed up) BFMRSM correctness.
82 
83 template <typename MapType>
85  : public BFMRScanMatcherTestBase<MapType> {};
86 
87 //------------------------------------------------------------------------------
88 // Tests
89 
90 using MapTs = ::testing::Types<UnboundedPlainGridMap,
92 
94 
97  this->test_scan_matcher(RobotPoseDelta{0, 0, 0});
98 }
99 
100 TYPED_TEST(BFMRScanMatcherSmokeTest, cecumLinStepXLeftDrift) {
101  const auto Translation_Error = this->SM_Max_Translation_Error / 2;
103  this->test_scan_matcher(RobotPoseDelta{-Translation_Error, 0, 0});
104 }
105 
106 TYPED_TEST(BFMRScanMatcherSmokeTest, cecumLinStepXRightDrift) {
107  const auto Translation_Error = this->SM_Max_Translation_Error / 2;
109  this->test_scan_matcher(RobotPoseDelta{Translation_Error, 0, 0});
110 }
111 
112 TYPED_TEST(BFMRScanMatcherSmokeTest, cecumLinStepYUpDrift) {
113  const auto Translation_Error = this->SM_Max_Translation_Error / 2;
115  this->test_scan_matcher(RobotPoseDelta{0, -Translation_Error, 0});
116 }
117 
118 TYPED_TEST(BFMRScanMatcherSmokeTest, cecumLinStepYDownDrift) {
119  const auto Translation_Error = this->SM_Max_Translation_Error / 2;
121  this->test_scan_matcher(RobotPoseDelta{0, Translation_Error, 0});
122 }
123 
124 TYPED_TEST(BFMRScanMatcherSmokeTest, cecumAngStepThetaCcwDrift) {
125  const auto Rotation_Error = this->SM_Max_Rotation_Error;
127  this->test_scan_matcher(RobotPoseDelta{0, 0, Rotation_Error});
128 }
129 
130 TYPED_TEST(BFMRScanMatcherSmokeTest, cecumAngStepThetaCwDrift) {
131  const auto Rotation_Error = this->SM_Max_Rotation_Error;
133  this->test_scan_matcher(RobotPoseDelta{0, 0, -Rotation_Error});
134 }
135 
136 TYPED_TEST(BFMRScanMatcherSmokeTest, cecumComboStepsDrift) {
137  const auto Translation_Error = this->SM_Max_Translation_Error / 2;
138  const auto Rotation_Error = this->SM_Max_Rotation_Error;
140  auto noise = RobotPoseDelta{-Translation_Error, Translation_Error,
141  -Rotation_Error};
142  this->test_scan_matcher(noise);
143 }
144 
145 //------------------------------------------------------------------------------
146 // A suit with tests specific to RescalabeMap
147 // Motivation: some test cases run slowly on a plain map.
148 
150 
152  : public BFMRScanMatcherTestBase<RescalableMap> {};
153 
155  const auto Translation_Error = this->SM_Max_Translation_Error / 2;
156  const auto Rotation_Error = this->SM_Max_Rotation_Error;
158  auto noise = RobotPoseDelta{-Translation_Error, Translation_Error,
159  Rotation_Error};
160  this->bfmrsm.set_lookup_ranges(this->SM_Max_Translation_Error * 10,
161  this->SM_Max_Translation_Error * 10,
162  this->SM_Max_Rotation_Error);
163  this->test_scan_matcher(noise);
164 }
165 
166 //------------------------------------------------------------------------------
167 
168 // TODO: More sophisticated testing (e.g. an arbitrary noise cases,
169 // high res map/scanner, map state, etc.) is supposed to be implemented
170 // with a separate test suite.
171 
172 //------------------------------------------------------------------------------
173 
174 int main (int argc, char *argv[]) {
175  ::testing::InitGoogleTest(&argc, argv);
176  return RUN_ALL_TESTS();
177 }
static constexpr auto to_lsp(double max_dist, double fow_deg, unsigned pts_nm)
static constexpr double SM_Transl_Step
BruteForceMultiResolutionScanMatcher bfmrsm
TYPED_TEST(BFMRScanMatcherSmokeTest, cecumNoPoseNoise)
static constexpr double LS_Max_Dist
static constexpr double SM_Max_Rotation_Error
static constexpr double SM_Max_Translation_Error
int main(int argc, char *argv[])
static constexpr double SM_Ang_Step
typename ScanMatcherTestBase< MapType >::DefaultSPE SPE
::testing::Types< UnboundedPlainGridMap, RescalableCachingGridMap< UnboundedPlainGridMap >> MapTs
void test_scan_matcher(const LaserScannerParams &lsp, const RobotPoseDelta &noise, const RobotPoseDelta &acc_error)
virtual void add_primitive_to_map(const TextRasterMapPrimitive &mp, const DiscretePoint2D &offset, int w_scale, int h_scale)
static constexpr double Map_Scale
TYPED_TEST_CASE(BFMRScanMatcherSmokeTest, MapTs)
std::shared_ptr< ScanProbabilityEstimator > spe
TEST_F(BFMRScanMatcherResclalableMapSpecificTest, hugeWindowLookup)
constexpr double deg2rad(double angle_deg)
Definition: math_utils.h:56
RobotPoseDelta default_acceptable_error() override
GridScanMatcher & scan_matcher() override


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