Roboclaw Python Class python3

General discussion of using Roboclaw motor controllers
Post Reply
robof
Posts: 36
Joined: Tue Jun 27, 2017 11:21 pm
Roboclaw Python Class python3

Post 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.
Last edited by robof on Mon Aug 28, 2017 10:56 am, edited 1 time in total.
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw Python Class python3

Post 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.
robof
Posts: 36
Joined: Tue Jun 27, 2017 11:21 pm
Re: Roboclaw Python Class python3

Post 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
User avatar
Basicmicro Support
Posts: 1594
Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw Python Class python3

Post by Basicmicro Support »

The python library was written/tested with Python 2.7

Post Reply