uArm Serial No.: (UARM-0505170790)
Firmware Version: 3.2.0
Operation System: Linux (Raspbian for Raspberry Pi3)
uArm Controlling Method: Python (Please specify the software/library version)
We are having issues with our uArm Swift Pro not executing certain commands. Specifically, the set_position method is not responding as expected. For example in our script, we specify particular coordinates for the robot to move to. However, some of these commands are ignored and not executed for no apparent reason. Is there a known problem with the python API that we should be aware of?
Below is our script:
#!/usr/bin/env python3
import sys, os, logging
from position import Position
from config import Conf
from time import sleep
sys.path.append(os.path.join(os.path.dirname(file), ‘…/…/…’))
from uf.wrapper.swift_api import SwiftAPI
from uf.utils.log import *
#logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
conf = Conf()
class Robot(object):
“”“docstring for Robot”“”
def __init__(self,filter=None):
super(Robot, self).__init__()
logging.debug('\tsetup self.swift ...')
if filter is not None:
#self.swift = SwiftAPI(dev_port = '/dev/ttyACM0')
#self.swift = SwiftAPI(filters = {'hwid': 'USB VID:PID=2341:0042'})
#self.swift = SwiftAPI() # default by filters: {'hwid': 'USB VID:PID=2341:0042'}
self.swift = SwiftAPI()
else:
self.swift = SwiftAPI()
logging.debug('\tsleep 2 sec ...')
sleep(2)
logging.debug('\tdevice info: ')
logging.debug(self.swift.get_device_info())
# Set to the inital resting position
logging.debug('\INITAL POS Robot(%d,%d,%d) Speed %d timeout %d'%(conf.I('robot','restX'), 0, conf.I('robot','restZ'),conf.I('robot','speed'),conf.I('robot','timeout')))
if True != self.swift.set_position(conf.I('robot','restX'), 0, conf.I('robot','restZ'), speed = conf.I('robot','speed'), timeout = conf.I('robot','timeout')):
logging.debug("Set position failed!")
self.swift.flush_cmd()
sleep(1)
def move(self,start,end):
#Up
self.movUp()
z =self.swift.get_position()[2]
#Start Position
logging.debug('\tSTART POS Board(%d,%d) Robot(%d:,%d)'%(start.getXBoard(),start.getYBoard(),start.getX(),start.getY()))
if True != self.swift.set_position(start.getX(), start.getY(), z,speed = conf.I('robot','speed'), wait = True):
logging.debug("Set position failed!")
self.swift.flush_cmd()
sleep(1)
#DOWN
self.movDown()
#Grip Peice
self.swift.set_gripper(True)
sleep(1)
#UP
self.movUp()
z =self.swift.get_position()[2]
#End Posistion
logging.debug('\tEND POS Board(%d,%d) robot(%d:,%d)'%(end.getXBoard(),end.getYBoard(),end.getX(),end.getY()))
if True != self.swift.set_position(end.getX(), end.getY(),z,speed = conf.I('robot','speed'), wait = True):
logging.debug("Set position failed!")
#self.swift.get_position()
self.swift.flush_cmd()
sleep(1)
#DOWN
self.movDown()
#Release
self.swift.set_gripper(False)
self.swift.flush_cmd()
sleep(1)
#Up
self.movUp()
#RETURN TO RESTING
logging.debug("\treset")
if True != self.swift.set_position(conf.I('robot','restX'), 0, conf.I('robot','restZ'),speed = conf.I('robot','speed')):
logging.debug("Set position failed!")
self.swift.flush_cmd()
def movUp(self):
zUP = conf.I('offsets','maxHeight')
#zHalf = z/2
x =self.swift.get_position()[0]
y = self.swift.get_position()[1]
zStart = self.swift.get_position()[2]
logging.debug('\tUP z=%d'%zUP)
for z in range(int(zStart), zUP, 10):
#logging.debug("\tSet position")
if True != self.swift.set_position(x,y,z,speed = conf.I('robot','speed'), wait = True):
logging.debug("Set position failed!")
#Check if going halfway helps the robot run
# if zHalf > self.swift.get_position()[2]:
# logging.debug('\tUP.5 z=%d'%zHalf)
# if True != self.swift.set_position(x,y,zHalf,speed = conf.I('robot','speed'), wait = True):
# logging.debug("Set position failed!")
# self.swift.flush_cmd()
# logging.debug('\tUP z=%d'%z)
# Make sure we did not end on an offset
# if True != self.swift.set_position(x,y,zUP,speed = conf.I('robot','speed'), wait = True):
# logging.debug("Set position failed!")
self.swift.flush_cmd()
logging.debug('\t\tReported Position:'+str(self.swift.get_position()))
sleep(1)
def movDown(self):
z = conf.I('offsets','minHeight')
logging.debug('\tDOWN z=%d'%z)
#logging.debug('\t\tx'+str(self.swift.get_position()[0]))
#self.swift.set_position(z = 100)
x =self.swift.get_position()[0]
y = self.swift.get_position()[1]
if True != self.swift.set_position(x,y,z, speed = conf.I('robot','speed'), wait = True):
logging.debug("Set position failed!")
self.swift.flush_cmd()
logging.debug('\t\tReported Position:'+str(self.swift.get_position()))
sleep(1)