AttributeError: 'Roboclaw' object has no attribute '_port'
Posted: Mon Jan 27, 2020 6:52 am
Having trouble running anything as a result of this error, i have provided the code i am running, it is based off the complete example from
https://resources.basicmicro.com/using- ... 3MKynbgdec
when i run the code i get the following response
any clues?
https://resources.basicmicro.com/using- ... 3MKynbgdec
Code: Select all
# Complete example of using the RoboClaw library
#import the relevant code from the RoboClaw library
from roboclaw_3 import Roboclaw
# address of the RoboClaw as set in Motion Studio
address = 128
# Creating the RoboClaw object, serial port and baudrate passed
roboclaw = Roboclaw("COM4",115200)
#roboclaw = RoboClaw(“/dev/ttyS0”, 38400)
# Starting communication with the RoboClaw hardware
roboclaw.Open()
# Start motor 1 in the forward direction at half speed
roboclaw.ForwardM1(address, 120)
Code: Select all
Traceback (most recent call last):
File "C:\Users\trist_000\Documents\-Warwick\Year 4\ES410 - Warwick Mobile Robotics\Motor control\roboclaw_python\roboclaw_python\TEST1_BasicExample1.py", line 21, in <module>
roboclaw.ForwardM1(address, 120)
File "C:\Users\trist_000\Documents\-Warwick\Year 4\ES410 - Warwick Mobile Robotics\Motor control\roboclaw_python\roboclaw_python\roboclaw_3.py", line 654, in ForwardM1
return self._write1(address,self.Cmd.M1FORWARD,val)
File "C:\Users\trist_000\Documents\-Warwick\Year 4\ES410 - Warwick Mobile Robotics\Motor control\roboclaw_python\roboclaw_python\roboclaw_3.py", line 317, in _write1
self._sendcommand(address,cmd)
File "C:\Users\trist_000\Documents\-Warwick\Year 4\ES410 - Warwick Mobile Robotics\Motor control\roboclaw_python\roboclaw_python\roboclaw_3.py", line 129, in _sendcommand
self._port.write(address.to_bytes(1, 'big'))
AttributeError: 'Roboclaw' object has no attribute '_port'