Basic python library for uArm swift Pro

Hi uArm swift Pro owners :slight_smile:

I hope you are as happy with your uArm as I am. I have started work on a simple python library to control the uArm Pro.

The initial library for the uArm swift Pro is still very basic. Tested under Windows and Linux (on Raspberry). Support for controlling multiple robots at a time synchronized or one-by-one.

p.s I am not just an amateur developer, so please do not bitch too much about my code :slight_smile: But improvement suggestions are welcome.

4 Likes

Hi there,

I’m also seeking to get the uArm Pro up and running on a Raspberry Pi 3 with python. Being a bit clueless myself - is there an obvious reason why you are not using the pyuarm library from here:

Question asked with the caveat that I’ve not yet managed to get the arm up and running on the pi at all yet! Just did some basic googling and ran into your post and thought I should sanity check what I was doing.

Cheers,

Ah nevermind,

I found this thread: uArm swift Pro - Python lib and Serial commands documentation in which you discovered that pyuarm doesn’t work

In short, for any other readers out there, it seems pyuarm is not yet functional for the Swift Pro. I will have a look at your code anykey. Thanks!

Ok,

I’ve got your basic_example code to work with python 3. I basically just cloned the repository to my pi and ran basic_example under python 3 IDLE with the uArm connected over USB. Only one small snag, the code is for python 2 (though with python 3 compliant print statements!). If anyone else gets stuck, python 3 changed the way bytes were handled so now you need to change all the:

line = str(self.ser.readline())

code to read something like:

line = str(self.ser.readline().strip().decode('ascii'))

and the

bytes(cmnd + "\n")

line to read:

bytes(cmnd + "\n", "ascii")

Then it should work. I’m not sure if this change is backward compatible with python2 or not so I haven’t made any attempt to push it to the online repository. If I have my git terminology right there.

Cheers anykey!

1 Like

I managed to hack the pyuarm package into working with my Swift w/ a few tweaks to the protocol,version and list_uarm.py modules. It appears that, at least for the Swift firmware, the main difference between uArm Metal and uArm Swift is that an additional ‘2’ has been added to most of the commands:
P200 is now P2200, M201 is now M2201, P231 is now P2231, etc. The commands are not all copied 1:1, so a conditional include seemed to be the best way to go than playing around with string.format().
I’m going to test it for a few more days and once I’m convinced it works, I’ll push it up to Github.

I was to get this working well enough that the ROS node talks to my uARM Swift now and I can send position commands through the relevant ROS topics. Rviz works as well…

I’ve forked the UFactory Repo here:

…and rolled my changes into it.
I would be interested in hearing about people’s experiences with this version of the pyuarm code.

Hi there,
I am a new user of uArm swift Pro. I am wondering about couple of questions.
1 How to run the python code to the uArm swift pro from my PC or labtop
regards
NQ

Hi, please check it here: GitHub - uArm-Developer/uArm-Python-SDK: New python library for Swift, Swift Pro

Hi,thank you very much for the link, I have checked the code. and it works . I m wondering is there any way to run Gcode using python. you comments are much appreciated
thanks
NQ