Roboclaw Python Class python3
Roboclaw Python Class python3
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.
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.
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw Python Class python3
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.
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
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
To
So I just changed these methods:
_sendcommand
_writebyte
SendRandomData
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))
Code: Select all
self._port.write(bytes([XXX]))
_sendcommand
_writebyte
SendRandomData
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: Roboclaw Python Class python3
The python library was written/tested with Python 2.7