init_occupancy_mapping.h
Go to the documentation of this file.
1 #ifndef SLAM_CTOR_UTILS_INIT_OCCUPANCY_MAPPING_H
2 #define SLAM_CTOR_UTILS_INIT_OCCUPANCY_MAPPING_H
3 
4 #include <memory>
5 #include <limits>
6 
7 #include "properties_providers.h"
8 
9 #include "../core/maps/grid_map.h"
10 #include "../core/maps/grid_map_scan_adders.h"
11 #include "../core/maps/area_occupancy_estimator.h"
12 #include "../core/maps/const_occupancy_estimator.h"
13 
15  static const std::string Map_NS = "slam/map/";
16  auto w = props.get_dbl(Map_NS + "height_in_meters", 10);
17  auto h = props.get_dbl(Map_NS + "width_in_meters", 10);
18  auto scale = props.get_dbl(Map_NS + "meters_per_cell", 0.1);
19  return GridMapParams{static_cast<int>(std::ceil(w / scale)),
20  static_cast<int>(std::ceil(h / scale)),
21  scale};
22 }
23 
24 std::shared_ptr<CellOccupancyEstimator> init_occ_estimator(
25  const PropertiesProvider &props) {
26 
27  // TODO: add mapping namespace, rename to ObservationToOccupancyConverver
28  static const std::string COE_NS = "slam/occupancy_estimator/";
29  auto base_occ = Occupancy{props.get_dbl(COE_NS + "base_occupied/prob", 0.95),
30  props.get_dbl(COE_NS + "base_occupied/qual", 1.0)};
31  auto base_empty = Occupancy{props.get_dbl(COE_NS + "base_empty/prob", 0.01),
32  props.get_dbl(COE_NS + "base_empty/qual", 1.0)};
33 
34  auto type = props.get_str(COE_NS + "type", "const");
35  if (type == "const") {
36  return std::make_shared<ConstOccupancyEstimator>(base_occ, base_empty);
37  } else if (type == "area") {
38  return std::make_shared<AreaOccupancyEstimator>(base_occ, base_empty);
39  } else {
40  std::cerr << "Unknown estimator type: " << type << std::endl;
41  std::exit(-1);
42  }
43 }
44 
45 auto init_scan_adder(const PropertiesProvider &props) {
46  static const auto DBL_INF = std::numeric_limits<double>::infinity();
48  return
49  builder.set_occupancy_estimator(init_occ_estimator(props))
50  .set_blur_distance(props.get_dbl("slam/mapping/blur", 0.0))
51  .set_max_usable_range(props.get_dbl("slam/mapping/max_range",
52  DBL_INF))
53  .build();
54 }
55 
56 #endif
virtual str get_str(const std::string &id, const str &dflt) const =0
auto init_scan_adder(const PropertiesProvider &props)
std::shared_ptr< CellOccupancyEstimator > init_occ_estimator(const PropertiesProvider &props)
virtual double get_dbl(const std::string &id, double dflt) const =0
static WallDistanceBlurringScanAdderBuilder builder()
auto init_grid_map_params(const PropertiesProvider &props)
TFSIMD_FORCE_INLINE const tfScalar & w() const


slam_constructor
Author(s): JetBrains Research, OSLL team
autogenerated on Mon Jun 10 2019 15:08:25