I have a Raspberry Pi communicating with the ODrive (via USB) controlling 2 motors, but reading data and sending control commands takes a long time. Is there a command that can query the ODrive for all sensor values at once? Or is there a firmware level change to increase the speed of communicating with the ODrive?
For example, getting encoder position for one axis within a loop runs at 600 Hz (see sample code below). Getting 2 encoders slows down the loop rate to 300 Hz. Sending/receiving 6 values: 2 encoder + 2 measured current + 2 current set points (the bare minimum I need) slows down the loop rate to 100 Hz. Ideally I’d be getting 12+ values from the ODrive at all times (state, errors, temperature) but this reduces loop frequency to <50 Hz. It would be awesome to get all these at 100+ Hz.
- Raspberry Pi 3 B+
- ODrive v3.6 (with SPI firmware)
- USB communication between Pi and ODrive
- Using Python to control ODrive
Here is a really simple function I used to test this (I call this from the odrivetool command line interface after the appropriate imports):
def testSpeed(odrv0,nTimes): Iteration = 0 t0 = time.time() print('Running...') while(True): try: Iteration += 1 Time = time.time() - t0 for i in range(nTimes): odrv0.axis0.encoder.pos_estimate if Time >= 5: break except KeyboardInterrupt: print('\n***STOPPED BY USER***') break print('Mean freq: %20.2f Hz' % ((Iteration + 0.0)/Time))