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 0b37155ed6
commit c0b9ecdc82
No known key found for this signature in database
GPG Key ID: 866DB5F0E24821BB
1 changed files with 11 additions and 1 deletions

View File

@ -420,8 +420,18 @@ void UxrceddsClient::run()
_subs->update(&session, reliable_out, best_effort_out, participant_id, _client_namespace);
// 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) {
if (uxr_sync_session(&session, 100)) {