-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AP_DDS: support automatic reconnect to micro-ROS agent #25228
AP_DDS: support automatic reconnect to micro-ROS agent #25228
Conversation
0e13a3d
to
304013f
Compare
304013f
to
a523b7e
Compare
a523b7e
to
224806d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
libraries/AP_DDS/AP_DDS_Client.cpp
Outdated
update(); | ||
|
||
// check ping response | ||
if (session.on_pong_flag == 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use PONG_IN_SESSION_STATUS
instead of magic 1, which is set in session.h
of the Micro-XRCE-DDS-Client library>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hal.scheduler->delay(1); | ||
update(); | ||
if (comm == nullptr) { | ||
GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "DDS Client: transport invalid, exiting"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is set from uxr_init_session(&session, comm, key);
, so perhaps better wording would be session invalid?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think the wording is ok: comm
is set when the transport initialises - before the session is initialised.
bool AP_DDS_Client::ddsSerialInit()
{
// setup a framed transport for serial
uxr_set_custom_transport_callbacks(&serial.transport, true,
serial_transport_open,
serial_transport_close,
serial_transport_write,
serial_transport_read);
if (!uxr_init_custom_transport(&serial.transport, (void*)this)) {
return false;
}
comm = &serial.transport.comm;
libraries/AP_DDS/AP_DDS_Client.cpp
Outdated
++num_pings_missed; | ||
} | ||
|
||
uxr_ping_agent_session(&session, 0, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you intend to set a timeout of 0 here? Note - for a non-obvious C-api like this one, I might actually just create some constexpr locals to show what is being passed in.
constexpr int timout_ping_ms {0};
constexpr int ping_attempts {1};
uxr_ping_agent_session(&session, timout_ping_ms, ping_attempts);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added const stack variables in:
a14e0af
Didn't add constexpr as we're adding for readability and are happy for the compiler to optimise these away.
The 0 timeout looks odd doesn't it? This is consistent with the approach used by the PX4 DDS implementation - it must be trying to poll at least once otherwise I'd expect a timeout. Need to trace this more thoroughly to understand why it does not fail every time.
224806d
to
38f5310
Compare
- Add ping test and attempt reconnect if connection dropped. - Retry ping test max_attempts before exiting. - Move `uxr_init_session` from transport init to session init for reconnect - Tidy handling of transport.comm - Fix codestyle Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> AP_DDS: use PONG_IN_SESSION_STATUS in status check Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com> AP_DDS: add local variables to clarify arguments to uxr_ping_agent_session Signed-off-by: Rhys Mainwaring <rhys.mainwaring@me.com>
a14e0af
to
6e96126
Compare
Add ping test and attempt to automatically reconnect to the micro-ROS agent.
Closes #23372
For details see: #23372 (comment)