11 #ifndef __MONTE_CARLO_SCAN_MATCHER_H 12 #define __MONTE_CARLO_SCAN_MATCHER_H 32 using ObsPtr = std::shared_ptr<GridScanMatcherObserver>;
43 unsigned failed_iter,
unsigned max_iter):
61 obs->on_matching_start(init_pose, scan, map);
64 unsigned failed_tries = 0, total_tries = 0;
66 double min_scan_cost = std::numeric_limits<double>::max();
69 min_scan_cost = sce->estimate_scan_cost(optimal_pose, scan,
73 obs->on_scan_test(optimal_pose, scan, min_scan_cost);
74 obs->on_pose_update(optimal_pose, scan, min_scan_cost);
83 double sampled_scan_cost = sce->estimate_scan_cost(sampled_pose, scan,
86 obs->on_scan_test(sampled_pose, scan, sampled_scan_cost);
89 if (min_scan_cost <= sampled_scan_cost) {
94 min_scan_cost = sampled_scan_cost;
95 optimal_pose = sampled_pose;
99 obs->on_pose_update(optimal_pose, scan, min_scan_cost);
103 pose_delta.
x = optimal_pose.
x - init_pose.
x;
104 pose_delta.
y = optimal_pose.
y - init_pose.
y;
108 obs->on_matching_end(pose_delta, min_scan_cost);
110 return min_scan_cost;
126 unsigned sample_limit) = 0;
131 if (
auto obs_ptr = obs.lock()) {
std::shared_ptr< ScanCostEstimator > cost_estimator()
Returns a pointer to the cost estimator.
unsigned _total_tries_limit
An occupancy grid implementation.
void do_for_each_observer(std::function< void(ObsPtr)> op)
Defines some interfaces for Scan Matchers. There are class GridScanMatcherObserver, ScanCostEstimator, GridScanMatcher.
virtual unsigned on_estimate_update(unsigned sample_num, unsigned sample_limit)=0
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...
double theta
The position of robot.
std::vector< std::weak_ptr< GridScanMatcherObserver > > & observers()
Returns a reference to the vector of pointers on observers.
Defines a robot position in cartesian coordinates and an angle of rotation.
Defines some classes related to a robot state. There are classes RobotState and World.
unsigned _failed_tries_limit
virtual double process_scan(const RobotState &init_pose, const TransformedLaserScan &scan, const GridMap &map, RobotState &pose_delta) override
virtual void sample_pose(RobotState &base_pose)=0
MonteCarloScanMatcher(std::shared_ptr< ScanCostEstimator > estimator, unsigned failed_iter, unsigned max_iter)
Initializes the scan matcher with a certain scan cost estimator.
std::shared_ptr< GridScanMatcherObserver > ObsPtr
Scan Matcher based on the Monte Carlo method. The focus of the scan matcher is to compare a scan and ...