Skip to content
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

Don't send so many very short UDP messages to avoid message loss #70

Merged
merged 4 commits into from
Apr 11, 2023

Conversation

brad112358
Copy link
Contributor

With QGround control, on both Linux and Android, I got lots of lost MAVLink messages without this change. When I checked, I saw that most UDP packets contained only a few bytes (1-3) of payload. I don't know which end the messages were being lost on.

The intent of this change is to wait for more bytes to be received on the serial link before sending a UDP packet, but still constrain the latency to a reasonable 5ms.

esp/mlrs-wifi-bridge/mlrs-wifi-bridge.ino Outdated Show resolved Hide resolved
esp/mlrs-wifi-bridge/mlrs-wifi-bridge.ino Outdated Show resolved Hide resolved
@olliw42
Copy link
Owner

olliw42 commented Apr 9, 2023

great, this makes lots of sense
I guess the 30 and 5ms has worked out well experimentally, couldn't this be increased to 10ms or even 20ms?
could you also test with MissionPlanner? (not asking for, I'm just curious)

@brad112358
Copy link
Contributor Author

brad112358 commented Apr 10, 2023

I haven't tested with mission planner yet, but I will let you know when I do. 30 and 5 was the first thing I tried and it helped so much I didn't think I needed to try others. But, after I submitted this PR, I discovered a few messages were still being lost so I have already increased the delay and message size which helped even more. I'll update this PR later.

I also have another idea for a heuristic which wouldn't add latency as much as this does: mLRS sends a mavlink message at a time in a burst, so we could actually wait for the break in serial reception, when the receive size stops growing for a ms or so, then send the packet. This should be especially effective at a slightly higher baud rate.

@olliw42
Copy link
Owner

olliw42 commented Apr 10, 2023

I'm really not concerned about 20ms vs 5ms
in other applications of mine, like the uavcan mavlik tunnel I did many years back, few 10-ish ms worked great
anyway, put in what you think is the best, it always can be further improved later

@brad112358
Copy link
Contributor Author

I did code up the heuristic to align UDP payload with MAVLink messages and it works quite well, allowing wireshark to decode mavlink messages and further limiting UDP message rate without much latency. I think I'll wait for your answer on why you don't like static locals before I push it.

@olliw42
Copy link
Owner

olliw42 commented Apr 11, 2023

I think we should first finish this up before attempting anything more difficult/else.

@brad112358
Copy link
Contributor Author

brad112358 commented Apr 11, 2023 via email

@brad112358
Copy link
Contributor Author

I did test mission planner on Windows 10 both with and without this change at 19Hz. Both worked fine with no sign of dropped messages. I'm not sure why QGC drops so many messages on Linux and Android with the original code.

Have you tested UDP bridge yet with Android?

@olliw42 olliw42 merged commit 890da51 into olliw42:main Apr 11, 2023
@olliw42
Copy link
Owner

olliw42 commented Apr 11, 2023

MANY THX :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants