Coder Social home page Coder Social logo

Comments (4)

MinnaZhong avatar MinnaZhong commented on July 17, 2024

Hi, do you use xArm6 or Lite6? Is there any error when running the 2006 example?
Would you please provide a simple script for us to reproduce the problem? What is the current firmware and ufactoryStudio version?

Best,

from xarm-python-sdk.

emanuelgollob avatar emanuelgollob commented on July 17, 2024

Hi Minna,

Thanks for your response! I use the Lite6. I didn´t have any errors when running the 2006 example uncustomized (with constant speed for all commands). The firmware version is 2.2.2. The studio version is also 2.2.2. Please find my code below.

In order to reproduce the error one needs a UDP sender script that sends every 1 second the new axis commands and new targetspeed. As my UDP sender sends the message every 1 second I skipped the time.sleep(1) after arm.set_servo_angle(..). I coded the UDP sender in another program, so I unfortunately can´t share it here right away.

#!/usr/bin/env python3

Software License Agreement (BSD License)

Copyright (c) 2019, UFACTORY, Inc.

All rights reserved.

Author: Vinman [email protected] [email protected]

"""
Description: joint online trajectory planning mode
"""

import os
import sys
import time
import math
import socket

sys.path.append(os.path.join(os.path.dirname(file), '../../..'))

from xarm.wrapper import XArmAPI

#######################################################

UDP_IP = "127.0.0.1"
UDP_PORT_SEND = 1005 #broadcast current axis angles and torque per axis
UDP_PORT_RECV = 1006 #receive axis commands and targetspeed from UDP client

print("UDP target IP: %s" % UDP_IP)
print("UDP target port: %s" % UDP_PORT_SEND)

sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP

sock2 = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM) # UDP
sock2.bind((UDP_IP, UDP_PORT_RECV))

#######################################################

arm = XArmAPI('192.168.1.172')
arm.motion_enable(enable=True)
arm.set_mode(0)
arm.set_state(state=0)

arm.set_reduced_max_joint_speed(45,is_radian=False)
arm.set_joint_maxacc(50,is_radian=False)
arm.save_conf()
#arm.reset(wait=True)
arm.set_servo_angle(angle=[35, 0, 180, 0, 0, -90, 0], wait=True)

set mode: joint online trajectory planning mode

the running command will be interrupted when the next command is received

arm.set_mode(6)
arm.set_state(0)
time.sleep(1)

#speed = 45

#for i in range(10):
while True:
# run on mode(6)
# the running command will be interrupted, and run the new command
arm.set_servo_angle(angle=[45, 0, 180, 0, 0, -90, 0], speed=speed, wait=False)
time.sleep(1)
print("while loop 1")

if arm.warn_code==0:

    temperatures=arm.temperatures
    highesttemp=max(temperatures)
    print("highesttemp:")
    print(highesttemp)

    while arm.connected and arm.state != 4 and highesttemp<60:
        try:
            #checking the temperatures every frame
            #temperatures=arm.temperatures
            #highesttemp=max(temperatures)
            #print(highesttemp)
        
            #broadcast current axis angles and torque per axis
            currentangles = arm.angles
            currenttorque = arm.joints_torque
            MESSAGEstr = ";A1:" + str(currentangles[0]) + ";A2:" + str(currentangles[1]) + ";A3:" + str(currentangles[2])+ ";A4:" + str(currentangles[3])+ ";A5:" + str(currentangles[4])+ ";A6:" + str(currentangles[5])+ ";T1:" + str(currenttorque[0])+ ";T2:" + str(currenttorque[1])+ ";T3:" + str(currenttorque[2])+ ";T4:" + str(currenttorque[3])+ ";T5:" + str(currenttorque[4])+ ";T6:" + str(currenttorque[5])
            MESSAGE = MESSAGEstr.encode('utf-8')
            sock.sendto(MESSAGE, (UDP_IP, UDP_PORT_SEND))

            #receive axis commands and targetspeed from UDP client
            data, addr = sock2.recvfrom(1024) # buffer size is 1024 bytes
            datadecode = data.decode("utf-8")
            split = datadecode.split(";")
            angles = [float(x) for x in split[0:6]]
            print(angles)

            targetspeed = int(split[6])
            if targetspeed > 45:
                targetspeed = 45
            print(targetspeed) #new

            arm.set_servo_angle(angle=angles, speed=targetspeed, wait=False) 
        
        except:
            print("No UDP Joint Command Received")
    
    time.sleep(0.01)

arm.clean_error()

arm.motion_enable(enable=True)
arm.set_mode(0)
arm.set_state(state=0)
time.sleep(1)
arm.set_mode(6)
arm.set_state(0)
time.sleep(1)
print("Recovered")

set_mode: position mode

arm.set_mode(0)
arm.set_state(0)
print("Disconnect")
#arm.reset(wait=True)
arm.disconnect()

from xarm-python-sdk.

MinnaZhong avatar MinnaZhong commented on July 17, 2024

Hi,

When set_servo_angle returns 1, please open our UFactoryStudio software to see if there is any error, what is the error code? You can call get_err_warn_code to get the error code as well.

Best regards,

from xarm-python-sdk.

emanuelgollob avatar emanuelgollob commented on July 17, 2024

Hi, I can´t re-test this setup of switching velocity right now as I meanwhile employed another one, but might get back in a few weeks with an update on its error codes

from xarm-python-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.