Page 1 of 1

Roboclaw Python Class python3

Posted: Tue Aug 22, 2017 5:31 pm
by robof
Is there any chance someone has a python 3 version of the Roboclaw class?

I've got a larger python 3.x project I'm trying to incorporate Roboclaw into, but it appears to be written for python 2.x so I'm getting some errors with some of the lower level / more internal serial/checksum portions of the code. I tried using the python 2to3 converter with no luck since I think the serial API may be part of the problem. I'm not comfortable enough with python at the moment to convert myself so hoping someone else can help.

Re: Roboclaw Python Class python3

Posted: Wed Aug 23, 2017 9:52 am
by Basicmicro Support
We will be supporting python3 eventually. We are a littel backed up right now. If you cant wait, this page has alot of usefull information:

https://docs.python.org/3/howto/pyporting.html

We use pyserial for serial communciations. We dont do anything special with it but you do need to use the pyserial version for python 3.

Re: Roboclaw Python Class python3

Posted: Wed Aug 23, 2017 12:35 pm
by robof
There was a change in pyserial with python 3 that assumed a different data type sent to write() command.

I've not tested this extensively, but so far this change appears to be all I needed to get the Roboclaw class to work in python 3.x

Change

Code: Select all

self._port.write(chr(XXX))
To

Code: Select all

self._port.write(bytes([XXX]))
So I just changed these methods:
_sendcommand
_writebyte
SendRandomData

Re: Roboclaw Python Class python3

Posted: Mon Oct 23, 2017 10:12 am
by Basicmicro Support
The python library was written/tested with Python 2.7