Skip to content

Commit

Permalink
[LatestTimeSync] Fix crash when Synchronizeris started before the mes…
Browse files Browse the repository at this point in the history
…sges are available. (#137)
  • Loading branch information
destogl authored Jul 30, 2024
1 parent f93d754 commit 4c9392a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion include/message_filters/sync_policies/latest_time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,15 @@ struct LatestTime : public PolicyBase<M0, M1, M2, M3, M4, M5, M6, M7, M8>
{
bool step_change_detected = false;
do {
double period = (now - prev).seconds();
double period = 0.0;
try {
period = (now - prev).seconds();
} catch (const std::runtime_error & /*e*/) {
// Different time sources that might happen on initialization if the messages are not yet
// available.
// std::cout << "Exception: " << e.what() << std::endl;
return false;
}
if (period <= 0.0) {
// multiple messages and time isn't updating
return false;
Expand Down

0 comments on commit 4c9392a

Please sign in to comment.