Python XArmAPI set_angle_function()

While using multiple lines of set_servo_angle() function, in between each move robot returns to Zero position. Is this expected or a configuration item?
I would like robot to strictly follow the angle moves I specify in parameters for use call to set_servo_angle() function.

Also, anyone have experience with set_servo_angle_j() function? When I produced a program from RoboDK Simulation software, it uses set_servo_angle_j() functions for moves, which did not seem to work as expected.

Hello,
Can you send your program to our email(support@ufactory.cc)?
Thanks.

Hi Jane
Is anyone able to explain why my program has xArm6 returning to Zero Position after each move that I programmed?

xArm Test Program

Draw a triangle from Zero Position

import sys, os

append path to access XArmAPI

sys.path.append(os.path.join(os.path.dirname(file), ‘…/…/…’))

Import the xArm library

from xarm.wrapper import XArmAPI
def print_message(arg):
print(arg)
def UpdateStatus(arg):
pass
ROBOTCOM_UNKNOWN = -1000
ROBOTCOM_CONNECTION_PROBLEMS = -3
ROBOTCOM_DISCONNECTED = -2
ROBOTCOM_NOT_CONNECTED = -1
ROBOTCOM_READY = 0
ROBOTCOM_WORKING = 1
ROBOTCOM_WAITING = 2
nDOFs_MIN = 6
class ComRobot:
“”“Robot class for programming xArm robots”“”
LAST_MSG = None # Keep a copy of the last message received
CONNECTED = False # Connection status is known at all times
UARMAPI = XArmAPI(“192.168.1.197”)
BUFFER_SIZE = None
TIMEOUT = None
#Speed and accelerations
LINEARSPEED = 50
LINEARACELL = 15
JOINTSPEED = 50
JOINTACELL = 40
LAST_TARGET_JOINTS = []

This is executed when the object is created

def init(self):
self.BUFFER_SIZE = 512 # bytes
self.TIMEOUT = 5 * 60 # seconds: enough time for movement to complete

destructor

def del(self):
self.disconnect()

Disconnect from robot

def disconnect(self):
self.CONNECTED = False
if self.UARMAPI:
try:
self.UARMAPI.disconnect()
except OSError:
return False
return True

Connect to robot

def connect(self, ip, port=-1):
global ROBOT_MOVING
self.disconnect()

print_message(‘Connecting to robot %s’ % (ip))

Create new socket connection

UpdateStatus(ROBOTCOM_WORKING)
try:
self.UARMAPI = XArmAPI(ip, do_not_open=False)
self.UARMAPI.motion_enable(enable=True)
self.UARMAPI.set_mode(0)
self.UARMAPI.set_state(state=0)
self.UARMAPI.reset(wait=True)

except Exception as e:
print_message(str(e))
return False
version = self.UARMAPI.version
print_message(“API Version:” + str(version))
self.CONNECTED = True
ROBOT_MOVING = False
sys.stdout.flush()
return True
def setTool(self,tool_pose):
self.UARMAPI.set_tcp_offset(tool_pose)
return True
def MoveJ(self,joints):
try:
self.UARMAPI.motion_enable(enable=True) # mdg,True)
self.UARMAPI.set_mode(mode=0) #
self.UARMAPI.set_state(state=0)
self.UARMAPI.reset(wait=True)

self.UARMAPI.set_servo_angle(angle=joints,speed=self.JOINTSPEED,is_rad
ian=False, wait=True, relative=False)
self.LAST_TARGET_JOINTS = joints
print(self.UARMAPI.get_servo_angle())

except Exception as e:
print_message(str(e))
return False
return True
if name == “main”:

Connect to xArm robot

global robot
ROBOT_IP = “192.168.1.197”
robot = ComRobot()
while not robot.connect(ROBOT_IP):
print_message(“Retrying connection…”)
import time
time.sleep(0.5)

print_message(“Connected to robot: " + ROBOT_IP)
print_message(”>>>>>Ready to run program!<<<<<")
robot.setTool([-70.000, 0.000, 470.000, -0.000, 0.000, -0.000])
print_message(“setTool is done!”)

#Program generated by RoboDK v5.0.2 for uFactory xArm6 on
12/09/2020 12:52:01
#Using nominal kinematics.
#robot ref frame set to 0.000, 0.000, 0.000, -0.000, 0.000,
-0.000

robot.MoveJ([0.000000,-25.732900,-59.100400,0.000001,51.804100,-0.0000
01])

robot.MoveJ([40.719900,-1.379620,-83.359800,-24.044300,60.775200,48.10
4500])

robot.MoveJ([-2.045810,-2.570910,-55.740300,2.607550,25.321700,-4.0727
30])

robot.MoveJ([-33.392900,-13.416300,-73.936800,20.174300,60.441200,-39.
201600])

robot.MoveJ([0.000000,-25.732900,-59.100400,0.000000,51.804100,0.00000
0])

robot.MoveJ([0.000000,0.000000,0.000000,0.000000,0.000000,0.000000])

Hello Garram,
The command (self.UARMAPI.reset(wait=True) ) will make xarm return to the zero point.
You can contact RoboDK to modify this interface.
You can refer to the documentation about the interface: xArm-Python-SDK/xarm_api.md at master · xArm-Developer/xArm-Python-SDK · GitHub

Thanks.