Teach&Learn Mode accessible via Python?

I successfully used the Python SDK to communicate to my uArm Swift Pro, and everything works fine. However, I want to also access the Teach&Learn Mode and I cannot see how to make that work. If I didn’t miss anything, I believe the API does not allow to directly issue a command “learn” or “repeat learned movement”. I felt confident in trying to mimic the behavior in my python code and tried something along this idea:

# learn
pos_list = []
swift.set_servo_detach()
while end_trigger == False:
    pos_list.append(swift.get_position())

# execute learned movement
swift.set_servo_attach()
for position in pos_list:
    swift.set_position(position)

It looks simple enough, but actually it doesn’t work: swift.get_position() reports the last position the uArm was when swift.set_servo_detach() was called. Is there a way to report the positions while the servos are detached?

I would appreciate any help.

My system information:
Operation System: Linux
uArm Controlling Method: uArm Python SDK
Hardware Version: 3.3.1
Firmware Version: 3.2.0
API Version: 3.2.0

Hi,you can replace get_position with get_servo_angle. We can use the interface get_servo_angle to get the position of the uarm.

Hi jane,
this works like a charm for learning/recording into memory. Thanks a lot for your fast reply :+1: :grin:

However, I’m now struggling implementing the movement. I’m not yet done with bugfixing, but I think I’m not sure what the response of get_servo_angle means, and this makes bugfixing itself difficult.

Is it the rotation, stretch and height? Such that rotation = SERVO_BOTTOM, stretch = SERVO_LEFT and height = SERVO_RIGHT? And would the gripper = SERVO_HAND?
If this is true, why are there two functions doing the same thing: get_polar and get_servo_angle?

So if I want to reproduce the movement I recorded with get_servo_angle, should I use set_polar instead of set_position?
Or do I have to specify the steps like this:
bottom, left, right = get_servo_angle()
set_servo_angle(‘SERVO_BOTTOM’, bottom)
set_servo_angle(‘SERVO_LEFT’, left)
set_servo_angle(‘SERVO_RIGHT’, right)
Or is this even equivalent to set_polar?

Hello,
you can refer to the program below:

from uarm.swift.teach import Teach

swift.set_speed_factor(100000)
teach = Teach(‘temp.gcode’, swift)
teach.start_standby_mode()
teach.start_record()

time.sleep(10)

teach.stop_record()
teach.stop_standby_mode()

teach.start_play()

while swift.connected:
time.sleep(1)