Delay when using two roboclaws over usb

General discussion of using Roboclaw motor controllers
Post Reply
mastns
Posts: 2
Joined: Wed Jul 24, 2019 6:56 am
Delay when using two roboclaws over usb

Post by mastns »

Hello,

I have connected 2 roboclaws in order to control 4 motors.
I have enabled Relay mode on the first Roboclaw that is connected to the USB port of my PC.
I have also changed its Packet Serial Address, 128 on the first one, 129 on the second one.
Last, I have connect S1 from one Roboclaw to S2 on the other and vis-versa.

The problem is that I am experiencing delays when sending commands over a joystick.
My python code looks like the following:

##################
rc = Roboclaw("/dev/ttyACM0", 115200)
rc.Open()
address = 0x80
address2 = 0x81

if data.axes[1] >= 0:
rc.ForwardM1(address, int(data.axes[1]*32))
rc.ForwardM1(address2,int(data.axes[1]*32))
else:
rc.BackwardM1(address,-int(data.axes[1]*32))
rc.BackwardM1(address2,-int(data.axes[1]*32))
##################

It is straightforward. data.axes are the joystick values.

I am experiencing something like command buffering. the commands are not executed on time but after 1 or 2 seconds etc, one after the other.

Do you have any suggestions ?

Thank you in advance for your help.

Athanasios Mastrogeorgiou
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Delay when using two roboclaws over usb

Post by Basicmicro Support »

You need to determine if the delay is happening on the Roboclaw command calls. Add "import time" to your script. Then add:

millis = int(round(time.time() * 1000))
print millis

Before and after each Roboclaw call.

Let me know the results.

I would also suggest you put similar code around the code that reads the joysticks or anything else that could be added delays.

Post Reply