Fixing 846 without tests. (#1183)

Fixing "Optimizing: -nan%... #846" https://github.com/googlecartographer/cartographer/issues/846.
The issue was triggered in a multithreaded execution, when all nodes were processed, but the working queue was still non empty (having other kind of jobs).
Unfortunately I failed to reproduce the bug in tests, so no new tests were added.
master
sotnik-github 2018-06-06 15:38:10 +02:00 committed by Wally B. Feed
parent 4ef38497a9
commit 3f0bb0eec5
2 changed files with 22 additions and 16 deletions

View File

@ -397,6 +397,8 @@ void PoseGraph2D::WaitForAllComputations() {
!work_queue_); !work_queue_);
}, },
common::FromSeconds(1.))) { common::FromSeconds(1.))) {
// Log progress on nodes only when we are actually processing nodes.
if (num_trajectory_nodes_ != num_finished_nodes_at_start) {
std::ostringstream progress_info; std::ostringstream progress_info;
progress_info << "Optimizing: " << std::fixed << std::setprecision(1) progress_info << "Optimizing: " << std::fixed << std::setprecision(1)
<< 100. * << 100. *
@ -406,6 +408,7 @@ void PoseGraph2D::WaitForAllComputations() {
<< "%..."; << "%...";
std::cout << "\r\x1b[K" << progress_info.str() << std::flush; std::cout << "\r\x1b[K" << progress_info.str() << std::flush;
} }
}
std::cout << "\r\x1b[KOptimizing: Done. " << std::endl; std::cout << "\r\x1b[KOptimizing: Done. " << std::endl;
constraint_builder_.WhenDone( constraint_builder_.WhenDone(
[this, [this,

View File

@ -412,6 +412,8 @@ void PoseGraph3D::WaitForAllComputations() {
!work_queue_); !work_queue_);
}, },
common::FromSeconds(1.))) { common::FromSeconds(1.))) {
// Log progress on nodes only when we are actually processing nodes.
if (num_trajectory_nodes_ != num_finished_nodes_at_start) {
std::ostringstream progress_info; std::ostringstream progress_info;
progress_info << "Optimizing: " << std::fixed << std::setprecision(1) progress_info << "Optimizing: " << std::fixed << std::setprecision(1)
<< 100. * << 100. *
@ -421,6 +423,7 @@ void PoseGraph3D::WaitForAllComputations() {
<< "%..."; << "%...";
std::cout << "\r\x1b[K" << progress_info.str() << std::flush; std::cout << "\r\x1b[K" << progress_info.str() << std::flush;
} }
}
std::cout << "\r\x1b[KOptimizing: Done. " << std::endl; std::cout << "\r\x1b[KOptimizing: Done. " << std::endl;
constraint_builder_.WhenDone( constraint_builder_.WhenDone(
[this, [this,