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
from roboclaw import Roboclaw
File “/home/pi/.virtualenvs/cv/local/lib/python2.7/site-packages/roboclaw/init.py”, line 1, in
from .roboclaw import RoboClaw
File “/home/pi/.virtualenvs/cv/local/lib/python2.7/site-packages/roboclaw/roboclaw.py”, line 9, in
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!