Roboclaw Raspberry Pi 3 USB communication problem

Post your own projects using Roboclaw motor controllers
alikazemian
Posts: 2
Joined: Mon Jul 10, 2017 7:58 pm

Roboclaw Raspberry Pi 3 USB communication problem

Postby alikazemian » Fri May 18, 2018 7:12 pm

Hi. I am trying to control a 2x30A roboclaw using Rasberry Pi 3. The two are connected using a USB-microUSB cable, and I tried to run this sample code via RPI terminal ($ python simplePWM.py):

import time
from roboclaw import Roboclaw
#Linux comport name
rc = Roboclaw("/dev/ttyACM0",115200)
rc.Open()
address = 0x80
while(1):
rc.ForwardM1(address,32) #1/4 power forward
rc.BackwardM2(address,32) #1/4 power backward
time.sleep(2)

rc.BackwardM1(address,32) #1/4 power backward
rc.ForwardM2(address,32) #1/4 power forward
time.sleep(2)

rc.BackwardM1(address,0) #Stopped
rc.ForwardM2(address,0) #Stopped
time.sleep(2)

m1duty = 16
m2duty = -16
rc.ForwardBackwardM1(address,64+m1duty) #1/4 power forward
rc.ForwardBackwardM2(address,64+m2duty) #1/4 power backward
time.sleep(2)

m1duty = -16
m2duty = 16
rc.ForwardBackwardM1(address,64+m1duty) #1/4 power backward
rc.ForwardBackwardM2(address,64+m2duty) #1/4 power forward
time.sleep(2)

rc.ForwardBackwardM1(address,64) #Stopped
rc.ForwardBackwardM2(address,64) #Stopped
time.sleep(2)

but got this error:

Traceback (most recent call last):
File "simplePWM.py", line 2, in <module>
from roboclaw import Roboclaw
File "/home/pi/.virtualenvs/cv/local/lib/python2.7/site-packages/roboclaw/__init__.py", line 1, in <module>
from .roboclaw import RoboClaw
File "/home/pi/.virtualenvs/cv/local/lib/python2.7/site-packages/roboclaw/roboclaw.py", line 9, in <module>
from roboclaw.roboclaw_cmd import Cmd
ImportError: No module named roboclaw_cmd

I am using python 2.7 on Raspberry Pi and installed roboclaw library using "pip install roboclaw" command. Any help regarding this would be appreciated!

User avatar
Basicmicro Support
Posts: 1132
Joined: Thu Feb 26, 2015 9:45 pm

Re: Roboclaw Raspberry Pi 3 USB communication problem

Postby Basicmicro Support » Mon May 21, 2018 9:36 am

Make sure you have the latest copy of the python library. The current library, line 9 is not an import command so this error makes no sense unless the roboclaw.py library file is very old or something else is in its place:

File "/home/pi/.virtualenvs/cv/local/lib/python2.7/site-packages/roboclaw/roboclaw.py", line 9, in <module>
from roboclaw.roboclaw_cmd import Cmd


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 1 guest