25 #include "Eigen/Geometry" 30 #include "glog/logging.h" 37 proto::SubmapsOptions2D options;
38 options.set_num_range_data(
41 parameter_dictionary->
GetDictionary(
"grid_options_2d").get());
42 *options.mutable_range_data_inserter_options() =
44 parameter_dictionary->
GetDictionary(
"range_data_inserter").get());
46 bool valid_range_data_inserter_grid_combination =
false;
47 const proto::GridOptions2D_GridType& grid_type =
48 options.grid_options_2d().grid_type();
49 const proto::RangeDataInserterOptions_RangeDataInserterType&
50 range_data_inserter_type =
51 options.range_data_inserter_options().range_data_inserter_type();
52 if (grid_type == proto::GridOptions2D::PROBABILITY_GRID &&
53 range_data_inserter_type ==
54 proto::RangeDataInserterOptions::PROBABILITY_GRID_INSERTER_2D) {
55 valid_range_data_inserter_grid_combination =
true;
57 CHECK(valid_range_data_inserter_grid_combination)
58 <<
"Invalid combination grid_type " << grid_type
59 <<
" with range_data_inserter_type " << range_data_inserter_type;
60 CHECK_GT(options.num_range_data(), 0);
66 Eigen::Vector3d(origin.x(), origin.y(), 0.))) {
67 grid_ = std::move(grid);
72 if (proto.has_grid()) {
73 CHECK(proto.grid().has_probability_grid_2d());
74 grid_ = common::make_unique<ProbabilityGrid>(proto.grid());
81 bool include_probability_grid_data)
const {
82 auto*
const submap_2d = proto->mutable_submap_2d();
86 if (include_probability_grid_data) {
88 *submap_2d->mutable_grid() =
grid_->ToProto();
93 CHECK(proto.has_submap_2d());
94 const auto& submap_2d = proto.submap_2d();
97 if (proto.submap_2d().has_grid()) {
98 CHECK(proto.submap_2d().grid().has_probability_grid_2d());
99 grid_ = common::make_unique<ProbabilityGrid>(submap_2d.grid());
105 proto::SubmapQuery::Response*
const response)
const {
108 proto::SubmapQuery::Response::SubmapTexture*
const texture =
109 response->add_textures();
118 range_data_inserter->
Insert(range_data,
grid_.get());
147 if (submaps_.back()->num_range_data() ==
options_.num_range_data()) {
152 std::unique_ptr<RangeDataInserterInterface>
154 return common::make_unique<ProbabilityGridRangeDataInserter2D>(
155 options_.range_data_inserter_options()
156 .probability_grid_range_data_inserter_options_2d());
160 const Eigen::Vector2f& origin) {
161 constexpr
int kInitialSubmapSize = 100;
162 float resolution =
options_.grid_options_2d().resolution();
163 return common::make_unique<ProbabilityGrid>(
165 origin.cast<
double>() + 0.5 * kInitialSubmapSize * resolution *
166 Eigen::Vector2d::Ones(),
167 CellLimits(kInitialSubmapSize, kInitialSubmapSize)));
184 submaps_.push_back(common::make_unique<Submap2D>(
185 origin, std::unique_ptr<Grid2D>(
void InsertRangeData(const sensor::RangeData &range_data, const RangeDataInserterInterface *range_data_inserter)
void ToProto(proto::Submap *proto, bool include_probability_grid_data) const override
std::unique_ptr< RangeDataInserterInterface > range_data_inserter_
proto::SubmapsOptions2D CreateSubmapsOptions2D(common::LuaParameterDictionary *const parameter_dictionary)
std::vector< std::shared_ptr< Submap2D > > submaps() const
void set_num_range_data(const int num_range_data)
void InsertRangeData(const sensor::RangeData &range_data)
int GetNonNegativeInt(const std::string &key)
void set_finished(bool finished)
void ToResponseProto(const transform::Rigid3d &global_submap_pose, proto::SubmapQuery::Response *response) const override
std::unique_ptr< GridInterface > CreateGrid(const Eigen::Vector2f &origin)
const proto::SubmapsOptions2D options_
std::unique_ptr< RangeDataInserterInterface > CreateRangeDataInserter()
std::vector< std::shared_ptr< Submap2D > > submaps_
Submap2D(const Eigen::Vector2f &origin, std::unique_ptr< Grid2D > grid)
virtual bool DrawToSubmapTexture(proto::SubmapQuery::Response::SubmapTexture *const texture, transform::Rigid3d local_pose) const =0
int matching_index() const
int matching_submap_index_
proto::ProbabilityGridRangeDataInserterOptions2D options_
std::unique_ptr< ProbabilityGridRangeDataInserter2D > range_data_inserter_
virtual void Insert(const sensor::RangeData &range_data, GridInterface *grid) const =0
const Grid2D * grid() const
transform::Rigid3d local_pose() const
ActiveSubmaps2D(const proto::SubmapsOptions2D &options)
std::unique_ptr< LuaParameterDictionary > GetDictionary(const std::string &key)
int num_range_data() const
std::unique_ptr< Grid2D > grid_
proto::RangeDataInserterOptions CreateRangeDataInserterOptions(common::LuaParameterDictionary *const parameter_dictionary)
void UpdateFromProto(const proto::Submap &proto) override
void AddSubmap(const Eigen::Vector2f &origin)
proto::GridOptions2D CreateGridOptions2D(common::LuaParameterDictionary *const parameter_dictionary)