Python library issue

General discussion of using Roboclaw motor controllers
Madmatt
Posts: 5
Joined: Sat Jan 26, 2019 9:57 am

Python library issue

Postby Madmatt » Thu Feb 07, 2019 1:34 pm

Hi all I have some issues with python library, hope some1 can help me out:
I'm trying to use the python library on a software called touchdesigner(windows 10) to control an engine from serial port.
it supports python and external modules.

I'm trying to do some basic functions but i cant communicate with the board.
At the moment i m still connected via usb serial.

this is the code I m trying to use:

from roboclaw import Roboclaw

#Windows comport name
rc = Roboclaw("COM7",38400)
#Linux comport name
#rc = Roboclaw("/dev/ttyACM0",115200)

rc.Open()

address = 0x80

rc.ForwardM1(address,32)

i got some errors as output:

python >>>
Traceback (most recent call last):
File "</project1/text1:op('/project1/text1').run()>", line 1
td.Error: File "/project1/text1", line 12
File "C:\Program Files\Derivative\TouchDesigner099\bin\lib\roboclaw.py", line 647, in ForwardM1
return self._write1(address,self.Cmd.M1FORWARD,val)
File "C:\Program Files\Derivative\TouchDesigner099\bin\lib\roboclaw.py", line 311, in _write1
self._sendcommand(address,cmd)
File "C:\Program Files\Derivative\TouchDesigner099\bin\lib\roboclaw.py", line 126, in _sendcommand
self._port.write(chr(address))
File "C:\Program Files\Derivative\TouchDesigner099\bin\lib\serial\serialwin32.py", line 308, in write
data = to_bytes(data)
File "C:\Program Files\Derivative\TouchDesigner099\bin\lib\serial\serialutil.py", line 63, in to_bytes
raise TypeError('unicode strings are not supported, please encode to bytes: {!r}'.format(seq))
TypeError: unicode strings are not supported, please encode to bytes: '\x80'
Results of run operation resulted in exception. <type:textDAT path:/project1/text1> <class 'td.textDAT'>
python >>>


Can someone help me to figure out what s happening?

Madmatt
Posts: 5
Joined: Sat Jan 26, 2019 9:57 am

Re: Python library issue

Postby Madmatt » Thu Feb 07, 2019 1:44 pm

just to add the issue here seems to be related to unicode string conversion of the address (0x80 - which is expressed in hex seems)

Madmatt
Posts: 5
Joined: Sat Jan 26, 2019 9:57 am

Re: Python library issue

Postby Madmatt » Thu Feb 07, 2019 1:54 pm

sorry again forgot to say i m using a roboclaw 2*15 a motor controller

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

Re: Python library issue

Postby Basicmicro Support » Fri Feb 08, 2019 10:23 am

What version of Python are you using? My guess is Python 3? Python 3 doenst allow certain conversions that Ptyhon 2.7 supported. Contact support@basicmicro.com for a pre-release of a Python 3 version of the library assuming you are using Python 3.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests