From fe6e81a0555cc62f429f70fb96b2782aee82d3fe Mon Sep 17 00:00:00 2001 From: Wolfgang Hess Date: Wed, 3 Jun 2020 11:46:45 +0200 Subject: [PATCH] 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. --- ...in_max_range_filtering_points_processor.cc | 21 +++++++++++-------- ...min_max_range_filtering_points_processor.h | 18 ++++++++-------- .../io/points_processor_pipeline_builder.cc | 2 +- .../io/serialization_format_migration_test.cc | 4 ++-- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/cartographer/io/min_max_range_filtering_points_processor.cc b/cartographer/io/min_max_range_filtering_points_processor.cc index 8cc56e7..ba5fc79 100644 --- a/cartographer/io/min_max_range_filtering_points_processor.cc +++ b/cartographer/io/min_max_range_filtering_points_processor.cc @@ -23,26 +23,29 @@ namespace cartographer { namespace io { -std::unique_ptr -MinMaxRangeFiteringPointsProcessor::FromDictionary( +std::unique_ptr +MinMaxRangeFilteringPointsProcessor::FromDictionary( common::LuaParameterDictionary* const dictionary, PointsProcessor* const next) { - return absl::make_unique( + return absl::make_unique( dictionary->GetDouble("min_range"), dictionary->GetDouble("max_range"), next); } -MinMaxRangeFiteringPointsProcessor::MinMaxRangeFiteringPointsProcessor( +MinMaxRangeFilteringPointsProcessor::MinMaxRangeFilteringPointsProcessor( 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) {} -void MinMaxRangeFiteringPointsProcessor::Process( +void MinMaxRangeFilteringPointsProcessor::Process( std::unique_ptr batch) { absl::flat_hash_set to_remove; for (size_t i = 0; i < batch->points.size(); ++i) { - const float range = (batch->points[i].position - batch->origin).squaredNorm(); - if (!(min_range_squared_ <= range && range <= max_range_squared_)) { + const float range_squared = + (batch->points[i].position - batch->origin).squaredNorm(); + if (!(min_range_squared_ <= range_squared && + range_squared <= max_range_squared_)) { to_remove.insert(i); } } @@ -50,7 +53,7 @@ void MinMaxRangeFiteringPointsProcessor::Process( next_->Process(std::move(batch)); } -PointsProcessor::FlushResult MinMaxRangeFiteringPointsProcessor::Flush() { +PointsProcessor::FlushResult MinMaxRangeFilteringPointsProcessor::Flush() { return next_->Flush(); } diff --git a/cartographer/io/min_max_range_filtering_points_processor.h b/cartographer/io/min_max_range_filtering_points_processor.h index 5bc727c..0e90b3e 100644 --- a/cartographer/io/min_max_range_filtering_points_processor.h +++ b/cartographer/io/min_max_range_filtering_points_processor.h @@ -27,21 +27,21 @@ namespace io { // Filters all points that are farther away from their 'origin' as 'max_range' // or closer than 'min_range'. -class MinMaxRangeFiteringPointsProcessor : public PointsProcessor { +class MinMaxRangeFilteringPointsProcessor : public PointsProcessor { public: constexpr static const char* kConfigurationFileActionName = "min_max_range_filter"; - MinMaxRangeFiteringPointsProcessor(double min_range, double max_range, - PointsProcessor* next); - static std::unique_ptr FromDictionary( + MinMaxRangeFilteringPointsProcessor(double min_range, double max_range, + PointsProcessor* next); + static std::unique_ptr FromDictionary( common::LuaParameterDictionary* dictionary, PointsProcessor* next); - ~MinMaxRangeFiteringPointsProcessor() override {} + ~MinMaxRangeFilteringPointsProcessor() override {} - MinMaxRangeFiteringPointsProcessor( - const MinMaxRangeFiteringPointsProcessor&) = delete; - MinMaxRangeFiteringPointsProcessor& operator=( - const MinMaxRangeFiteringPointsProcessor&) = delete; + MinMaxRangeFilteringPointsProcessor( + const MinMaxRangeFilteringPointsProcessor&) = delete; + MinMaxRangeFilteringPointsProcessor& operator=( + const MinMaxRangeFilteringPointsProcessor&) = delete; void Process(std::unique_ptr batch) override; FlushResult Flush() override; diff --git a/cartographer/io/points_processor_pipeline_builder.cc b/cartographer/io/points_processor_pipeline_builder.cc index 23c9232..e50cc77 100644 --- a/cartographer/io/points_processor_pipeline_builder.cc +++ b/cartographer/io/points_processor_pipeline_builder.cc @@ -83,7 +83,7 @@ void RegisterBuiltInPointsProcessors( RegisterPlainPointsProcessor(builder); RegisterPlainPointsProcessor(builder); RegisterPlainPointsProcessor(builder); - RegisterPlainPointsProcessor(builder); + RegisterPlainPointsProcessor(builder); RegisterPlainPointsProcessor(builder); RegisterPlainPointsProcessor(builder); RegisterPlainPointsProcessor(builder); diff --git a/cartographer/io/serialization_format_migration_test.cc b/cartographer/io/serialization_format_migration_test.cc index 24904ca..16e29b2 100644 --- a/cartographer/io/serialization_format_migration_test.cc +++ b/cartographer/io/serialization_format_migration_test.cc @@ -150,7 +150,7 @@ TEST_F(MigrationTest, MigrationAddsHeaderAsFirstMessage) { mapping::proto::SerializationHeader 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) { @@ -165,7 +165,7 @@ TEST_F(MigrationTest, MigrationWithGridMigrationAddsHeaderAsFirstMessage) { mapping::proto::SerializationHeader header; EXPECT_TRUE(TextFormat::ParseFromString( 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) {