uxrce_dds_client: immediately create data writers on startup

There is some race condition where in rare cases the topic publication
right after creating the writer did not get received on the ROS side.
This happens even with reliable QoS & reliable transport.
This commit is contained in:
Beat Küng
2024-01-18 13:12:28 +01:00
parent ba35ca461c
commit 6fcfd5fac1
3 changed files with 20 additions and 20 deletions
@@ -366,6 +366,11 @@ bool UxrceddsClient::setupSession(uxrSession *session)
return false;
}
if (!_subs->init(session, _reliable_out, reliable_in, best_effort_in, _participant_id, _client_namespace)) {
PX4_ERR("subs init failed");
return false;
}
// create VehicleCommand replier
if (_num_of_repliers < MAX_NUM_REPLIERS) {
if (add_replier(new VehicleCommandSrv(session, _reliable_out, reliable_in, _participant_id, _client_namespace,
@@ -388,11 +393,6 @@ void UxrceddsClient::deleteSession(uxrSession *session)
_session_created = false;
}
if (_subs_initialized) {
_subs->reset();
_subs_initialized = false;
}
_last_payload_tx_rate = 0;
_timesync.reset_filter();
}
@@ -650,9 +650,6 @@ void UxrceddsClient::run()
int poll_error_counter = 0;
resetConnectivityCounters();
_subs->init();
_subs_initialized = true;
while (!should_exit() && _connected) {
perf_begin(_loop_perf);
perf_count(_loop_interval_perf);