Move 'finished' getter to the base class. (#803)
* Move 'finished' getter to the base class. * Ran clang-format. * Ran clang-format.master
parent
712c7e3e39
commit
53c2a6b58f
cartographer
|
@ -67,25 +67,32 @@ class Submap {
|
|||
bool include_probability_grid_data) const = 0;
|
||||
virtual void UpdateFromProto(const proto::Submap& proto) = 0;
|
||||
|
||||
// Fills data into the 'response'.
|
||||
virtual void ToResponseProto(
|
||||
const transform::Rigid3d& global_submap_pose,
|
||||
proto::SubmapQuery::Response* response) const = 0;
|
||||
|
||||
// Pose of this submap in the local map frame.
|
||||
transform::Rigid3d local_pose() const { return local_pose_; }
|
||||
|
||||
// Number of RangeData inserted.
|
||||
int num_range_data() const { return num_range_data_; }
|
||||
|
||||
// Fills data into the 'response'.
|
||||
virtual void ToResponseProto(
|
||||
const transform::Rigid3d& global_submap_pose,
|
||||
proto::SubmapQuery::Response* response) const = 0;
|
||||
// Whether the submap is finished or not.
|
||||
bool finished() const { return finished_; }
|
||||
|
||||
void SetNumRangeData(const int num_range_data) {
|
||||
num_range_data_ = num_range_data;
|
||||
}
|
||||
|
||||
void SetFinished(bool finished) { finished_ = finished; }
|
||||
|
||||
private:
|
||||
const transform::Rigid3d local_pose_;
|
||||
int num_range_data_ = 0;
|
||||
bool finished_ = false;
|
||||
};
|
||||
|
||||
} // namespace mapping
|
||||
} // namespace cartographer
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ Submap::Submap(const mapping::proto::Submap2D& proto)
|
|||
: mapping::Submap(transform::ToRigid3(proto.local_pose())),
|
||||
probability_grid_(ProbabilityGrid(proto.probability_grid())) {
|
||||
SetNumRangeData(proto.num_range_data());
|
||||
finished_ = proto.finished();
|
||||
SetFinished(proto.finished());
|
||||
}
|
||||
|
||||
void Submap::ToProto(mapping::proto::Submap* const proto,
|
||||
|
@ -79,7 +79,7 @@ void Submap::ToProto(mapping::proto::Submap* const proto,
|
|||
auto* const submap_2d = proto->mutable_submap_2d();
|
||||
*submap_2d->mutable_local_pose() = transform::ToProto(local_pose());
|
||||
submap_2d->set_num_range_data(num_range_data());
|
||||
submap_2d->set_finished(finished_);
|
||||
submap_2d->set_finished(finished());
|
||||
if (include_probability_grid_data) {
|
||||
*submap_2d->mutable_probability_grid() = probability_grid_.ToProto();
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ void Submap::UpdateFromProto(const mapping::proto::Submap& proto) {
|
|||
CHECK(proto.has_submap_2d());
|
||||
const auto& submap_2d = proto.submap_2d();
|
||||
SetNumRangeData(submap_2d.num_range_data());
|
||||
finished_ = submap_2d.finished();
|
||||
SetFinished(submap_2d.finished());
|
||||
if (submap_2d.has_probability_grid()) {
|
||||
probability_grid_ = ProbabilityGrid(submap_2d.probability_grid());
|
||||
}
|
||||
|
@ -145,15 +145,15 @@ void Submap::ToResponseProto(
|
|||
|
||||
void Submap::InsertRangeData(const sensor::RangeData& range_data,
|
||||
const RangeDataInserter& range_data_inserter) {
|
||||
CHECK(!finished_);
|
||||
CHECK(!finished());
|
||||
range_data_inserter.Insert(range_data, &probability_grid_);
|
||||
SetNumRangeData(num_range_data() + 1);
|
||||
}
|
||||
|
||||
void Submap::Finish() {
|
||||
CHECK(!finished_);
|
||||
CHECK(!finished());
|
||||
probability_grid_ = ComputeCroppedProbabilityGrid(probability_grid_);
|
||||
finished_ = true;
|
||||
SetFinished(true);
|
||||
}
|
||||
|
||||
ActiveSubmaps::ActiveSubmaps(const proto::SubmapsOptions& options)
|
||||
|
|
|
@ -51,13 +51,12 @@ class Submap : public mapping::Submap {
|
|||
bool include_probability_grid_data) const override;
|
||||
void UpdateFromProto(const mapping::proto::Submap& proto) override;
|
||||
|
||||
const ProbabilityGrid& probability_grid() const { return probability_grid_; }
|
||||
bool finished() const { return finished_; }
|
||||
|
||||
void ToResponseProto(
|
||||
const transform::Rigid3d& global_submap_pose,
|
||||
mapping::proto::SubmapQuery::Response* response) const override;
|
||||
|
||||
const ProbabilityGrid& probability_grid() const { return probability_grid_; }
|
||||
|
||||
// Insert 'range_data' into this submap using 'range_data_inserter'. The
|
||||
// submap must not be finished yet.
|
||||
void InsertRangeData(const sensor::RangeData& range_data,
|
||||
|
@ -66,7 +65,6 @@ class Submap : public mapping::Submap {
|
|||
|
||||
private:
|
||||
ProbabilityGrid probability_grid_;
|
||||
bool finished_ = false;
|
||||
};
|
||||
|
||||
// Except during initialization when only a single submap exists, there are
|
||||
|
|
|
@ -212,7 +212,7 @@ Submap::Submap(const mapping::proto::Submap3D& proto)
|
|||
low_resolution_hybrid_grid_(
|
||||
common::make_unique<HybridGrid>(proto.low_resolution_hybrid_grid())) {
|
||||
SetNumRangeData(proto.num_range_data());
|
||||
finished_ = proto.finished();
|
||||
SetFinished(proto.finished());
|
||||
}
|
||||
|
||||
void Submap::ToProto(mapping::proto::Submap* const proto,
|
||||
|
@ -220,7 +220,7 @@ void Submap::ToProto(mapping::proto::Submap* const proto,
|
|||
auto* const submap_3d = proto->mutable_submap_3d();
|
||||
*submap_3d->mutable_local_pose() = transform::ToProto(local_pose());
|
||||
submap_3d->set_num_range_data(num_range_data());
|
||||
submap_3d->set_finished(finished_);
|
||||
submap_3d->set_finished(finished());
|
||||
if (include_probability_grid_data) {
|
||||
*submap_3d->mutable_high_resolution_hybrid_grid() =
|
||||
high_resolution_hybrid_grid().ToProto();
|
||||
|
@ -233,7 +233,7 @@ void Submap::UpdateFromProto(const mapping::proto::Submap& proto) {
|
|||
CHECK(proto.has_submap_3d());
|
||||
const auto& submap_3d = proto.submap_3d();
|
||||
SetNumRangeData(submap_3d.num_range_data());
|
||||
finished_ = submap_3d.finished();
|
||||
SetFinished(submap_3d.finished());
|
||||
if (submap_3d.has_high_resolution_hybrid_grid()) {
|
||||
high_resolution_hybrid_grid_ =
|
||||
submap_3d.has_high_resolution_hybrid_grid()
|
||||
|
@ -264,7 +264,7 @@ void Submap::ToResponseProto(
|
|||
void Submap::InsertRangeData(const sensor::RangeData& range_data,
|
||||
const RangeDataInserter& range_data_inserter,
|
||||
const int high_resolution_max_range) {
|
||||
CHECK(!finished_);
|
||||
CHECK(!finished());
|
||||
const sensor::RangeData transformed_range_data = sensor::TransformRangeData(
|
||||
range_data, local_pose().inverse().cast<float>());
|
||||
range_data_inserter.Insert(
|
||||
|
@ -277,8 +277,8 @@ void Submap::InsertRangeData(const sensor::RangeData& range_data,
|
|||
}
|
||||
|
||||
void Submap::Finish() {
|
||||
CHECK(!finished_);
|
||||
finished_ = true;
|
||||
CHECK(!finished());
|
||||
SetFinished(true);
|
||||
}
|
||||
|
||||
ActiveSubmaps::ActiveSubmaps(const proto::SubmapsOptions& options)
|
||||
|
|
|
@ -51,17 +51,16 @@ class Submap : public mapping::Submap {
|
|||
bool include_probability_grid_data) const override;
|
||||
void UpdateFromProto(const mapping::proto::Submap& proto) override;
|
||||
|
||||
void ToResponseProto(
|
||||
const transform::Rigid3d& global_submap_pose,
|
||||
mapping::proto::SubmapQuery::Response* response) const override;
|
||||
|
||||
const HybridGrid& high_resolution_hybrid_grid() const {
|
||||
return *high_resolution_hybrid_grid_;
|
||||
}
|
||||
const HybridGrid& low_resolution_hybrid_grid() const {
|
||||
return *low_resolution_hybrid_grid_;
|
||||
}
|
||||
bool finished() const { return finished_; }
|
||||
|
||||
void ToResponseProto(
|
||||
const transform::Rigid3d& global_submap_pose,
|
||||
mapping::proto::SubmapQuery::Response* response) const override;
|
||||
|
||||
// Insert 'range_data' into this submap using 'range_data_inserter'. The
|
||||
// submap must not be finished yet.
|
||||
|
@ -73,7 +72,6 @@ class Submap : public mapping::Submap {
|
|||
private:
|
||||
std::unique_ptr<HybridGrid> high_resolution_hybrid_grid_;
|
||||
std::unique_ptr<HybridGrid> low_resolution_hybrid_grid_;
|
||||
bool finished_ = false;
|
||||
};
|
||||
|
||||
// Except during initialization when only a single submap exists, there are
|
||||
|
|
Loading…
Reference in New Issue