-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
Mavlink Ping Protocol Implementation #9399
Conversation
@dagar @bkueng What do you think about rolling We might also want to enable a 1Hz ping on the low-bandwidth telemetry links (e.g SiK radios) for latency measurement and packet drop statistics. |
ddd9b91
to
210317c
Compare
Yes I think that makes sense. It's come up before in the context of iridium status. The current telemetry_status has quite a few fields from RADIO_STATUS that don't apply generally.
|
Streaming ping at 10 Hz? Shouldn't it only be responding to pings? |
@mhkabir Once this is accepted, can we please have a summary of the Ping protocol as a sub page of https://mavlink.io/en/protocol/overview.html ? (assuming that makes sense) |
@dagar It is sending pings requests at 10Hz on onboard links. A companion system will bounce these back and we can calculate latency from that. @hamishwillee Will do! |
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.
I'm also wondering whether we really need 10Hz?
What do you think about rolling telemetry_status and ping into one single link_health topic, with the radio-specific fields only being filled if the link is wireless.
Makes sense.
src/modules/mavlink/mavlink_main.h
Outdated
@@ -480,6 +480,21 @@ class Mavlink | |||
|
|||
bool ftp_enabled() const { return _ftp_on; } | |||
|
|||
struct ping_statistics { |
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.
I suggest to rename to something like ping_statistics_t
for clarity
/* Ping status is supported only on first ORB_MULTI_MAX_INSTANCES mavlink channels */ | ||
if (_mavlink->get_channel() < (mavlink_channel_t)ORB_MULTI_MAX_INSTANCES) { | ||
|
||
struct ping_s png = {}; |
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.
uorb_ping_message
and mavlink_ping_message
instead of png
?
(ping.target_component == | ||
mavlink_system.compid)) { // This is a returned ping message from this system. Calculate latency from it. | ||
|
||
double rtt_ms = (hrt_absolute_time() - ping.time_usec) / 1000.0; |
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 directly use float here?
// Update ping statistics | ||
struct Mavlink::ping_statistics &pstats = _mavlink->get_ping_statistics(); | ||
|
||
pstats.last_ping_time = hrt_absolute_time(); |
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 calculate the time only once in this code block?
const hrt_abstime now = hrt_absolute_time();
pstats.last_ping_seq = ping.seq - 1; | ||
} | ||
|
||
pstats.dropped_packets += (ping.seq - pstats.last_ping_seq - 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.
unnecessary brackets
@bkueng All addressed. I also reduced rate of ping on onboard/USB links to 2Hz. Please review and merge. :) |
Is there any reason it needs to be sent regularly? On a radio link, this already consumes some bandwidth. 0.1 Hz would be more than sufficient for normal instrumentation. |
The reason why I implemented the ping in the first place was to debug transient spikes in the link quality on a companion link, which would usually last under 1s. I can reduce it to 0.1Hz for radio links if desired. |
That makes sense - let's use different rates for the different configurations. We have the distinction already, so let's leverage it. |
Updated PR with reduced rates. Please review @LorenzMeier @bkueng. |
It seems like the SiK radios use the "normal" mode. This degree of distinction seems insufficient to me. Even SITL uses the "normal" mode, and reducing the rate to 0.1Hz in SITL is unnecessary. Can we have a separate mode for the SiK radios if we don't have one already? @dagar Thoughts? |
It's not because SITL needs to run in the same mode as the radio (otherwise its not anymore simulating the system). |
Okay, in that case, this is ready to merge. |
Cool. @mhkabir don't forget mavlink/mavlink-devguide#52 :-) |
This implements the full ping protocol from MAVLink so that we can accurately measure link quality. Status is published to the
ping
uORB topic and logged, and is also available from the system console usingmavlink status
:Example :