Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dakejahl committed Nov 1, 2023
1 parent 11ef293 commit 8b05309
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/modules/uxrce_dds_client/uxrce_dds_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ void on_time(uxrSession *session, int64_t current_time, int64_t received_timesta
Timesync *timesync = static_cast<Timesync *>(args);
timesync->update(current_time / 1000, transmit_timestamp, originate_timestamp);

// fprintf(stderr, "time_offset: %lld, timesync: %lld, diff: %lld\n", session->time_offset/1000, timesync->offset(), session->time_offset/1000 + timesync->offset());
// PX4_INFO("utc time: %lld", (transmit_timestamp + (rtt / 2))/1000000000);
//fprintf(stderr, "time_offset: %lld, timesync: %lld, diff: %lld\n", session->time_offset/1000, timesync->offset(), session->time_offset/1000 + timesync->offset());

session->time_offset = -timesync->offset() * 1000; // us -> ns
}
Expand Down Expand Up @@ -103,7 +102,7 @@ UxrceddsClient::UxrceddsClient(Transport transport, const char *device, int baud
if (fd < 0) {
PX4_ERR("open %s failed (%i)", device, errno);
// sleep before trying again
usleep(1_s);
px4_sleep(1_s);

} else {
break;
Expand Down Expand Up @@ -323,9 +322,10 @@ void UxrceddsClient::run()
px4_clock_gettime(CLOCK_REALTIME, &ts);
time_t current_system_utc = ts.tv_sec + (ts.tv_nsec / 1e9);

if (current_system_utc > agent_utc ) {
if (current_system_utc > agent_utc) {
// Assume agents time is wrong if it's in the past
PX4_INFO("Agents UTC time is %f seconds in the past, not setting time", double((current_system_utc - agent_utc)/1000000));
PX4_INFO("Agents UTC time is %f seconds in the past, not setting time",
double((current_system_utc - agent_utc) / 1000000));
break;
}

Expand All @@ -342,7 +342,7 @@ void UxrceddsClient::run()
break;
}

usleep(10_ms);
px4_sleep(10_ms);
}

hrt_abstime last_sync_session = 0;
Expand Down Expand Up @@ -384,7 +384,7 @@ void UxrceddsClient::run()
// time sync session
if (_synchronize_timestamps && hrt_elapsed_time(&last_sync_session) > 1_s) {
if (uxr_sync_session(&session, 100)) {
// PX4_INFO("synchronized with time offset %-5" PRId64 "ns", session.time_offset);
//PX4_INFO("synchronized with time offset %-5" PRId64 "ns", session.time_offset);
last_sync_session = hrt_absolute_time();
}
}
Expand Down

0 comments on commit 8b05309

Please sign in to comment.