1 #ifndef SLAM_CTOR_UTILS_INIT_SCAN_MATCHING_H 2 #define SLAM_CTOR_UTILS_INIT_SCAN_MATCHING_H 10 #include "../core/scan_matchers/occupancy_observation_probability.h" 12 #include "../core/scan_matchers/monte_carlo_scan_matcher.h" 13 #include "../core/scan_matchers/hill_climbing_scan_matcher.h" 14 #include "../core/scan_matchers/hcsm_fixed.h" 15 #include "../core/scan_matchers/brute_force_scan_matcher.h" 16 #include "../core/scan_matchers/connect_the_dots_ambiguous_drift_detector.h" 17 #include "../core/scan_matchers/weighted_mean_point_probability_spe.h" 24 std::shared_ptr<OccupancyObservationProbabilityEstimator>
init_oope(
26 static const std::string OOPE_NS =
Slam_SM_NS +
"oope/";
27 auto type = props.
get_str(OOPE_NS +
"type",
"obstacle");
29 if (type ==
"obstacle") {
30 return std::make_shared<ObstacleBasedOccupancyObservationPE>();
31 }
else if (type ==
"max") {
32 return std::make_shared<MaxOccupancyObservationPE>();
33 }
else if (type ==
"mean") {
34 return std::make_shared<MeanOccupancyObservationPE>();
35 }
else if (type ==
"overlap") {
36 return std::make_shared<OverlapWeightedOccupancyObservationPE>();
38 std::cerr <<
"Unknown occupancy observation probability estimator type " 39 <<
"(" << OOPE_NS +
"type) " << type << std::endl;
48 static const std::string SWP_Type =
Slam_SM_NS +
"spe/wmpp/weighting/type";
49 auto type = props.
get_str(SWP_Type,
"<undefined>");
50 auto swp = std::shared_ptr<ScanPointWeighting>{};
52 std::cout <<
"Used SWP: " << type << std::endl;
54 swp = std::make_shared<EvenSPW>();
55 }
else if (type ==
"viny") {
56 swp = std::make_shared<VinySlamSPW>();
57 }
else if (type ==
"ahr") {
58 swp = std::make_shared<AngleHistogramReciprocalSPW>();
60 std::cerr <<
"Unknown Scan Point Weighting type " 61 <<
"(" << SWP_Type <<
") " << type << std::endl;
68 std::shared_ptr<OccupancyObservationProbabilityEstimator> oope) {
71 const std::string WMPP_Prefix =
Slam_SM_NS +
"spe/wmpp";
72 auto skip_rate = props.
get_uint(WMPP_Prefix +
"/sp_skip_rate", 0);
73 auto max_range = props.
get_dbl(WMPP_Prefix +
"/sp_max_usable_range", -1);
75 return std::make_shared<WmppSpe>(oope,
init_swp(props),
76 skip_rate, max_range);
78 std::cerr <<
"Unknown Scan Probability Estimator type (" 79 <<
Slam_SM_NS <<
"spe/type): " << type << std::endl;
92 std::shared_ptr<ScanProbabilityEstimator> spe) {
93 static const std::string SM_NS =
Slam_SM_NS +
"MC/";
94 static const std::string DISP_NS = SM_NS +
"dispersion/";
96 auto transl_dispersion = props.
get_dbl(DISP_NS +
"translation", 0.2);
97 auto rot_dispersion = props.
get_dbl(DISP_NS +
"rotation", 0.1);
98 auto failed_attempts_per_dispersion_limit =
99 props.
get_uint(DISP_NS +
"failed_attempts_limit", 20);
101 auto attempts_limit = props.
get_uint(SM_NS +
"attempts_limit", 100);
102 auto seed = props.
get_int(SM_NS +
"seed", std::random_device{}());
104 std::cout <<
"[INFO] MC Scan Matcher seed: " << seed << std::endl;
105 return std::make_shared<MonteCarloScanMatcher>(
106 spe, seed, transl_dispersion, rot_dispersion,
107 failed_attempts_per_dispersion_limit, attempts_limit);
111 std::shared_ptr<ScanProbabilityEstimator> spe) {
112 static const std::string SM_NS =
Slam_SM_NS +
"HC/";
113 static const std::string DIST_NS = SM_NS +
"distortion/";
115 auto transl_distorsion = props.
get_dbl(DIST_NS +
"translation", 0.1);
116 auto rot_distorsion = props.
get_dbl(DIST_NS +
"rotation", 0.1);
117 auto fal = props.
get_uint(DIST_NS +
"failed_attempts_limit", 6);
119 return std::make_shared<HillClimbingScanMatcher>(
120 spe, fal, transl_distorsion, rot_distorsion);
124 std::shared_ptr<ScanProbabilityEstimator> spe) {
125 static const std::string SM_NS =
Slam_SM_NS +
"BF/";
127 #define INIT_BFSM_RANGE(dim, limit, step) \ 128 auto from_##dim = props.get_dbl(SM_NS + #dim + "/from", -(limit)); \ 129 auto to_##dim = props.get_dbl(SM_NS + #dim + "/to", limit); \ 130 auto step_##dim = props.get_dbl(SM_NS + #dim + "/step", step); 136 #undef INIT_BFSM_RANGE 138 return std::make_shared<BruteForceScanMatcher>(
139 spe, from_x, to_x, step_x, from_y, to_y, step_y, from_t, to_t, step_t);
144 auto sm = std::shared_ptr<GridScanMatcher>{};
146 std::cout <<
"Used Scan Matcher: " << sm_type << std::endl;
150 else if (sm_type ==
"HC_FIXED") {
152 sm = std::make_shared<HillClimbingSMFixed>(spe);
154 std::cerr <<
"Unknown scan matcher type: " << sm_type << std::endl;
160 sm = std::make_shared<ConnectTheDotsAmbiguousDriftDetector>(sm);
auto init_brute_force_sm(const PropertiesProvider &props, std::shared_ptr< ScanProbabilityEstimator > spe)
std::shared_ptr< OccupancyObservationProbabilityEstimator > init_oope(const PropertiesProvider &props)
auto init_swp(const PropertiesProvider &props)
virtual str get_str(const std::string &id, const str &dflt) const =0
virtual int get_int(const std::string &id, int dflt) const =0
auto init_spe(const PropertiesProvider &props, std::shared_ptr< OccupancyObservationProbabilityEstimator > oope)
#define INIT_BFSM_RANGE(dim, limit, step)
virtual double get_dbl(const std::string &id, double dflt) const =0
TFSIMD_FORCE_INLINE const tfScalar & y() const
auto init_hill_climbing_sm(const PropertiesProvider &props, std::shared_ptr< ScanProbabilityEstimator > spe)
TFSIMD_FORCE_INLINE const tfScalar & x() const
auto init_scan_matcher(const PropertiesProvider &props)
virtual unsigned get_uint(const std::string &id, unsigned dflt) const =0
constexpr double deg2rad(double angle_deg)
virtual bool get_bool(const std::string &id, bool dflt) const =0
auto init_monte_carlo_sm(const PropertiesProvider &props, std::shared_ptr< ScanProbabilityEstimator > spe)
static const std::string Slam_SM_NS