Connecting multiple ODrive boards to one PC

Hi,

Is there a way to communicate with multiple ODrives using one PC at the same time? Is it using find_all, which returns a generator? I have tried change the code in find_any, but that won’t work. Since I have a project needs to control multiple motors and make them work cooperatively, is there a way to do it by just using one PC? What is the code should be like?

Best Regards,

Yes, it definitely is possible. I have 3 connected through a USB hub. I’ve written a C++ interface for my needs at https://github.com/moorage/odrive_cpp_sdk

I’m sure you can use the existing python interface to do the same. They should have a function to find one by serial number (or /dev/ttyACM* if on native-stream)

Yes you can use find_all, it returns a generator. If you are uncomfortable using generators in Python, you can simply cast it to a list and use the list. So like:

all_odrives = list(odrive.find_all( ... ))
print(all_odrives[0].vbus_voltage)

Thank you so much for your help!

Thank you for your guidance, it is now working so well!

Best

2 Likes

keep in mind that connecting multiple devices to a USB hub doesn’t let you talk to them at the same time, you are talking to them sequentially.

for most things this is ‘good enough’, but if you are needing to have close coordination of movement across axis that are on different boards, this probably will fall out of ‘good enough’ pretty quickly

With C++, coordinating across a USB hub never became a problem for coordinating across all degrees of freedom, so that’s good news!

Just in case anyone stumbles upon this post; the above implementation has changed. The new implementation (currently on the development branch as of December 2019) uses find_any with an additional argument called find_multiple and will return a list containing the connected odrives. See the example below which will look for two odrives connected by USB.

odrives = odrive.find_any(find_multiple=2)

print('found {} ODrives'.format(len(odrives)))
for odrv in odrives:
    print(odrv.serial_number)

when run will output

$ ipython find_multiple.py
found 2 ODrives
35606208918856
62093270660151

which parameters will be written instead of these 3 points?

this does not work :
TypeError: find_any() got an unexpected keyword argument ‘find_multiple’

Im not a Python coder so i might be doing things wrong - i took some code from the fibre library and changed it. with this it will return a list of odrives after 30 seconds. I put it on a timer because i still need to figure out how to make it block right. the file is Odriver.py

it works well on my odrive devices. thank you

How to get this? I’m on latest 0.5.3 odrive and this find_all is still not recognized…

Also I get this ACKN issue via this code:
odrv0 = odrive.find_any(serial_number = “serial number 1 in hex”)
odrv1 = odrive.find_any(serial_number = “serial number 2 in hex”)

So what to do to be able to handle two boards?

It seems easy to find all serial numbers:

		odrives = usb.core.find(idVendor=0x1209, idProduct=0x0d32, find_all=True)
		for dev in odrives:
			print(dev.serial_number)
1 Like