AutonomyLab/libcreate

Large delay in recieving messages from Roomba

Opened this issue · 1 comments

I am using libcreate on a Raspberry Pi Zero W to communicate with a Roomba 694. I am noticing a delay of 30 seconds to 2 minutes for messages coming from the Roomba. Looking at the code this delay appears to be coming from messages coming in faster than they can be processed and filling up the serial buffer. My application uses stream mode as it is a V3 device.

I know my case is extreme and most people will not be using 1-core systems. I still feel like this is not the correct way to implement receiving messages from the Roomba. We should be fetching the newest message from the Roomba rather than the oldest message in the buffer.

As a temporary workaround, I have been clearing the buffer after each message is received and the delay has diappeared. I have not fully tested to see if half messages are coming through and being marked as corrupted.

What would be the best way to ensure each message we process is the latest from the Roomba and any older messages are discarded?

Also anyone else jump in if you have experienced this.

I'm not sure what the best strategy is for your setup, but one idea is we could add an option to use the serial "query" mode, even though you have a V3 device (which I think should still work). For example, instead of only using the protocol version here to choose the serial mode, we could add an option to override the choice:

libcreate/src/create.cpp

Lines 47 to 52 in d75d41c

if (model.getVersion() == V_1) {
serial = std::make_shared<SerialQuery>(data, install_signal_handler);
} else {
serial = std::make_shared<SerialStream>(
data, create::util::STREAM_HEADER, install_signal_handler);
}