1 #ifndef SLAM_CTOR_GMAPPING_WORLD_H 2 #define SLAM_CTOR_GMAPPING_WORLD_H 8 #include "../../core/particle_filter.h" 9 #include "../../core/states/single_state_hypothesis_laser_scan_grid_world.h" 10 #include "../../core/maps/grid_cell.h" 11 #include "../../core/maps/lazy_tiled_grid_map.h" 12 #include "../../core/scan_matchers/hill_climbing_scan_matcher.h" 25 double mean_sample_th,
double sigma_sample_th,
26 double min_sm_lim_xy,
double max_sm_lim_xy,
27 double min_sm_lim_th,
double max_sm_lim_th)
28 : pose_guess_rv{
GRV1D{mean_sample_xy, sigma_sample_xy},
29 GRV1D{mean_sample_xy, sigma_sample_xy},
30 GRV1D{mean_sample_th, sigma_sample_th}}
31 , next_sm_delta_rv{
URV1D{min_sm_lim_xy, max_sm_lim_xy},
32 URV1D{min_sm_lim_xy, max_sm_lim_xy},
33 URV1D{min_sm_lim_th, max_sm_lim_th}} {}
50 , _raw_odom_pose{0, 0, 0}
51 , _rnd_engine(std::random_device{}())
52 , _pose_guess_rv{gparams.pose_guess_rv}
53 , _next_sm_delta_rv{gparams.next_sm_delta_rv} {
54 reset_scan_matching_delta();
58 auto d_th = (pose() - _raw_odom_pose).theta;
59 auto s = std::sin(d_th), c = std::cos(d_th);
62 c*delta.
x -
s*delta.
y,
63 s*delta.
x + c*delta.
y,
67 _raw_odom_pose += delta;
69 _delta_since_last_sm += corrected_delta.
abs();
74 if (_delta_since_last_sm.sq_dist() < _next_sm_delta.sq_dist() &&
75 std::fabs(_delta_since_last_sm.theta) < _next_sm_delta.theta) {
81 if (!_scan_is_first) {
83 auto noise = _pose_guess_rv.sample(_rnd_engine);
88 double scan_prob = scan_matcher()->process_scan(scan, pose(),
93 if (0.0 < scan_prob || _scan_is_first) {
95 scan_adder()->append_scan(map(), pose(), scan.
scan, scan.
quality, 0);
96 _scan_is_first =
false;
100 reset_scan_matching_delta();
112 void sample()
override { _is_master =
false; }
117 _delta_since_last_sm.reset();
118 _next_sm_delta = _next_sm_delta_rv.sample(_rnd_engine);
123 bool _is_master =
false;
124 bool _scan_is_first =
true;
RobotPoseDelta abs() const
std::mt19937 RandomEngine
void update_robot_pose(const RobotPoseDelta &delta) override
void reset_scan_matching_delta()
RobotPoseDeltaRV< RandomEngine > next_sm_delta_rv
GMappingParams(double mean_sample_xy, double sigma_sample_xy, double mean_sample_th, double sigma_sample_th, double min_sm_lim_xy, double max_sm_lim_xy, double min_sm_lim_th, double max_sm_lim_th)
GmappingWorld(const SingleStateHypothesisLSGWProperties &shw_params, const GMappingParams &gparams)
RobotPoseDeltaRV< RandomEngine > _pose_guess_rv
RobotPoseDelta _next_sm_delta
RobotPoseDeltaRV< RandomEngine > pose_guess_rv
void handle_observation(TransformedLaserScan &scan) override
void set_weight(double w)
std::mt19937 RandomEngine
virtual void update_robot_pose(const RobotPoseDelta &delta)