Connecting to Multiple ODrives in Python

#1

This is sort of a follow-up to this post: Connecting multiple ODrive boards to one PC

I have 4 ODrives I’m trying to control from one Linux computer, and would like to do it via the Python interface. However, I can’t figure out how to connect to each of the ODrives in a Python script (odrivetool does it just fine).

I can discover one using odrive.find_any() but can’t figure out the syntax for connecting to multiple odrives at the same time. I’ve tried the following syntax
odrive.find_any("serial:/dev/ttyACM0")
odrive.find_any("usb",208737963548)
odrive.find_any("usb",'208737963548')
But all of these just sit there for minutes without finding the device.

I found the odrive.find_all() command that odrive.find_any() calls, but I can’t seem to figure out the syntax or the requirement arguments to simply connect to all of the odrives. I’m not familiar with the fibre library and haven’t worked through all that it’s trying to do or how it’s doing it.

Is there an easy way to connect to multiple ODrives in a Python script?

Thanks!

#2

Have you tried calling find_any() multiple times sequentially and saving each instance to a different variable? I think that worked for me. You can check the serial numbers afterwards to make sure you have correct configuration.

#3

Odrv1 = odrive.find_any(serial_number=serial1)
Odrv2 = odrive.find_any(serial_number=serial2)

This works perfect for me. serial1 and serial2 are the serial numbers (as a string) of the odrives.

#4

That doesn’t work for me. When I type the code below I do not get a reply. I am certain the serial is correct because find_any().serial_number outputs this number.

odrv0 = odrive.find_any(serial_number="62020256281655")

#5

Figured out what I was doing wrong. Appearantly an Odrive has two different serial numbers, the one you are looking for is the one that pops up in odrivetool when you connect.

In the Odrivetool I get:

Connected to ODrive 386837583437 as odrv0
In [1]: odrv0.serial_number
Out[1]: 62020256281655

And odrv0 = odrive.find_any(serial_number="386837583437") gets me a connection. I also found out why:

image

3 Likes