Wrap HybridGrid in unique_ptr to make Submap updatable (#809)

master
Christoph Schütte 2018-01-11 14:34:56 +01:00 committed by Wally B. Feed
parent e1a182d1fa
commit 8fc64fdbb5
2 changed files with 16 additions and 12 deletions

View File

@ -200,13 +200,17 @@ proto::SubmapsOptions CreateSubmapsOptions(
Submap::Submap(const float high_resolution, const float low_resolution, Submap::Submap(const float high_resolution, const float low_resolution,
const transform::Rigid3d& local_submap_pose) const transform::Rigid3d& local_submap_pose)
: mapping::Submap(local_submap_pose), : mapping::Submap(local_submap_pose),
high_resolution_hybrid_grid_(high_resolution), high_resolution_hybrid_grid_(
low_resolution_hybrid_grid_(low_resolution) {} common::make_unique<HybridGrid>(high_resolution)),
low_resolution_hybrid_grid_(
common::make_unique<HybridGrid>(low_resolution)) {}
Submap::Submap(const mapping::proto::Submap3D& proto) Submap::Submap(const mapping::proto::Submap3D& proto)
: mapping::Submap(transform::ToRigid3(proto.local_pose())), : mapping::Submap(transform::ToRigid3(proto.local_pose())),
high_resolution_hybrid_grid_(proto.high_resolution_hybrid_grid()), high_resolution_hybrid_grid_(
low_resolution_hybrid_grid_(proto.low_resolution_hybrid_grid()) { common::make_unique<HybridGrid>(proto.high_resolution_hybrid_grid())),
low_resolution_hybrid_grid_(
common::make_unique<HybridGrid>(proto.low_resolution_hybrid_grid())) {
SetNumRangeData(proto.num_range_data()); SetNumRangeData(proto.num_range_data());
finished_ = proto.finished(); finished_ = proto.finished();
} }
@ -227,9 +231,9 @@ void Submap::ToResponseProto(
mapping::proto::SubmapQuery::Response* const response) const { mapping::proto::SubmapQuery::Response* const response) const {
response->set_submap_version(num_range_data()); response->set_submap_version(num_range_data());
AddToTextureProto(high_resolution_hybrid_grid_, global_submap_pose, AddToTextureProto(*high_resolution_hybrid_grid_, global_submap_pose,
response->add_textures()); response->add_textures());
AddToTextureProto(low_resolution_hybrid_grid_, global_submap_pose, AddToTextureProto(*low_resolution_hybrid_grid_, global_submap_pose,
response->add_textures()); response->add_textures());
} }
@ -242,9 +246,9 @@ void Submap::InsertRangeData(const sensor::RangeData& range_data,
range_data_inserter.Insert( range_data_inserter.Insert(
FilterRangeDataByMaxRange(transformed_range_data, FilterRangeDataByMaxRange(transformed_range_data,
high_resolution_max_range), high_resolution_max_range),
&high_resolution_hybrid_grid_); high_resolution_hybrid_grid_.get());
range_data_inserter.Insert(transformed_range_data, range_data_inserter.Insert(transformed_range_data,
&low_resolution_hybrid_grid_); low_resolution_hybrid_grid_.get());
SetNumRangeData(num_range_data() + 1); SetNumRangeData(num_range_data() + 1);
} }

View File

@ -50,10 +50,10 @@ class Submap : public mapping::Submap {
void ToProto(mapping::proto::Submap* proto) const override; void ToProto(mapping::proto::Submap* proto) const override;
const HybridGrid& high_resolution_hybrid_grid() const { const HybridGrid& high_resolution_hybrid_grid() const {
return high_resolution_hybrid_grid_; return *high_resolution_hybrid_grid_;
} }
const HybridGrid& low_resolution_hybrid_grid() const { const HybridGrid& low_resolution_hybrid_grid() const {
return low_resolution_hybrid_grid_; return *low_resolution_hybrid_grid_;
} }
bool finished() const { return finished_; } bool finished() const { return finished_; }
@ -69,8 +69,8 @@ class Submap : public mapping::Submap {
void Finish(); void Finish();
private: private:
HybridGrid high_resolution_hybrid_grid_; std::unique_ptr<HybridGrid> high_resolution_hybrid_grid_;
HybridGrid low_resolution_hybrid_grid_; std::unique_ptr<HybridGrid> low_resolution_hybrid_grid_;
bool finished_ = false; bool finished_ = false;
}; };