grid_scan_matcher.h
Go to the documentation of this file.
1 
7 #ifndef __GRID_SCAN_MATCHER_H
8 #define __GRID_SCAN_MATCHER_H
9 
10 #include <vector>
11 #include <memory>
12 #include <algorithm>
13 
14 #include "state_data.h"
15 #include "sensor_data.h"
16 
21 public:
28  virtual void on_matching_start(const RobotState &, /*pose*/
29  const TransformedLaserScan &, /*scan*/
30  const GridMap &) {} /*map*/
31 
37  virtual void on_scan_test(const RobotState &, /*pose*/
38  const TransformedLaserScan &, /*scan*/
39  double) {}; /*score*/
40 
47  virtual void on_pose_update(const RobotState &, /*pose*/
48  const TransformedLaserScan &, /*scan*/
49  double) {}; /*score*/
50 
55  virtual void on_matching_end(const RobotState &, /*delta*/
56  double) {}; /*best_score*/
57 };
58 
64 public:
65 
72  virtual double estimate_scan_cost(const RobotState &pose,
73  const TransformedLaserScan &scan,
74  const GridMap &map,
75  double min_cost) = 0;
76 };
77 
85 public:
86  GridScanMatcher(std::shared_ptr<ScanCostEstimator> estimator) :
87  _cost_estimator(estimator) {}
88 
97  virtual double process_scan(const RobotState &init_pose,
98  const TransformedLaserScan &scan,
99  const GridMap &map,
100  RobotState &pose_delta) = 0;
101 
103  virtual void reset_state() {};
104 
109  void subscribe(std::shared_ptr<GridScanMatcherObserver> obs) {
110  _observers.push_back(obs);
111  }
112 
117  void unsubscribe(std::shared_ptr<GridScanMatcherObserver> obs) {
118  // TODO: replace with more ideomatic C++
119  std::vector<std::weak_ptr<GridScanMatcherObserver>> new_observers;
120  for (auto &raw_obs : GridScanMatcher::observers()) {
121  auto obs_ptr = raw_obs.lock();
122  if (obs_ptr && obs_ptr != obs) {
123  new_observers.push_back(raw_obs);
124  }
125  }
126  _observers = new_observers;
127  }
128 
129 protected:
131  std::shared_ptr<ScanCostEstimator> cost_estimator() {
132  return _cost_estimator;
133  }
134 
136  std::vector<std::weak_ptr<GridScanMatcherObserver>> & observers() {
137  return _observers;
138  }
139 private:
140  std::vector<std::weak_ptr<GridScanMatcherObserver>> _observers;
141  std::shared_ptr<ScanCostEstimator> _cost_estimator;
142 };
143 
144 #endif
std::shared_ptr< ScanCostEstimator > cost_estimator()
Returns a pointer to the cost estimator.
virtual void on_matching_end(const RobotState &, double)
void subscribe(std::shared_ptr< GridScanMatcherObserver > obs)
An occupancy grid implementation.
Definition: grid_map.h:22
GridScanMatcher(std::shared_ptr< ScanCostEstimator > estimator)
virtual void on_scan_test(const RobotState &, const TransformedLaserScan &, double)
virtual void on_matching_start(const RobotState &, const TransformedLaserScan &, const GridMap &)
Defines some structures related to data obtained from sensors. There are structures ScanPoint and Tra...
Class that matches scans. Performes a scan adjustment by altering a robot pose in order to maximize t...
virtual void on_pose_update(const RobotState &, const TransformedLaserScan &, double)
std::vector< std::weak_ptr< GridScanMatcherObserver > > & observers()
Returns a reference to the vector of pointers on observers.
std::vector< std::weak_ptr< GridScanMatcherObserver > > _observers
void unsubscribe(std::shared_ptr< GridScanMatcherObserver > obs)
Interface of scan matcher observer.
Defines a robot position in cartesian coordinates and an angle of rotation.
Definition: state_data.h:14
Defines some classes related to a robot state. There are classes RobotState and World.
virtual void reset_state()
Invoked to reset the scan matcher&#39;s state.
Framework internal representation of a laser scan.
Definition: sensor_data.h:33
Interface of Estimator of Scan Cost. Cost - is a number that complies to a scan; the lower cost the b...
std::shared_ptr< ScanCostEstimator > _cost_estimator


tiny_slam
Author(s):
autogenerated on Mon Jun 10 2019 15:30:57