Roboclaw Python Class python3

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

Roboclaw Python Class python3

Postby robof » Tue Aug 22, 2017 5:31 pm

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: 1130
Joined: Thu Feb 26, 2015 9:45 pm

Re: Roboclaw Python Class python3

Postby Basicmicro Support » Wed Aug 23, 2017 9:52 am

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

Postby robof » Wed Aug 23, 2017 12:35 pm

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

Gordsm8
Posts: 1
Joined: Fri Oct 13, 2017 1:16 am

Re: Roboclaw Python Class python3

Postby Gordsm8 » Tue Oct 17, 2017 12:23 pm

I have just ordered a RoboClaw 2x15A and wondered if the Python Library was v2 or v3!

Did your changes you mentioned above work OK? Did you need to make any other changes to make it work with Python3?

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

Re: Roboclaw Python Class python3

Postby Basicmicro Support » Mon Oct 23, 2017 10:12 am

The python library was written/tested with Python 2.7


Return to “General Discussion”

Who is online

Users browsing this forum: Bing [Bot] and 5 guests