1 #ifndef SLAM_CTOR_CORE_CONNECT_THE_DOTS_AMBIOUS_DRIFT_DETECTOR_H 2 #define SLAM_CTOR_CORE_CONNECT_THE_DOTS_AMBIOUS_DRIFT_DETECTOR_H 6 #include "../features/angle_histogram.h" 26 auto sm_best_prob =
_sm->process_scan(raw_scan, init_pose, map, pose_delta);
27 auto best_pose = init_pose + pose_delta;
32 auto drift_dir_i = angle_histogram.max_i();
33 auto drift_dir = angle_histogram[drift_dir_i];
34 std::cout << drift_dir * 1.0 / scan.points().size() << std::endl;
35 if (drift_dir < 0.4 * scan.points().size()) {
38 std::cout <<
"ANALYSIS: " << drift_dir * 1.0 / scan.points().size() << std::endl;
44 auto &scan_pts = filtered_scan.
points();
45 for (LaserScan2D::Points::size_type i = 1; i < scan.points().size(); ++i) {
46 auto &sp = scan.points()[i];
48 if (drift_dir == angle_histogram.value(scan.points(), i)) {
51 scan_pts.push_back(sp);
55 auto probs = std::vector<double>{};
57 auto hist_step = angle_histogram.angle_step();
60 auto ang = drift_dir_i * hist_step + hist_step / 2;
69 while (poses.has_next()) {
70 auto next_pose = poses.next(best_pose);
72 probs.push_back(next_prob);
73 auto next_pose_is_better = best_prob < next_prob;
74 if (next_pose_is_better) {
75 best_prob = next_prob;
76 best_pose = next_pose;
77 std::cout <<
"2ND Pass Update: " << best_prob <<
" --> " 78 << best_pose << std::endl;
80 poses.feedback(next_pose_is_better);
83 if (1 < probs.size()) {
84 std::sort(probs.begin(), probs.end(), std::greater<double>{});
85 if (
are_equal(probs[0], probs[1], 1e-6)) {
86 std::cout <<
"ALARM: " << probs[0] <<
" == " << probs[1] << std::endl;
90 pose_delta = best_pose - init_pose;
92 if (corrected_best_prob < sm_best_prob) {
93 std::cout <<
"[CtD][Bug] " << corrected_best_prob <<
" " 94 << sm_best_prob << std::endl;
96 return corrected_best_prob;
100 std::shared_ptr<GridScanMatcher>
_sm;
CONSTEXPR bool are_equal(const T &a, const T &b, const T &eps)
ConnectTheDotsAmbiguousDriftDetector(std::shared_ptr< GridScanMatcher > sm)
std::shared_ptr< GridScanMatcher > _sm
double process_scan(const TransformedLaserScan &raw_scan, const RobotPose &init_pose, const GridMap &map, RobotPoseDelta &pose_delta) override
const Points & points() const
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
std::shared_ptr< TrigonometryProvider > trig_provider
SPE scan_probability_estimator() const
void reset_state() override
auto reset(const LaserScan2D &scan)