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

libmavconn : enable low-latency mode on Linux #975

Merged
merged 1 commit into from
Mar 21, 2018
Merged

Conversation

mhkabir
Copy link
Member

@mhkabir mhkabir commented Mar 15, 2018

Some common USB-UART converters like the FTDI accumulate individual bytes from the serial link in order to send them in a single USB packet ("Nagling" - https://en.wikipedia.org/wiki/Nagle%27s_algorithm). This commit sets the ASYNC_LOW_LATENCY flag, which the FTDI kernel driver interprets as a request to drop the Nagling timer to 1ms (i.e send all accumulated bytes after 1ms.)

This reduces average link RTT to under 5ms at 921600 baud (it is 20-30 ms on master), and enables the use of mavros in systems where low latency is required to get good performance for e.g estimation and controls. As a side effect, this also greatly increases performance of timesync on serial links and prevents the hard-resets we've been seeing.

Copy link
Member

@TSC21 TSC21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good commit! Can you share some results?

@mhkabir
Copy link
Member Author

mhkabir commented Mar 15, 2018

@TSC21

Good commit! Can you share some results?

This reduces average link RTT to under 5ms at 921600 baud (it is 20-30 ms on master)

Some common USB-UART convertors like the FTDI accumulates individual bytes from the serial link
in order to send them in a single USB packet (Nagling). This commit sets the ASYNC_LOW_LATENCY flag,
which the FTDI kernel driver interprets as a request to drop the Nagling timer to 1ms (i.e send all
accumulated bytes after 1ms.)

This reduces average link RTT to under 5ms at 921600 baud, and enables the use of mavros in
systems where low latency is required to get good performance for e.g estimation and controls.
@TSC21
Copy link
Member

TSC21 commented Mar 15, 2018

Yeah I read that. I was asking if you have some pratical example where you tested this (ex: VIO) and you could show us the improvement on that situation.

@vooon vooon merged commit a77dcef into master Mar 21, 2018
@@ -61,7 +62,6 @@ MAVConnSerial::MAVConnSerial(uint8_t system_id, uint8_t component_id,
// Workaround to set some options for the port manually. This is done in
// Boost.ASIO, but until v1.12.0 (Boost 1.66) there was a bug which doesn't enable relevant
// code. Fixed by commit: https://github.com/boostorg/asio/commit/619cea4356
int fd = serial_dev.native_handle();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not portable outside of POSIX systems.

@vooon vooon added this to the Version 0.24 milestone Mar 21, 2018
@vooon vooon deleted the pr-linux-latency branch March 21, 2018 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants