From 333516d95564d05200d359d0c3d0a3904dc15e1d Mon Sep 17 00:00:00 2001 From: Wolfgang Hess Date: Thu, 7 Sep 2017 14:04:00 +0200 Subject: [PATCH] Rename the scan queue. (#505) This queue does not only contain scans, but also other sensor data, e.g. from an IMU. --- cartographer/mapping_2d/sparse_pose_graph.cc | 26 ++++++++++---------- cartographer/mapping_2d/sparse_pose_graph.h | 8 +++--- cartographer/mapping_3d/sparse_pose_graph.cc | 26 ++++++++++---------- cartographer/mapping_3d/sparse_pose_graph.h | 8 +++--- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/cartographer/mapping_2d/sparse_pose_graph.cc b/cartographer/mapping_2d/sparse_pose_graph.cc index d719f3b..02f0c3f 100644 --- a/cartographer/mapping_2d/sparse_pose_graph.cc +++ b/cartographer/mapping_2d/sparse_pose_graph.cc @@ -48,7 +48,7 @@ SparsePoseGraph::SparsePoseGraph( SparsePoseGraph::~SparsePoseGraph() { WaitForAllComputations(); common::MutexLocker locker(&mutex_); - CHECK(scan_queue_ == nullptr); + CHECK(work_queue_ == nullptr); } std::vector SparsePoseGraph::GrowSubmapTransformsAsNeeded( @@ -140,10 +140,10 @@ void SparsePoseGraph::AddScan( } void SparsePoseGraph::AddWorkItem(const std::function& work_item) { - if (scan_queue_ == nullptr) { + if (work_queue_ == nullptr) { work_item(); } else { - scan_queue_->push_back(work_item); + work_queue_->push_back(work_item); } } @@ -298,15 +298,15 @@ void SparsePoseGraph::ComputeConstraintsForScan( num_scans_since_last_loop_closure_ > options_.optimize_every_n_scans()) { CHECK(!run_loop_closure_); run_loop_closure_ = true; - // If there is a 'scan_queue_' already, some other thread will take care. - if (scan_queue_ == nullptr) { - scan_queue_ = common::make_unique>>(); - HandleScanQueue(); + // If there is a 'work_queue_' already, some other thread will take care. + if (work_queue_ == nullptr) { + work_queue_ = common::make_unique>>(); + HandleWorkQueue(); } } } -void SparsePoseGraph::HandleScanQueue() { +void SparsePoseGraph::HandleWorkQueue() { constraint_builder_.WhenDone( [this](const sparse_pose_graph::ConstraintBuilder::Result& result) { { @@ -319,16 +319,16 @@ void SparsePoseGraph::HandleScanQueue() { num_scans_since_last_loop_closure_ = 0; run_loop_closure_ = false; while (!run_loop_closure_) { - if (scan_queue_->empty()) { + if (work_queue_->empty()) { LOG(INFO) << "We caught up. Hooray!"; - scan_queue_.reset(); + work_queue_.reset(); return; } - scan_queue_->front()(); - scan_queue_->pop_front(); + work_queue_->front()(); + work_queue_->pop_front(); } // We have to optimize again. - HandleScanQueue(); + HandleWorkQueue(); }); } diff --git a/cartographer/mapping_2d/sparse_pose_graph.h b/cartographer/mapping_2d/sparse_pose_graph.h index 7f3c38a..1e927b7 100644 --- a/cartographer/mapping_2d/sparse_pose_graph.h +++ b/cartographer/mapping_2d/sparse_pose_graph.h @@ -142,8 +142,8 @@ class SparsePoseGraph : public mapping::SparsePoseGraph { REQUIRES(mutex_); // Registers the callback to run the optimization once all constraints have - // been computed, that will also do all work that queue up in 'scan_queue_'. - void HandleScanQueue() REQUIRES(mutex_); + // been computed, that will also do all work that queue up in 'work_queue_'. + void HandleWorkQueue() REQUIRES(mutex_); // Waits until we caught up (i.e. nothing is waiting to be scheduled), and // all computations have finished. @@ -166,9 +166,9 @@ class SparsePoseGraph : public mapping::SparsePoseGraph { const mapping::proto::SparsePoseGraphOptions options_; common::Mutex mutex_; - // If it exists, further scans must be added to this queue, and will be + // If it exists, further work items must be added to this queue, and will be // considered later. - std::unique_ptr>> scan_queue_ + std::unique_ptr>> work_queue_ GUARDED_BY(mutex_); // How our various trajectories are related. diff --git a/cartographer/mapping_3d/sparse_pose_graph.cc b/cartographer/mapping_3d/sparse_pose_graph.cc index 2c59b0f..9cef64f 100644 --- a/cartographer/mapping_3d/sparse_pose_graph.cc +++ b/cartographer/mapping_3d/sparse_pose_graph.cc @@ -49,7 +49,7 @@ SparsePoseGraph::SparsePoseGraph( SparsePoseGraph::~SparsePoseGraph() { WaitForAllComputations(); common::MutexLocker locker(&mutex_); - CHECK(scan_queue_ == nullptr); + CHECK(work_queue_ == nullptr); } std::vector SparsePoseGraph::GrowSubmapTransformsAsNeeded( @@ -135,10 +135,10 @@ void SparsePoseGraph::AddScan( } void SparsePoseGraph::AddWorkItem(const std::function& work_item) { - if (scan_queue_ == nullptr) { + if (work_queue_ == nullptr) { work_item(); } else { - scan_queue_->push_back(work_item); + work_queue_->push_back(work_item); } } @@ -313,15 +313,15 @@ void SparsePoseGraph::ComputeConstraintsForScan( num_scans_since_last_loop_closure_ > options_.optimize_every_n_scans()) { CHECK(!run_loop_closure_); run_loop_closure_ = true; - // If there is a 'scan_queue_' already, some other thread will take care. - if (scan_queue_ == nullptr) { - scan_queue_ = common::make_unique>>(); - HandleScanQueue(); + // If there is a 'work_queue_' already, some other thread will take care. + if (work_queue_ == nullptr) { + work_queue_ = common::make_unique>>(); + HandleWorkQueue(); } } } -void SparsePoseGraph::HandleScanQueue() { +void SparsePoseGraph::HandleWorkQueue() { constraint_builder_.WhenDone( [this](const sparse_pose_graph::ConstraintBuilder::Result& result) { { @@ -334,16 +334,16 @@ void SparsePoseGraph::HandleScanQueue() { num_scans_since_last_loop_closure_ = 0; run_loop_closure_ = false; while (!run_loop_closure_) { - if (scan_queue_->empty()) { + if (work_queue_->empty()) { LOG(INFO) << "We caught up. Hooray!"; - scan_queue_.reset(); + work_queue_.reset(); return; } - scan_queue_->front()(); - scan_queue_->pop_front(); + work_queue_->front()(); + work_queue_->pop_front(); } // We have to optimize again. - HandleScanQueue(); + HandleWorkQueue(); }); } diff --git a/cartographer/mapping_3d/sparse_pose_graph.h b/cartographer/mapping_3d/sparse_pose_graph.h index a128c8f..42d5a83 100644 --- a/cartographer/mapping_3d/sparse_pose_graph.h +++ b/cartographer/mapping_3d/sparse_pose_graph.h @@ -143,8 +143,8 @@ class SparsePoseGraph : public mapping::SparsePoseGraph { REQUIRES(mutex_); // Registers the callback to run the optimization once all constraints have - // been computed, that will also do all work that queue up in 'scan_queue_'. - void HandleScanQueue() REQUIRES(mutex_); + // been computed, that will also do all work that queue up in 'work_queue_'. + void HandleWorkQueue() REQUIRES(mutex_); // Waits until we caught up (i.e. nothing is waiting to be scheduled), and // all computations have finished. @@ -171,9 +171,9 @@ class SparsePoseGraph : public mapping::SparsePoseGraph { const mapping::proto::SparsePoseGraphOptions options_; common::Mutex mutex_; - // If it exists, further scans must be added to this queue, and will be + // If it exists, further work items must be added to this queue, and will be // considered later. - std::unique_ptr>> scan_queue_ + std::unique_ptr>> work_queue_ GUARDED_BY(mutex_); // How our various trajectories are related.