1 #ifndef SLAM_CTOR_CORE_GRID_SCAN_MATCHER_H 2 #define SLAM_CTOR_CORE_GRID_SCAN_MATCHER_H 9 #include "../states/state_data.h" 10 #include "../states/sensor_data.h" 11 #include "../states/robot_pose.h" 12 #include "../maps/occupancy_map.h" 13 #include "../maps/grid_map.h" 55 bool scan_is_prerotated =
false;
57 using OOPE = std::shared_ptr<OccupancyObservationProbabilityEstimator>;
62 return std::numeric_limits<double>::quiet_NaN();
66 return probability == unknown_probability();
75 return _oope->probability(aoo, area, map);
86 return estimate_scan_probability(scan, pose, map,
SPEParams{});
89 virtual double estimate_scan_probability(
const LaserScan2D &scan,
101 using ObsPtr = std::shared_ptr<GridScanMatcherObserver>;
102 using SPE = std::shared_ptr<ScanProbabilityEstimator>;
106 double max_x_error = 0,
double max_y_error = 0,
107 double max_th_error = 0)
108 : _scan_prob_estimator{estimator}
109 , _max_x_error{max_x_error}, _max_y_error{max_y_error}
110 , _max_th_error{max_th_error} {}
121 void subscribe(std::shared_ptr<GridScanMatcherObserver> obs) {
122 _observers.push_back(obs);
127 std::vector<std::weak_ptr<GridScanMatcherObserver>> new_observers;
129 auto obs_ptr = raw_obs.lock();
130 if (obs_ptr && obs_ptr != obs) {
131 new_observers.push_back(raw_obs);
134 _observers = new_observers;
145 return scan_probability_estimator()->filter_scan(scan, pose, map);
150 return _scan_prob_estimator->estimate_scan_probability(scan, pose, map);
155 return _scan_prob_estimator->estimate_scan_probability(scan, pose, map, p);
159 return _scan_prob_estimator;
163 _scan_prob_estimator = spe;
168 std::vector<std::weak_ptr<GridScanMatcherObserver>> &
observers() {
173 for (
auto &obs : observers()) {
174 if (
auto obs_ptr = obs.lock()) {
185 std::vector<std::weak_ptr<GridScanMatcherObserver>>
_observers;
187 double _max_x_error = 0, _max_y_error = 0, _max_th_error = 0;
virtual void on_scan_test(const RobotPose &, const LaserScan2D &, double)
ScanProbabilityEstimator(OOPE oope)
virtual LaserScan2D filter_scan(const LaserScan2D &scan, const RobotPose &, const GridMap &)
std::shared_ptr< ScanProbabilityEstimator > SPE
void subscribe(std::shared_ptr< GridScanMatcherObserver > obs)
static constexpr double unknown_probability()
double occupancy_observation_probability(const AreaOccupancyObservation &aoo, const LightWeightRectangle &area, const GridMap &map) const
virtual void on_matching_end(const RobotPose &, const LaserScan2D &, double)
std::shared_ptr< GridScanMatcherObserver > ObsPtr
std::shared_ptr< OccupancyObservationProbabilityEstimator > OOPE
OOPE occupancy_observation_probability_estimator() const
TFSIMD_FORCE_INLINE const tfScalar & y() const
virtual void on_pose_update(const RobotPose &, const LaserScan2D &, double)
virtual void on_matching_start(const RobotPose &, const TransformedLaserScan &, const GridMap &)
void set_lookup_ranges(double x, double y=0, double th=0)
std::vector< std::weak_ptr< GridScanMatcherObserver > > & observers()
std::vector< std::weak_ptr< GridScanMatcherObserver > > _observers
double estimate_scan_probability(const LaserScan2D &scan, const RobotPose &pose, const GridMap &map) const
void unsubscribe(std::shared_ptr< GridScanMatcherObserver > obs)
GridScanMatcher(SPE estimator, double max_x_error=0, double max_y_error=0, double max_th_error=0)
static bool is_prob_unknown(double probability)
LaserScan2D filter_scan(const LaserScan2D &scan, const RobotPose &pose, const GridMap &map)
double scan_probability(const LaserScan2D &scan, const RobotPose &pose, const GridMap &map, const SPEParams &p) const
void set_scan_probability_estimator(SPE spe)
void set_oope(OOPE occ_obs_prob_est)
double scan_probability(const LaserScan2D &scan, const RobotPose &pose, const GridMap &map) const
void do_for_each_observer(std::function< void(ObsPtr)> op)
virtual void reset_state()
SPE scan_probability_estimator() const