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,14 +397,17 @@ void PoseGraph2D::WaitForAllComputations() {
!work_queue_); !work_queue_);
}, },
common::FromSeconds(1.))) { common::FromSeconds(1.))) {
std::ostringstream progress_info; // Log progress on nodes only when we are actually processing nodes.
progress_info << "Optimizing: " << std::fixed << std::setprecision(1) if (num_trajectory_nodes_ != num_finished_nodes_at_start) {
<< 100. * std::ostringstream progress_info;
(constraint_builder_.GetNumFinishedNodes() - progress_info << "Optimizing: " << std::fixed << std::setprecision(1)
num_finished_nodes_at_start) / << 100. *
(num_trajectory_nodes_ - num_finished_nodes_at_start) (constraint_builder_.GetNumFinishedNodes() -
<< "%..."; num_finished_nodes_at_start) /
std::cout << "\r\x1b[K" << progress_info.str() << std::flush; (num_trajectory_nodes_ - num_finished_nodes_at_start)
<< "%...";
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(

View File

@ -412,14 +412,17 @@ void PoseGraph3D::WaitForAllComputations() {
!work_queue_); !work_queue_);
}, },
common::FromSeconds(1.))) { common::FromSeconds(1.))) {
std::ostringstream progress_info; // Log progress on nodes only when we are actually processing nodes.
progress_info << "Optimizing: " << std::fixed << std::setprecision(1) if (num_trajectory_nodes_ != num_finished_nodes_at_start) {
<< 100. * std::ostringstream progress_info;
(constraint_builder_.GetNumFinishedNodes() - progress_info << "Optimizing: " << std::fixed << std::setprecision(1)
num_finished_nodes_at_start) / << 100. *
(num_trajectory_nodes_ - num_finished_nodes_at_start) (constraint_builder_.GetNumFinishedNodes() -
<< "%..."; num_finished_nodes_at_start) /
std::cout << "\r\x1b[K" << progress_info.str() << std::flush; (num_trajectory_nodes_ - num_finished_nodes_at_start)
<< "%...";
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(