brute_force_scan_matcher.h
Go to the documentation of this file.
1 #ifndef SLAM_CTOR_CORE_BRUTE_FORCE_SCAN_MATCHER_H
2 #define SLAM_CTOR_CORE_BRUTE_FORCE_SCAN_MATCHER_H
3 
4 #include <cassert>
5 
7 
8 // TODO: move to pose enumerators
9 // FIXME: class name
11 public:
12  BruteForcePoseEnumerator(double from_x, double to_x, double step_x,
13  double from_y, double to_y, double step_y,
14  double from_t, double to_t, double step_t)
15  : _base_pose_is_set{false}
16  , _from_x{from_x}, _to_x{to_x}, _step_x{step_x}
17  , _from_y{from_y}, _to_y{to_y}, _step_y{step_y}
18  , _from_t{from_t}, _to_t{to_t}, _step_t{step_t} {
19  assert(_from_x <= _to_x && _from_y <= _to_y && _from_t <= _to_t);
20  reset();
21  }
22 
23  bool has_next() const override {
24  return _t <= _to_t; // NB: "top-level" changing dimension
25  }
26 
27  RobotPose next(const RobotPose &prev_pose) override {
28  if (!_base_pose_is_set) {
29  _base_pose = prev_pose;
30  _base_pose_is_set = true;
31  }
32 
33  return {_base_pose.x + _x, _base_pose.y + _y, _base_pose.theta + _t};
34  }
35 
36  void reset() override {
37  _x = _from_x;
38  _y = _from_y;
39  _t = _from_t;
40  }
41 
42  void feedback(bool pose_is_acceptable) override {
43  // HACK: use switch falls to simplify code (no nested ifs/d_y, d_t tracking
44  switch (0) {
45  case 0:
46  if (_x < _to_x) { _x += _step_x; break; }
47  else { _x = _from_x; /* to Y */ }
48  case 1:
49  if (_y < _to_y) { _y += _step_y; break; }
50  else { _y = _from_y; /* to T */ }
51  case 2:
52  _t += _step_t;
53  }
54  }
55 
56 private:
57  // TODO: use std::optional when C++17 is available
60 
61  double _from_x, _x, _to_x, _step_x;
62  double _from_y, _y, _to_y, _step_y;
63  double _from_t, _t, _to_t, _step_t;
64 };
65 
66 // TODO: add a PoseEnumerationScanMatcher descendant
67 
69 public:
70  BruteForceScanMatcher(std::shared_ptr<ScanProbabilityEstimator> estimator,
71  double from_x, double to_x, double step_x,
72  double from_y, double to_y, double step_y,
73  double from_t, double to_t, double step_t)
75  estimator,
76  std::make_shared<BruteForcePoseEnumerator>(from_x, to_x, step_x,
77  from_y, to_y, step_y,
78  from_t, to_t, step_t)
79  } {}
80 };
81 
82 #endif
BruteForceScanMatcher(std::shared_ptr< ScanProbabilityEstimator > estimator, double from_x, double to_x, double step_x, double from_y, double to_y, double step_y, double from_t, double to_t, double step_t)
double theta
Definition: robot_pose.h:131
void feedback(bool pose_is_acceptable) override
BruteForcePoseEnumerator(double from_x, double to_x, double step_x, double from_y, double to_y, double step_y, double from_t, double to_t, double step_t)
RobotPose next(const RobotPose &prev_pose) override
bool has_next() const override
double y
Definition: robot_pose.h:131
double x
Definition: robot_pose.h:131


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