Didn't get too much time to spend on this tonight, but I did run some timing tests using the new sendInstruction implementation.
Test setup is three AX-12+ on a bus with 1Mbps baud rate and reading the entire 50 byte table. Return Delay Time is 0.
Here is a receive code snippet:
Code:
byte[] status = new byte[instruction.getReturnPacketLength()];
int bytesReceived = 0;
long startTime = System.nanoTime();
while (bytesReceived < status.length && (System.nanoTime() - startTime) < receiveTimeoutNanos) {
byte[] bytes = receive();
if (bytes != null) {
System.arraycopy(bytes, 0, status, bytesReceived, bytes.length);
bytesReceived += bytes.length;
}
}
I now include the duration in nanos, which I need for the timeout anway, in the status return object. This makes it easy to benchmark.
Here are the numbers.
USB2AX
fastestTimeMillis = 0.742871
slowestTimeMillis = 1.263982
averageTimeMillis = 1.0172655466666665
USB2Dynamixel
fastestTimeMillis = 1.008165
slowestTimeMillis = 16.386709
averageTimeMillis = 8.790776
These numbers validate the times that I had settled on using the send/wait/receive approach (2 millis for USB2AX and ~20 millis for USB2Dynamixel). And as Xevel mentioned, I should also state that the USB2Dynamixel driver has not been tuned.
Bookmarks