Fix typo, naming, formatting, type. (#1694)

Fixes the typo mentioned in #1637.
Also improves naming and ran clang-format.

Changed an integer literal to unsigned to
fix a compiler warning.
master
Wolfgang Hess 2020-06-03 11:46:45 +02:00 committed by GitHub
parent 6bbf2558ce
commit fe6e81a055
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 21 deletions

View File

@ -23,26 +23,29 @@
namespace cartographer { namespace cartographer {
namespace io { namespace io {
std::unique_ptr<MinMaxRangeFiteringPointsProcessor> std::unique_ptr<MinMaxRangeFilteringPointsProcessor>
MinMaxRangeFiteringPointsProcessor::FromDictionary( MinMaxRangeFilteringPointsProcessor::FromDictionary(
common::LuaParameterDictionary* const dictionary, common::LuaParameterDictionary* const dictionary,
PointsProcessor* const next) { PointsProcessor* const next) {
return absl::make_unique<MinMaxRangeFiteringPointsProcessor>( return absl::make_unique<MinMaxRangeFilteringPointsProcessor>(
dictionary->GetDouble("min_range"), dictionary->GetDouble("max_range"), dictionary->GetDouble("min_range"), dictionary->GetDouble("max_range"),
next); next);
} }
MinMaxRangeFiteringPointsProcessor::MinMaxRangeFiteringPointsProcessor( MinMaxRangeFilteringPointsProcessor::MinMaxRangeFilteringPointsProcessor(
const double min_range, const double max_range, PointsProcessor* next) const double min_range, const double max_range, PointsProcessor* next)
: min_range_squared_(min_range*min_range), max_range_squared_(max_range*max_range), : min_range_squared_(min_range * min_range),
max_range_squared_(max_range * max_range),
next_(next) {} next_(next) {}
void MinMaxRangeFiteringPointsProcessor::Process( void MinMaxRangeFilteringPointsProcessor::Process(
std::unique_ptr<PointsBatch> batch) { std::unique_ptr<PointsBatch> batch) {
absl::flat_hash_set<int> to_remove; absl::flat_hash_set<int> to_remove;
for (size_t i = 0; i < batch->points.size(); ++i) { for (size_t i = 0; i < batch->points.size(); ++i) {
const float range = (batch->points[i].position - batch->origin).squaredNorm(); const float range_squared =
if (!(min_range_squared_ <= range && range <= max_range_squared_)) { (batch->points[i].position - batch->origin).squaredNorm();
if (!(min_range_squared_ <= range_squared &&
range_squared <= max_range_squared_)) {
to_remove.insert(i); to_remove.insert(i);
} }
} }
@ -50,7 +53,7 @@ void MinMaxRangeFiteringPointsProcessor::Process(
next_->Process(std::move(batch)); next_->Process(std::move(batch));
} }
PointsProcessor::FlushResult MinMaxRangeFiteringPointsProcessor::Flush() { PointsProcessor::FlushResult MinMaxRangeFilteringPointsProcessor::Flush() {
return next_->Flush(); return next_->Flush();
} }

View File

@ -27,21 +27,21 @@ namespace io {
// Filters all points that are farther away from their 'origin' as 'max_range' // Filters all points that are farther away from their 'origin' as 'max_range'
// or closer than 'min_range'. // or closer than 'min_range'.
class MinMaxRangeFiteringPointsProcessor : public PointsProcessor { class MinMaxRangeFilteringPointsProcessor : public PointsProcessor {
public: public:
constexpr static const char* kConfigurationFileActionName = constexpr static const char* kConfigurationFileActionName =
"min_max_range_filter"; "min_max_range_filter";
MinMaxRangeFiteringPointsProcessor(double min_range, double max_range, MinMaxRangeFilteringPointsProcessor(double min_range, double max_range,
PointsProcessor* next); PointsProcessor* next);
static std::unique_ptr<MinMaxRangeFiteringPointsProcessor> FromDictionary( static std::unique_ptr<MinMaxRangeFilteringPointsProcessor> FromDictionary(
common::LuaParameterDictionary* dictionary, PointsProcessor* next); common::LuaParameterDictionary* dictionary, PointsProcessor* next);
~MinMaxRangeFiteringPointsProcessor() override {} ~MinMaxRangeFilteringPointsProcessor() override {}
MinMaxRangeFiteringPointsProcessor( MinMaxRangeFilteringPointsProcessor(
const MinMaxRangeFiteringPointsProcessor&) = delete; const MinMaxRangeFilteringPointsProcessor&) = delete;
MinMaxRangeFiteringPointsProcessor& operator=( MinMaxRangeFilteringPointsProcessor& operator=(
const MinMaxRangeFiteringPointsProcessor&) = delete; const MinMaxRangeFilteringPointsProcessor&) = delete;
void Process(std::unique_ptr<PointsBatch> batch) override; void Process(std::unique_ptr<PointsBatch> batch) override;
FlushResult Flush() override; FlushResult Flush() override;

View File

@ -83,7 +83,7 @@ void RegisterBuiltInPointsProcessors(
RegisterPlainPointsProcessor<CountingPointsProcessor>(builder); RegisterPlainPointsProcessor<CountingPointsProcessor>(builder);
RegisterPlainPointsProcessor<FixedRatioSamplingPointsProcessor>(builder); RegisterPlainPointsProcessor<FixedRatioSamplingPointsProcessor>(builder);
RegisterPlainPointsProcessor<FrameIdFilteringPointsProcessor>(builder); RegisterPlainPointsProcessor<FrameIdFilteringPointsProcessor>(builder);
RegisterPlainPointsProcessor<MinMaxRangeFiteringPointsProcessor>(builder); RegisterPlainPointsProcessor<MinMaxRangeFilteringPointsProcessor>(builder);
RegisterPlainPointsProcessor<OutlierRemovingPointsProcessor>(builder); RegisterPlainPointsProcessor<OutlierRemovingPointsProcessor>(builder);
RegisterPlainPointsProcessor<ColoringPointsProcessor>(builder); RegisterPlainPointsProcessor<ColoringPointsProcessor>(builder);
RegisterPlainPointsProcessor<IntensityToColorPointsProcessor>(builder); RegisterPlainPointsProcessor<IntensityToColorPointsProcessor>(builder);

View File

@ -150,7 +150,7 @@ TEST_F(MigrationTest, MigrationAddsHeaderAsFirstMessage) {
mapping::proto::SerializationHeader header; mapping::proto::SerializationHeader header;
EXPECT_TRUE(TextFormat::ParseFromString(output_messages_[0], &header)); EXPECT_TRUE(TextFormat::ParseFromString(output_messages_[0], &header));
EXPECT_THAT(header.format_version(), Eq(1)); EXPECT_THAT(header.format_version(), Eq(1u));
} }
TEST_F(MigrationTest, MigrationWithGridMigrationAddsHeaderAsFirstMessage) { TEST_F(MigrationTest, MigrationWithGridMigrationAddsHeaderAsFirstMessage) {
@ -165,7 +165,7 @@ TEST_F(MigrationTest, MigrationWithGridMigrationAddsHeaderAsFirstMessage) {
mapping::proto::SerializationHeader header; mapping::proto::SerializationHeader header;
EXPECT_TRUE(TextFormat::ParseFromString( EXPECT_TRUE(TextFormat::ParseFromString(
output_messages_after_migrating_grid_[0], &header)); output_messages_after_migrating_grid_[0], &header));
EXPECT_THAT(header.format_version(), Eq(1)); EXPECT_THAT(header.format_version(), Eq(1u));
} }
TEST_F(MigrationTest, SerializedDataOrderIsCorrect) { TEST_F(MigrationTest, SerializedDataOrderIsCorrect) {