I am precalculating the positions to send to motors then use a loop like below to send such commands.
On an Intel Core i5 PC, I noticed that each iteration of the loop (in other words without waiting), was about 5ms.
On raspberry pi however, i’m more the 20~22ms range. i’m using the latest rpi 3 model B+
I use native-stream for usb communication.
In other words
1/0.005 = 200 Hz on PC
1/0.022 = 45 Hz on raspberry pi
apart from porting my code from python to c++, is there anyway that i can increase this frequency on raspberry pi ? (or maybe finding a faster python implementation that python3
t0 = time.monotonic() # gives current absolute time in sec. ex: 28774.414338526 for i in range(0,m): if (i<len(distances_a)): self.cur_a = distances_a[i] if (i<len(distances_b)): self.cur_b = distances_b[i] self.my_odrive.motor0.set_pos_setpoint(int(self.cur_a), 0.0, 0.0) self.my_odrive.motor1.set_pos_setpoint(int(self.cur_b), 0.0, 0.0) t1 = time.monotonic() duration = (t1 - t0) t0 = t1 time_to_sleep = self.dt - duration if (time_to_sleep >0): time.sleep(time_to_sleep)