bf_multi_res_scan_matcher.h
Go to the documentation of this file.
1 #ifndef SLAM_CTOR_CORE_BRUTE_FORCE_MULTIRES_SCAN_MATCHER_H
2 #define SLAM_CTOR_CORE_BRUTE_FORCE_MULTIRES_SCAN_MATCHER_H
3 
4 #include <utility>
5 
6 #include "grid_scan_matcher.h"
7 #include "m3rsm_engine.h"
8 #include "../maps/rescalable_caching_grid_map.h"
9 #include "../geometry_primitives.h"
10 
12 private: // consts
13  static constexpr double _Max_Translation_Error = 1,
15 public:
17  double ang_step = deg2rad(0.1),
18  double transl_step = 0.05)
21  , _ang_step{ang_step}, _transl_step{transl_step} {}
22 
23  void set_target_accuracy(double angle_step, double translation_step) {
24  _ang_step = angle_step;
25  _transl_step = translation_step;
26  }
27 
28  double process_scan(const TransformedLaserScan &raw_scan,
29  const RobotPose &pose,
30  const GridMap &map,
31  RobotPoseDelta &result_pose_delta) override {
32  do_for_each_observer([&pose, &raw_scan, &map](ObsPtr obs) {
33  obs->on_matching_start(pose, raw_scan, map);
34  });
35 
36  /* setup engine */
39  // TODO: dynamic angle step estimate
41 
42  // FIXME: API - const cast (inside the RAII obj) to be able to do rescaling
43  // NB: Do not make 'rescale' const (doing const_cast client probably
44  // won't forget to save/restore current scale)
45  SafeRescalableMap rescalable_map{map};
47  raw_scan.scan, rescalable_map, true);
48  while (1) {
49  auto best_match = _engine.next_best_match(_transl_step);
50  assert(best_match.is_valid());
51  if (best_match.is_finest()) {
52  result_pose_delta = {best_match.translation_drift.center(),
53  best_match.rotation};
54  do_for_each_observer([&result_pose_delta, &best_match](ObsPtr obs) {
55  obs->on_matching_end(result_pose_delta, *best_match.filtered_scan,
56  best_match.prob_upper_bound);
57  });
58  return best_match.prob_upper_bound;
59  }
60  // Add exact translation candidates as matches
61  // NB: center doesn't guarentee the optimal translation pick
62  // so (as a heuristic) test extra hypotheses in the rectangle.
63  auto crucial_points = best_match.translation_drift.corners();
64  crucial_points.push_back(best_match.translation_drift.center());
65 
66  for (const auto &cp : crucial_points) {
67  _engine.add_match(Match{M3RSMEngine::Rect{cp}, best_match});
68  }
69  }
70  }
71 
72 private:
75 };
76 
77 #endif // include guard
void set_translation_lookup_range(double max_x_error, double max_y_error)
Definition: m3rsm_engine.h:150
BruteForceMultiResolutionScanMatcher(SPE est, double ang_step=deg2rad(0.1), double transl_step=0.05)
std::shared_ptr< ScanProbabilityEstimator > SPE
void set_rotation_lookup_range(double sector, double step)
Definition: m3rsm_engine.h:155
Match next_best_match(double translation_step)
Definition: m3rsm_engine.h:198
std::shared_ptr< GridScanMatcherObserver > ObsPtr
void add_match(Match &&match)
Definition: m3rsm_engine.h:160
double process_scan(const TransformedLaserScan &raw_scan, const RobotPose &pose, const GridMap &map, RobotPoseDelta &result_pose_delta) override
void do_for_each_observer(std::function< void(ObsPtr)> op)
decltype(SPEParams{}.sp_analysis_area) Rect
Definition: m3rsm_engine.h:137
SPE scan_probability_estimator() const
void add_scan_matching_request(std::shared_ptr< ScanProbabilityEstimator > spe, const RobotPose &pose, const LaserScan2D &raw_scan, GridMap &map, bool prerotate_scan=false)
Definition: m3rsm_engine.h:171
constexpr double deg2rad(double angle_deg)
Definition: math_utils.h:56
void reset_engine_state()
Definition: m3rsm_engine.h:145
void set_target_accuracy(double angle_step, double translation_step)


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