Python 2.7 Support (for ROS)

Hello,

I have the python 3.5 odrivetool working with my motor.
However I need it to work with python 2.7 for use with Neomanic’s ROS node.
How do I run the odrivetool in python 2.7? Do I need to install odrive package into python 2.7 too?
The ROS node currently fails to launch due to not being able to import ‘odrive’

When I installed odrive it was as a 3.5 package - pip3 install odrive
My attempt to install it to 2.7 fails - pip install odrive

Any suggestions greatly appreciated.

1 Like

Finally worked this out.
odrive needs to be installed as a python 2 package in order to work.
Note that neomanics 2.7 compatibility patch is no longer required as python 2.7 is now supported by the truck again.

To install as python 2.7 package:
pip install monotonic
pip install IPython==5.0 --user
sudo pip install odrive

See the ROS node itself:

1 Like

Hi - I’m trying to get Odrive to work with Python 2.7. I’m using ROS as well. The Odrive library works fine with Python 3, but when I follow the above steps with Python 2, the script runs, but it hangs when trying to connect to the board. Any ideas?

Here are some details…

  • I have monotonic and ipython 5 installed as described above
  • Specifically the command that hangs is: instance = odrive.find_any()
  • I’m running Ubuntu 18.04
  • Python version = Python 2.7.17
  • Its a new 56 Volt board. HW = v3.6 and looks like firmware is v0.4.11

Note - the problem has nothing to do with ROS. I’m testing with a python test app that is completely separate from ROS. I’ve tried on 2 different machines - same problem on both.

Any ideas would be greatly appreciated.

i use ros noetic and this repo also but i got this kind of error can any one solve the issue

i tried ch340 module by rx and tx pin but it doesn’t work
should i need to use can bus

What’s your node configuration look like?

i use this package and set up it in the src folder of my workspace GitHub - neomanic/odrive_ros: ROS driver for the ODrive motor drive

I believe that node expects the ODrive to be connected over USB.

Should i use any CAN for it because everytime i connect it shows /dev/ttyACM0
It not showing ttyUSB
how can i get ttyUSB port when i connect odrive-ros package

ODrive gives both a tty port – that’s ttyACM0 – and a USB vendor device class. You actually don’t want to use the ttyACM0 port, since that only runs serial communications, not the high-efficiency binary connection that ODrivetool and the ROS node uses.

Maybe reading the node docs would help a bit? odrive_ros/src/odrive_ros/odrive_node.py at master · neomanic/odrive_ros · GitHub It looks like you need to pass the param connect_on_startup - see odrive_ros/src/odrive_ros/odrive_node.py at master · neomanic/odrive_ros · GitHub

i tried it with ttyACM0 port but it shows it is not connected
is there any solution of it


i use ros noetic , pyhton version 3 , ubuntu 20
can anyone give me a solution

As I said, you need to pass the connect_on_startup flag, which you’re not doing.

i change is from False to True but get this error


but odrive is running by odrivetool prefectly

I don’t think you can just change the code, I think it’s supposed to be an externally passed argument.