Skip to content

Commit

Permalink
fix: add WaitForSync call
Browse files Browse the repository at this point in the history
  • Loading branch information
mschweig committed Jan 3, 2025
1 parent bf06fdc commit 9e792ea
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions spot_driver/src/api/default_time_sync_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <spot_driver/api/default_time_sync_api.hpp>
#include <tl_expected/expected.hpp>
#include <chrono>

namespace spot_ros2 {

Expand All @@ -12,6 +13,9 @@ tl::expected<google::protobuf::Duration, std::string> 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.");
}
Expand Down

0 comments on commit 9e792ea

Please sign in to comment.