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?