hill_climbing_scan_matcher.h
Go to the documentation of this file.
1 #ifndef SLAM_CTOR_CORE_HILL_CLIMBING_SCAN_MATCHER_H
2 #define SLAM_CTOR_CORE_HILL_CLIMBING_SCAN_MATCHER_H
3 
4 #include <memory>
5 
7 
8 // TODO: move to pose enumerators
10 public:
11  Distorsion1DPoseEnumerator(double translation_delta,
12  double rotation_delta)
13  : _action_id{0}
14  , _translation_delta{translation_delta}
15  , _rotation_delta{rotation_delta}
16  , _base_pose_is_set{false} {
17  reset();
18  }
19 
20  bool has_next() const override { return _action_id < DirNm * DimNm; }
21 
22  RobotPose next(const RobotPose &prev_pose) override {
23  if (!_base_pose_is_set) {
24  _base_pose = prev_pose;
25  _base_pose_is_set = true;
26  }
27  auto distorted_pose = _base_pose;
28 
29  double shift_value = _action_id % DirNm ? -1 : 1;
30  double *shiftee;
31  switch (_action_id % DimNm) {
32  case X:
33  shiftee = &distorted_pose.x, shift_value *= _translation_delta; break;
34  case Y:
35  shiftee = &distorted_pose.y, shift_value *= _translation_delta; break;
36  case Th:
37  shiftee = &distorted_pose.theta, shift_value *= _rotation_delta; break;
38  default:
39  assert(0 && "Missed shift destination");
40  }
41  *shiftee += shift_value;
42 
43  ++_action_id;
44  return distorted_pose;
45  }
46 
47  void reset() override {}
48  void feedback(bool pose_is_acceptable) override {}
49 
50 private:
51  enum Dim {X = 0, Y, Th, DimNm};
52  enum Dir {Inc = 0, Dec, DirNm};
53  static_assert(DimNm % 2 != DirNm % 2, "");
54 private:
55  std::size_t _action_id;
57 
60 };
61 
62 
63 template <typename BasePoseEnumerator>
65 public:
66  FailedRoundsLimitedPoseEnumerator(unsigned max_failed_rounds,
67  double translation_delta,
68  double rotation_delta)
69  : _max_failed_rounds{max_failed_rounds}
70  , _base_translation_delta{translation_delta}
71  , _base_rotation_delta{rotation_delta} {
72  reset();
73  }
74 
75  bool has_next() const override {
76  return _failed_rounds < _max_failed_rounds;
77  }
78 
79  RobotPose next(const RobotPose &prev_pose) override {
80  if (!_round_pe.has_next()) {
81  if (_round_failed) {
82  _translation_delta *= 0.5;
83  _rotation_delta *= 0.5;
84  ++_failed_rounds;
85  }
86  reset_round(_translation_delta, _rotation_delta);
87  }
88  return _round_pe.next(prev_pose);
89  }
90 
91  void reset() override {
92  _failed_rounds = 0;
93  _translation_delta = _base_translation_delta;
94  _rotation_delta = _base_rotation_delta;
95 
96  reset_round(_translation_delta, _rotation_delta);
97  }
98 
99  void feedback(bool pose_is_acceptable) override {
100  _round_failed &= !pose_is_acceptable;
101  _round_pe.feedback(pose_is_acceptable);
102  }
103 
104 private:
105  void reset_round(double translation_delta, double rotation_delta) {
106  _round_pe = {_translation_delta, _rotation_delta};
107  _round_failed = true;
108  }
109 private:
111  double _base_translation_delta, _base_rotation_delta;
112 
113  unsigned _failed_rounds;
115 
116  BasePoseEnumerator _round_pe{0, 0};
118 };
119 
121 private:
123 public:
124  // FIXME: update enumerator on set_lookup_ranges update
125  HillClimbingScanMatcher(std::shared_ptr<ScanProbabilityEstimator> estimator,
126  unsigned max_lookup_attempts_failed,
127  double translation_delta, double rotation_delta)
129  estimator,
130  std::make_shared<HCPE>(max_lookup_attempts_failed,
131  translation_delta, rotation_delta)
132  } {}
133 };
134 
135 #endif
FailedRoundsLimitedPoseEnumerator(unsigned max_failed_rounds, double translation_delta, double rotation_delta)
void feedback(bool pose_is_acceptable) override
RobotPose next(const RobotPose &prev_pose) override
RobotPose next(const RobotPose &prev_pose) override
void feedback(bool pose_is_acceptable) override
void reset_round(double translation_delta, double rotation_delta)
Distorsion1DPoseEnumerator(double translation_delta, double rotation_delta)
HillClimbingScanMatcher(std::shared_ptr< ScanProbabilityEstimator > estimator, unsigned max_lookup_attempts_failed, double translation_delta, double rotation_delta)


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