uxrce_dds_client: run session until we do not get data anymore

Otherwise there can be significant delay for received data
This commit is contained in:
Beat Küng 2023-09-07 13:41:04 +02:00
parent 36fbd18bdc
commit d12a7dd11d
1 changed files with 11 additions and 1 deletions

View File

@ -456,7 +456,17 @@ void UxrceddsClient::run()
// check if there are available replies
process_replies();
uxr_run_session_timeout(&session, 0);
// Run the session until we receive no more data or up to a maximum number of iterations.
// The maximum observed number of iterations was 6 (SITL). If we were to run only once, data starts to get
// delayed, causing registered flight modes to time out.
for (int i = 0; i < 10; ++i) {
const uint32_t prev_num_payload_received = _pubs->num_payload_received;
uxr_run_session_timeout(&session, 0);
if (_pubs->num_payload_received == prev_num_payload_received) {
break;
}
}
// time sync session
if (_synchronize_timestamps && hrt_elapsed_time(&last_sync_session) > 1_s) {