RoboClaw 2x15A, Python3, Windows: Unable to read version
RoboClaw 2x15A, Python3, Windows: Unable to read version
Hello,
I have written a program in Python3 in which I want to include a motor control with a RoboClaw2x15A.
Currently I am working on Windows10, but maybe I will swap to a Raspberry Pi in the future.
The Python Lib for Raspberry Pi is written for Python2, so I got the same _port-error as in the thread.
http://forums.basicmicro.com/viewtopic.php?f=2&t=542
Thus I did the changes mentioned from "robof" in forum and had no error anymore.
I checked the connection with
and it is working.
But trying to get data from the roboclaw does not really work.
Executing
does give me only the "GETVERSION Failed" output.
I also tried to read the encoder-value and measured the response time for the "rc.ReadEncM1(address)" -function and that is always a little bit more than 3seconds.
Do you have a python3 library available for further testing? Or may you help me with my communiction problem?
Thanks
simons
EDIT:
I changed the adress value from "0x80" to "80" before I tested all of these, because otherwise I got the error
Tested everything in python2 and that is working.
So the problem must be at the conversion of the address, so it can be used in python3
I have written a program in Python3 in which I want to include a motor control with a RoboClaw2x15A.
Currently I am working on Windows10, but maybe I will swap to a Raspberry Pi in the future.
The Python Lib for Raspberry Pi is written for Python2, so I got the same _port-error as in the thread.
http://forums.basicmicro.com/viewtopic.php?f=2&t=542
Thus I did the changes mentioned from "robof" in forum and had no error anymore.
I checked the connection with
Code: Select all
a = rc.Open
if a ==1:
print("okay")
else:
print("not okay")
But trying to get data from the roboclaw does not really work.
Executing
Code: Select all
version = rc.ReadVersion(address)
if version[0]==False:
print("GETVERSION Failed")
else:
print( repr(version[1]))
I also tried to read the encoder-value and measured the response time for the "rc.ReadEncM1(address)" -function and that is always a little bit more than 3seconds.
Do you have a python3 library available for further testing? Or may you help me with my communiction problem?
Thanks
simons
EDIT:
I changed the adress value from "0x80" to "80" before I tested all of these, because otherwise I got the error
Code: Select all
File "C:\Users\Simon\Desktop\testbed\GUI\roboclaw.py", line 717, in ReadVersion
str+=data[0]
TypeError: must be str, not int
So the problem must be at the conversion of the address, so it can be used in python3
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: RoboClaw 2x15A, Python3, Windows: Unable to read version
80 is not the same as 0x80. 0x80 = 128 is a valid address, 80 is not a valid address. Changing the address in the python code to 80 will definitely prevent thbe Roboclaw from communicating.
The str+=data[0] has nothing to do with the address value itself. It's just the fact that if you change the address to an invalid address you will never read any data back so data is empty and never reaches the line with the error.
Python3 is doing something different obviously. the _port.read command returns a byte array IIRC and str is initialised as a str( = ""). Apparently Python3 wont convert from one to the other correctly without doing something else where Python2 does it just fine.
The str+=data[0] has nothing to do with the address value itself. It's just the fact that if you change the address to an invalid address you will never read any data back so data is empty and never reaches the line with the error.
Python3 is doing something different obviously. the _port.read command returns a byte array IIRC and str is initialised as a str( = ""). Apparently Python3 wont convert from one to the other correctly without doing something else where Python2 does it just fine.
Re: RoboClaw 2x15A, Python3, Windows: Unable to read version
Thanks for the fast response.
I completely understand the fact, that I need to work with 0x80 as the address.
Can you tell me the changes I will need to do in the roboclaw.py to get it working with python3? I think that it should be possible with just a few changes, right?
I completely understand the fact, that I need to work with 0x80 as the address.
Can you tell me the changes I will need to do in the roboclaw.py to get it working with python3? I think that it should be possible with just a few changes, right?
- Basicmicro Support
- Posts: 1594
- Joined: Thu Feb 26, 2015 9:45 pm
Re: RoboClaw 2x15A, Python3, Windows: Unable to read version
I have never tried converting to Python3 but a customer did send us a copy of a conversion they did. We havent had a chance to confirm it is fully functionaly yet but you can email support@basicmicro.com to get a copy of it.