diff --git a/spot_driver/src/api/default_time_sync_api.cpp b/spot_driver/src/api/default_time_sync_api.cpp index ebfb48335..614d2fa60 100644 --- a/spot_driver/src/api/default_time_sync_api.cpp +++ b/spot_driver/src/api/default_time_sync_api.cpp @@ -2,6 +2,7 @@ #include #include +#include namespace spot_ros2 { @@ -12,6 +13,9 @@ tl::expected DefaultTimeSyncApi::getClo if (!time_sync_thread_) { return tl::make_unexpected("Time sync thread was not initialized."); } + if (!time_sync_thread_->WaitForSync(std::chrono::seconds(5))) { + return tl::make_unexpected("Failed to establish time sync before timing out."); + } if (!time_sync_thread_->HasEstablishedTimeSync()) { return tl::make_unexpected("Time sync not yet established between Spot and the local system."); }