There is a 300 ms latency when I publish motor position commands from a python node to the OpenCR using rosserial. The publishing frequency is 200 hz (I have also tried lower frequencies e.g. 50 hz). You can see this in the graph I attach where I apply a sine wave to a single motor (out of 12 total). The other motors are at 0 rads. Each step also seems to be about 100 ms (10 hz) not 200 hz. I am using the Dynamixel SDK in arduino and syncRead/Write to send/receive position data.
However, when I disconnect the motors and publish the same position commands (and get the OpenCR to publish them back to python) the latency drops to 13 ms which is more normal.
I don't think it is a bandwidth issue as I am only publishing imu data and joint states. I tried not publishing imu data and latency stayed the same. I think its to do with having so many motors.
How can I reduce this massive latency?
Quick update: I have found that the latency is caused by calling the syncRead function in the Dynamixel SDK. My syncRead function is identical to the one found in the turtlebot3_realturtlebot_motor_driver.cpp example.
When I read both position and velocity (calling syncRead twice one after the other) The latency is 280 ms. If I just read position is drops to 230 ms and when I read nothing its 22 ms.
Thank you for reporting the issue.
We'll take a look into the library and get back to you.
Could you give us more information about your OpenCR board manager version of the Arduino IDE?
Also, make sure that your DYNAMIXEL is set to higher baudrate such as 1Mbps (default is 57600bps) with Return delay time of 0 (default is 250 = 500usec)
Assuming that you are using 12 joints with 8 byte strings as a name and fraime_id, I get 316 bytes.
Since OpenCR use 115200bps = 14400 byte per second, I'm worried about overloading the bandwidth as well when the control frequency is increased.