Go to the documentation of this file.00001 #ifndef __TINY_SCAN_MATCHER_H
00002 #define __TINY_SCAN_MATCHER_H
00003
00004 #include <random>
00005
00006 #include "../core/monte_carlo_scan_matcher.h"
00007 #include "tiny_scan_cost_estimator.h"
00008
00015 class TinyScanMatcher : public MonteCarloScanMatcher {
00016 private:
00017 using ScePtr = std::shared_ptr<ScanCostEstimator>;
00018 public:
00028 TinyScanMatcher(ScePtr cost_estimator, unsigned bad_iter, unsigned max_iter,
00029 double sigma_coord, double sigma_angle):
00030 MonteCarloScanMatcher(cost_estimator, bad_iter, max_iter),
00031 _sigma_coord(sigma_coord), _sigma_angle(sigma_angle),
00032 _curr_sigma_coord(_sigma_coord), _curr_sigma_angle(_sigma_angle) {}
00033
00037 virtual void reset_state() override {
00038 _curr_sigma_coord = _sigma_coord;
00039 _curr_sigma_angle = _sigma_angle;
00040 }
00041
00042 protected:
00043 virtual void sample_pose(RobotState &base_pose) override {
00044 std::random_device rd;
00045 std::mt19937 gen(rd());
00046 std::normal_distribution<> d_coord(0.0, _curr_sigma_coord);
00047 std::normal_distribution<> d_angle(0.0, _curr_sigma_angle);
00048
00049 base_pose.x += d_coord(gen);
00050 base_pose.y += d_coord(gen);
00051 base_pose.theta += d_angle(gen);
00052 }
00053
00054 virtual unsigned on_estimate_update(unsigned sample_num,
00055 unsigned sample_limit) override {
00056 if (sample_num <= sample_limit / 3) {
00057 return sample_num;
00058 }
00059
00060 _curr_sigma_coord *= 0.5;
00061 _curr_sigma_angle *= 0.5;
00062 return 0;
00063 }
00064
00065 private:
00066 double _sigma_coord, _sigma_angle;
00067 double _curr_sigma_coord, _curr_sigma_angle;
00068 };
00069
00070 #endif