uArm swift Pro - Python lib and Serial commands documentation

Hi, I received my uArm swift pro :slight_smile: and want to start working with it using a Raspberry pi.

Is it correct the current pyuarm (python lib) is not working for the uArm swift pro?

Is there any documentation serial commands/gcode for the Swift pro? I can only find this documentation for the uarm metal.

Regards,
Richard

1 Like

Hi Richard, libraries for swift pro are not published yet.
Except “ArduinoForSwift”(arduino library for swift, not pro), the current libraries are for uArm Metal. We’re working on libraries for pro but we need some time. :slight_smile:

The communication protocol of swift pro is included in the document “Getting Started with uArm Swift Pro”, downloadable here: http://download.ufactory.cc/docs/en/uArm-Swift-Pro-Quick-Start-Guide-1.0.pdf

2 Likes

Thanks. I started playing with this.

When I am sending movement commands and the uArm swift pro is moving, I am polling the “is moving” with M2200. I find that I get returns of 0, while the arm is still moving. If this a know issue?

1 Like

So I figured it out. When sending goto commands, you have to wait anyway to get any response from the uArm untill the movement is done. So I do not need to use the M2200 command, just with for an OK answer on the movement command.

2 Likes

So does that mean that we can use the standard arduino library (say for java) and send the gcodes?

Arduino libraries for Swift and Swift Pro are already on Github:

@cleo – I see repositories for the Marlin Gcode interpreter for both Swift and Swift Pro. I do not see any supporting Python code for Swift Pro. Help?

python library is still under development. will publish asap!

Thank you for working on the python library for the Swift Pro. I think this is going to be one of the most valuable interfaces for me.

@cleo That document is sadly very lacking! Someone attempting to write a new interface library for the uArm in C/C++/Java/Swift/etc. would find it impossible.

What it lacks (in addition to being hard to find in the first place):

  • A recommended way to identify which serial port the uArm is connected to
  • Identification of joint IDs (I had to find this in the uArm metal docs, and must assume it’s the same)
  • Which instructions tell the suction cup to pick up/release? I assume it’s the pump, but it’s non-obvious how this works
  • Will a move in cartesian co-ordinates be in a straight line by default? If not, is there a trivial way specify that it should be in a straight line?
  • How do I rotate the wrist joint?
  • Can I “detach” and/or read the angle wrist joint?
  • What’s the min/max for any of the motor positions?
  • How to control the feed system for 3D printing
  • Can the laser power be set, or can it be pulse width modulated? If so, how do we do this given the asynchronous nature of the protocol, and what’s the maximum possible frequency for modulating
  • How to talk to any of the grove or IIC modules. Is grove/IIC via EEPROM access? If so, is it SYS or USR, and how is the corresponding memory space mapped to various modules?
  • What else is EEPROM used/usable for?
  • What is the M2240 command (Set the digital IO output) used/usable for?

I believe that a lot of these questions could be answered by reading the python lib code, but at a trivial glance it looks like the answers are spread far and wide across multiple files. Python is also a very verbose language, which makes it a very slow and tedious process to try and reverse-engineer the code in this fashion.

1 Like

A recommended way to identify which serial port the uArm is connected to

I told my colleagues don’t forget to change the default String Descriptors of the USB device,
but when I start write pyuf, I found that all info report by USB is still the original from Arduino,
and there are no serial number to distinguish different arms.

It’s not possible to upgrade the firmware of the USB to serial chip without disassembly the arm.
So, we can only identify the serial port by Arduino’s vid, pid, manufacturer and product strings.
(A few days ago I added the identification code to the pyuf.)

I will keep tracking this issue and hope fix it in follow shipment.

Identification of joint IDs (I had to find this in the uArm metal docs, and must assume it’s the same)

Yes, they are same.

Identified as Left and Right servo in:
http://download.ufactory.cc/docs/en/uArm-Metal-Developer-Guide.pdf

Identified as servo 0, 1, 2, 3 in:
http://download.ufactory.cc/docs/en/uarm_gcode_communication_protocol_v1.0_en.pdf

Defined in pyuf/uf/wrapper/swift_api.py:

SERVO_BOTTOM = 0
SERVO_LEFT = 1
SERVO_RIGHT = 2
SERVO_HAND = 3 # or wrist

Which instructions tell the suction cup to pick up/release? I assume it’s the pump, but it’s non-obvious how this works

Follow steps (step 2 is optional):

1. pick up: M2231 V1
2. check if anything grabbed: P2231
   return: V0: stop, V1: working, V2: grabbed
   (known bug: sometimes even nothing grabbed, it still return V2)
3. release: M2231 V0

Will a move in cartesian co-ordinates be in a straight line by default? If not, is there a trivial way specify that it should be in a straight line?

According to G-code standard, it must be straight line.

How do I rotate the wrist joint?

G2202 N3 V0~180

Can I “detach” and/or read the angle wrist joint?

Normally, all joint could be attach by command:

M17        # for all, or
M2201 N0~3 # for specified joint

detach by:

M2019      # for all, or
M2202 N0~3 # for specified joint

read attach status:

M2203 N0~3 # return V0: not attach, V1: attached

But wrist joint not support attach by now.

Read the angle wrist:

P2206 N3

What’s the min/max for any of the motor positions?

BOTTOM: 0~180
LEFT:   0~135
RIGHT:  0~119.9
HAND:   0~180

How to control the feed system for 3D printing

It’s same as other 3D printings, there is an E value in G0/1 command.
Reset the E value to zero by command:

G92 E0

Can the laser power be set, or can it be pulse width modulated? If so, how do we do this given the asynchronous nature of the protocol, and what’s the maximum possible frequency for modulating

The laser power is close by G0 command, open by G1 command
(I think it’s should change to a value argument instead),
pulse width modulated controlled by P value in G1 command.
frequency is fixed to 490 Hz, may changed in the future.

Unfortunately, the laser module already shipped don’t support modulate. (or don’t support well)

How to talk to any of the grove or IIC modules. Is grove/IIC via EEPROM access? If so, is it SYS or USR, and how is the corresponding memory space mapped to various modules?

Grove modules are controlled by there own command, which could be found in the last document:
http://download.ufactory.cc/docs/en/uArm-Swift-Pro-Quick-Start-Guide-1.0.pdf

What else is EEPROM used/usable for?

I thought SYS and USR is different partition on the EEPROM chip,
but the trues is that they are different chips,
and the SYS is not even exist for Swift Pro,
so, only the USR could be used.
(there is a INTERNAL EEPROM instead of SYS for Swift Pro, but not opened for users)

The USR default used by offline teaching, there is no header or anything special,
all space are filled by recording points:

EEPROM default data format, each item is one offline record data:
  [p0, p1, p2, p3, p4, p5 ... p_end]

each record data is 10 bytes, and each item inside is 2 bytes:
  [a0, a1, a2, a3, accessories_state]

a0~3: unsigned fixed point of servos' angle (multiply by 100)

accessories_state:
  bit0: pump on/off
  bit4: griper on/off

p_end indicate the end of records, filled by 0xffff

You can use USR EEPROM for any other propose.

What is the M2240 command (Set the digital IO output) used/usable for?

Control all GPIO output if you want, for 30P Base Extension, Accessory Port and Front Extension Port.
The firmware not support digital IO as input currently.


I hope the document would be migrate to LaTeX or similar, that's much easier for collaborative work and version control.

Hi AnyKey,
I wondered how are you using the serial protocol and ‘playing’ with the swift pro?
Are you using pyuarm?
Thanks
Dror

Hi, I am using my own library I wrote in python, it is basic, but (hopefully) easy to use. I am working on a update that will allow also easy integration with camera vision.
You can find the library here: GitHub - AnykeyNL/uArmProPython: Python Library for the uArm swift Pro robot arm

Hey,
So I have recently started working with a uArm Swift Pro and I am trying to get it to move over a stack of tiles and descend in Z until the limit switch is triggered. Once triggered the Z motion stops. Here I want to activate the pump and pickup the tile and move it. I am able to control the position separately and I am able to check the status of the limit switch separately but there doesn’t appear to be a function I can call which allows me to move in Z until limit switch is triggered. I am thinking there must be a better way of doing this than repeatedly moving a small amount and checking to see if the limit switch is triggered? Is this possible in the service / topic architecture and does this mean I will have to adopt it or am I able to do this available python scripts or simple G commands?

Thanks,

Peter