diff --git a/cartographer/BUILD.bazel b/cartographer/BUILD.bazel index 063489a..0caf39a 100644 --- a/cartographer/BUILD.bazel +++ b/cartographer/BUILD.bazel @@ -98,6 +98,7 @@ cc_library( "@com_google_absl//absl/base", "@com_google_absl//absl/strings", "@com_google_absl//absl/container:flat_hash_map", + "@com_google_absl//absl/container:flat_hash_set", "@com_google_absl//absl/synchronization", "@com_google_absl//absl/types:optional", "@com_google_glog//:glog", diff --git a/cartographer/io/fixed_ratio_sampling_points_processor.cc b/cartographer/io/fixed_ratio_sampling_points_processor.cc index 8ac14de..6b07f3c 100644 --- a/cartographer/io/fixed_ratio_sampling_points_processor.cc +++ b/cartographer/io/fixed_ratio_sampling_points_processor.cc @@ -42,7 +42,7 @@ FixedRatioSamplingPointsProcessor::FixedRatioSamplingPointsProcessor( void FixedRatioSamplingPointsProcessor::Process( std::unique_ptr batch) { - std::unordered_set to_remove; + absl::flat_hash_set to_remove; for (size_t i = 0; i < batch->points.size(); ++i) { if (!sampler_->Pulse()) { to_remove.insert(i); diff --git a/cartographer/io/frame_id_filtering_points_processor.cc b/cartographer/io/frame_id_filtering_points_processor.cc index f9b9f42..5fbe4c4 100644 --- a/cartographer/io/frame_id_filtering_points_processor.cc +++ b/cartographer/io/frame_id_filtering_points_processor.cc @@ -37,14 +37,14 @@ FrameIdFilteringPointsProcessor::FromDictionary( dictionary->GetDictionary("drop_frames")->GetArrayValuesAsStrings(); } return absl::make_unique( - std::unordered_set(keep_frames.begin(), keep_frames.end()), - std::unordered_set(drop_frames.begin(), drop_frames.end()), + absl::flat_hash_set(keep_frames.begin(), keep_frames.end()), + absl::flat_hash_set(drop_frames.begin(), drop_frames.end()), next); } FrameIdFilteringPointsProcessor::FrameIdFilteringPointsProcessor( - const std::unordered_set& keep_frame_ids, - const std::unordered_set& drop_frame_ids, + const absl::flat_hash_set& keep_frame_ids, + const absl::flat_hash_set& drop_frame_ids, PointsProcessor* next) : keep_frame_ids_(keep_frame_ids), drop_frame_ids_(drop_frame_ids), diff --git a/cartographer/io/frame_id_filtering_points_processor.h b/cartographer/io/frame_id_filtering_points_processor.h index 598b832..a35cb60 100644 --- a/cartographer/io/frame_id_filtering_points_processor.h +++ b/cartographer/io/frame_id_filtering_points_processor.h @@ -17,8 +17,7 @@ #ifndef CARTOGRAPHER_IO_FRAME_ID_FILTERING_POINTS_PROCESSOR_H_ #define CARTOGRAPHER_IO_FRAME_ID_FILTERING_POINTS_PROCESSOR_H_ -#include - +#include "absl/container/flat_hash_set.h" #include "cartographer/common/lua_parameter_dictionary.h" #include "cartographer/io/points_processor.h" @@ -32,8 +31,8 @@ class FrameIdFilteringPointsProcessor : public PointsProcessor { public: constexpr static const char* kConfigurationFileActionName = "frame_id_filter"; FrameIdFilteringPointsProcessor( - const std::unordered_set& keep_frame_ids, - const std::unordered_set& drop_frame_ids, + const absl::flat_hash_set& keep_frame_ids, + const absl::flat_hash_set& drop_frame_ids, PointsProcessor* next); static std::unique_ptr FromDictionary( common::LuaParameterDictionary* dictionary, PointsProcessor* next); @@ -48,8 +47,8 @@ class FrameIdFilteringPointsProcessor : public PointsProcessor { FlushResult Flush() override; private: - const std::unordered_set keep_frame_ids_; - const std::unordered_set drop_frame_ids_; + const absl::flat_hash_set keep_frame_ids_; + const absl::flat_hash_set drop_frame_ids_; PointsProcessor* const next_; }; diff --git a/cartographer/io/min_max_range_filtering_points_processor.cc b/cartographer/io/min_max_range_filtering_points_processor.cc index 898a82c..c487d6d 100644 --- a/cartographer/io/min_max_range_filtering_points_processor.cc +++ b/cartographer/io/min_max_range_filtering_points_processor.cc @@ -38,7 +38,7 @@ MinMaxRangeFiteringPointsProcessor::MinMaxRangeFiteringPointsProcessor( void MinMaxRangeFiteringPointsProcessor::Process( std::unique_ptr batch) { - std::unordered_set to_remove; + 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).norm(); if (!(min_range_ <= range && range <= max_range_)) { diff --git a/cartographer/io/outlier_removing_points_processor.cc b/cartographer/io/outlier_removing_points_processor.cc index 5cff194..92c9787 100644 --- a/cartographer/io/outlier_removing_points_processor.cc +++ b/cartographer/io/outlier_removing_points_processor.cc @@ -107,7 +107,7 @@ void OutlierRemovingPointsProcessor::ProcessInPhaseTwo( void OutlierRemovingPointsProcessor::ProcessInPhaseThree( std::unique_ptr batch) { constexpr double kMissPerHitLimit = 3; - std::unordered_set to_remove; + absl::flat_hash_set to_remove; for (size_t i = 0; i < batch->points.size(); ++i) { const VoxelData voxel = voxels_.value(voxels_.GetCellIndex(batch->points[i].position)); diff --git a/cartographer/io/pbstream_main.cc b/cartographer/io/pbstream_main.cc index 6055b77..0a795ff 100644 --- a/cartographer/io/pbstream_main.cc +++ b/cartographer/io/pbstream_main.cc @@ -15,8 +15,8 @@ */ #include -#include +#include "absl/container/flat_hash_set.h" #include "cartographer/io/internal/pbstream_info.h" #include "cartographer/io/internal/pbstream_migrate.h" #include "gflags/gflags.h" diff --git a/cartographer/io/points_batch.cc b/cartographer/io/points_batch.cc index 2639cd0..ea0fe4c 100644 --- a/cartographer/io/points_batch.cc +++ b/cartographer/io/points_batch.cc @@ -19,7 +19,7 @@ namespace cartographer { namespace io { -void RemovePoints(std::unordered_set to_remove, PointsBatch* batch) { +void RemovePoints(absl::flat_hash_set to_remove, PointsBatch* batch) { const int new_num_points = batch->points.size() - to_remove.size(); sensor::PointCloud points; points.reserve(new_num_points); diff --git a/cartographer/io/points_batch.h b/cartographer/io/points_batch.h index 980fec7..752966e 100644 --- a/cartographer/io/points_batch.h +++ b/cartographer/io/points_batch.h @@ -19,10 +19,10 @@ #include #include -#include #include #include "Eigen/Core" +#include "absl/container/flat_hash_set.h" #include "cartographer/common/time.h" #include "cartographer/io/color.h" #include "cartographer/sensor/point_cloud.h" @@ -67,7 +67,7 @@ struct PointsBatch { }; // Removes the indices in 'to_remove' from 'batch'. -void RemovePoints(std::unordered_set to_remove, PointsBatch* batch); +void RemovePoints(absl::flat_hash_set to_remove, PointsBatch* batch); } // namespace io } // namespace cartographer diff --git a/cartographer/mapping/internal/collated_trajectory_builder.cc b/cartographer/mapping/internal/collated_trajectory_builder.cc index bfb73af..b72aa26 100644 --- a/cartographer/mapping/internal/collated_trajectory_builder.cc +++ b/cartographer/mapping/internal/collated_trajectory_builder.cc @@ -39,7 +39,7 @@ CollatedTrajectoryBuilder::CollatedTrajectoryBuilder( trajectory_id_(trajectory_id), wrapped_trajectory_builder_(std::move(wrapped_trajectory_builder)), last_logging_time_(std::chrono::steady_clock::now()) { - std::unordered_set expected_sensor_id_strings; + absl::flat_hash_set expected_sensor_id_strings; for (const auto& sensor_id : expected_sensor_ids) { if (sensor_id.type == SensorId::SensorType::LANDMARK && !collate_landmarks_) { diff --git a/cartographer/mapping/internal/connected_components.cc b/cartographer/mapping/internal/connected_components.cc index 6306b0b..131fb4f 100644 --- a/cartographer/mapping/internal/connected_components.cc +++ b/cartographer/mapping/internal/connected_components.cc @@ -17,8 +17,8 @@ #include "cartographer/mapping/internal/connected_components.h" #include -#include +#include "absl/container/flat_hash_set.h" #include "cartographer/mapping/proto/connected_components.pb.h" #include "glog/logging.h" diff --git a/cartographer/sensor/collator_interface.h b/cartographer/sensor/collator_interface.h index 6fff62d..91d7c83 100644 --- a/cartographer/sensor/collator_interface.h +++ b/cartographer/sensor/collator_interface.h @@ -19,9 +19,9 @@ #include #include -#include #include +#include "absl/container/flat_hash_set.h" #include "absl/types/optional.h" #include "cartographer/sensor/data.h" @@ -42,7 +42,7 @@ class CollatorInterface { // for each collated sensor data. virtual void AddTrajectory( int trajectory_id, - const std::unordered_set& expected_sensor_ids, + const absl::flat_hash_set& expected_sensor_ids, const Callback& callback) = 0; // Marks 'trajectory_id' as finished. diff --git a/cartographer/sensor/internal/collator.cc b/cartographer/sensor/internal/collator.cc index 7db3aa5..917d6be 100644 --- a/cartographer/sensor/internal/collator.cc +++ b/cartographer/sensor/internal/collator.cc @@ -21,7 +21,7 @@ namespace sensor { void Collator::AddTrajectory( const int trajectory_id, - const std::unordered_set& expected_sensor_ids, + const absl::flat_hash_set& expected_sensor_ids, const Callback& callback) { for (const auto& sensor_id : expected_sensor_ids) { const auto queue_key = QueueKey{trajectory_id, sensor_id}; diff --git a/cartographer/sensor/internal/collator.h b/cartographer/sensor/internal/collator.h index 053b27e..bea93af 100644 --- a/cartographer/sensor/internal/collator.h +++ b/cartographer/sensor/internal/collator.h @@ -19,10 +19,10 @@ #include #include -#include #include #include "absl/container/flat_hash_map.h" +#include "absl/container/flat_hash_set.h" #include "cartographer/sensor/collator_interface.h" #include "cartographer/sensor/data.h" #include "cartographer/sensor/internal/ordered_multi_queue.h" @@ -37,9 +37,10 @@ class Collator : public CollatorInterface { Collator(const Collator&) = delete; Collator& operator=(const Collator&) = delete; - void AddTrajectory(int trajectory_id, - const std::unordered_set& expected_sensor_ids, - const Callback& callback) override; + void AddTrajectory( + int trajectory_id, + const absl::flat_hash_set& expected_sensor_ids, + const Callback& callback) override; void FinishTrajectory(int trajectory_id) override; diff --git a/cartographer/sensor/internal/collator_test.cc b/cartographer/sensor/internal/collator_test.cc index e0f79b1..6cf9099 100644 --- a/cartographer/sensor/internal/collator_test.cc +++ b/cartographer/sensor/internal/collator_test.cc @@ -67,7 +67,7 @@ TEST(Collator, Ordering) { Collator collator; collator.AddTrajectory( kTrajectoryId, - std::unordered_set(kSensorId.begin(), kSensorId.end()), + absl::flat_hash_set(kSensorId.begin(), kSensorId.end()), [&received, kTrajectoryId](const std::string& sensor_id, std::unique_ptr data) { received.push_back(CollatorOutput(kTrajectoryId, data->GetSensorId(), @@ -134,7 +134,7 @@ TEST(Collator, OrderingMultipleTrajectories) { Collator collator; collator.AddTrajectory( kTrajectoryId[0], - std::unordered_set(kSensorId.begin(), kSensorId.end()), + absl::flat_hash_set(kSensorId.begin(), kSensorId.end()), [&received, kTrajectoryId](const std::string& sensor_id, std::unique_ptr data) { received.push_back(CollatorOutput(kTrajectoryId[0], data->GetSensorId(), @@ -142,7 +142,7 @@ TEST(Collator, OrderingMultipleTrajectories) { }); collator.AddTrajectory( kTrajectoryId[1], - std::unordered_set(kSensorId.begin(), kSensorId.end()), + absl::flat_hash_set(kSensorId.begin(), kSensorId.end()), [&received, kTrajectoryId](const std::string& sensor_id, std::unique_ptr data) { received.push_back(CollatorOutput(kTrajectoryId[1], data->GetSensorId(), diff --git a/cartographer/sensor/internal/trajectory_collator.cc b/cartographer/sensor/internal/trajectory_collator.cc index 4b7c89c..982dbbd 100644 --- a/cartographer/sensor/internal/trajectory_collator.cc +++ b/cartographer/sensor/internal/trajectory_collator.cc @@ -25,7 +25,7 @@ metrics::Family* void TrajectoryCollator::AddTrajectory( const int trajectory_id, - const std::unordered_set& expected_sensor_ids, + const absl::flat_hash_set& expected_sensor_ids, const Callback& callback) { CHECK_EQ(trajectory_to_queue_.count(trajectory_id), 0); for (const auto& sensor_id : expected_sensor_ids) { diff --git a/cartographer/sensor/internal/trajectory_collator.h b/cartographer/sensor/internal/trajectory_collator.h index 135a60d..4b7c7e4 100644 --- a/cartographer/sensor/internal/trajectory_collator.h +++ b/cartographer/sensor/internal/trajectory_collator.h @@ -42,9 +42,10 @@ class TrajectoryCollator : public CollatorInterface { TrajectoryCollator(const TrajectoryCollator&) = delete; TrajectoryCollator& operator=(const TrajectoryCollator&) = delete; - void AddTrajectory(int trajectory_id, - const std::unordered_set& expected_sensor_ids, - const Callback& callback) override; + void AddTrajectory( + int trajectory_id, + const absl::flat_hash_set& expected_sensor_ids, + const Callback& callback) override; void FinishTrajectory(int trajectory_id) override; diff --git a/cartographer/sensor/internal/trajectory_collator_test.cc b/cartographer/sensor/internal/trajectory_collator_test.cc index 7f35eb8..cb8f5f5 100644 --- a/cartographer/sensor/internal/trajectory_collator_test.cc +++ b/cartographer/sensor/internal/trajectory_collator_test.cc @@ -63,7 +63,7 @@ TEST(TrajectoryCollator, OrderingMultipleTrajectories) { TrajectoryCollator collator; collator.AddTrajectory( kTrajectoryId[0], - std::unordered_set(kSensorId.begin(), kSensorId.end()), + absl::flat_hash_set(kSensorId.begin(), kSensorId.end()), [&received, kTrajectoryId](const std::string& sensor_id, std::unique_ptr data) { received.push_back(CollatorOutput(kTrajectoryId[0], data->GetSensorId(), @@ -71,7 +71,7 @@ TEST(TrajectoryCollator, OrderingMultipleTrajectories) { }); collator.AddTrajectory( kTrajectoryId[1], - std::unordered_set(kSensorId.begin(), kSensorId.end()), + absl::flat_hash_set(kSensorId.begin(), kSensorId.end()), [&received, kTrajectoryId](const std::string& sensor_id, std::unique_ptr data) { received.push_back(CollatorOutput(kTrajectoryId[1], data->GetSensorId(), diff --git a/cartographer/sensor/internal/voxel_filter.h b/cartographer/sensor/internal/voxel_filter.h index a8edbbe..f14575b 100644 --- a/cartographer/sensor/internal/voxel_filter.h +++ b/cartographer/sensor/internal/voxel_filter.h @@ -18,8 +18,8 @@ #define CARTOGRAPHER_SENSOR_INTERNAL_VOXEL_FILTER_H_ #include -#include +#include "absl/container/flat_hash_set.h" #include "cartographer/common/lua_parameter_dictionary.h" #include "cartographer/sensor/point_cloud.h" #include "cartographer/sensor/proto/adaptive_voxel_filter_options.pb.h" @@ -58,7 +58,7 @@ class VoxelFilter { Eigen::Array3i GetCellIndex(const Eigen::Vector3f& point) const; float resolution_; - std::unordered_set voxel_set_; + absl::flat_hash_set voxel_set_; }; proto::AdaptiveVoxelFilterOptions CreateAdaptiveVoxelFilterOptions(