jkur / python-urx

Python library to control a robot from 'Universal Robots' http://www.universal-robots.com/
GNU Lesser General Public License v3.0
22 stars 32 forks source link

Im getting error when wait function is on #1

Open Ukkeli12 opened 2 years ago

Ukkeli12 commented 2 years ago

Code: from urx import Robot from time import sleep from math import radians import sys

rob = Robot("192.168.100.10")

base,shouder,elbow,wrist1,wrist2,wrist3,ja,jv = 68.95,-61.30,128.65,10.62,87.54,85.48,1.2,0.25 #Jointspace asetukset x,y,z,rx,ry,rz,la,lv = 3.74,-323.51,-497.28,1.782,-2.389,0.227,1.4,1.05 #Toolspace asetukset

def DegToRad(degree): #Muunnetaan asteet radiaaneiksi jotta helpotetaan koodausta return radians(degree)

def MilToM(mil): #Muunnetaan millimetri metreiksi return mil / 1000

print("Tässä on asteet radiaaneiksi",DegToRad(90))

print("Tässä on millit metreiksi",MilToM(100))

rob.set_tcp((0, 0, 0.1, 0, 0, 0)) rob.set_payload(2, (0, 0, 0.1)) sleep(0.2) #leave some time to robot to process the setup commands rob.movej((DegToRad(base), DegToRad(shouder), DegToRad(elbow), DegToRad(wrist1), DegToRad(wrist2), DegToRad(wrist3)), ja, jv,wait=True) #Jointspace rob.movel((MilToM(x), MilToM(y), MilToM(z), rx, ry, rz), la, lv,wait=True) #Toolspace print(rob.getj()) rob.close()

rob.exit

tried 11 times to find a packet in data, advertised packet size: -2, type: 3 Data length: 68 tried 11 times to find a packet in data, advertised packet size: -2, type: 3 Data length: 1092 tried 11 times to find a packet in data, advertised packet size: -2, type: 3 Data length: 1420 Traceback (most recent call last): File "c:\Users\OMISTAJA\OneDrive - Oulun ammattikorkeakoulu\Harjoittelu 2022 oamk\Koodit python\Demo_robotti.py", line 25, in rob.movej((DegToRad(base), DegToRad(shouder), DegToRad(elbow), DegToRad(wrist1), DegToRad(wrist2), DegToRad(wrist3)), ja, jv,wait=True) #Jointspace File "C:\Users\OMISTAJA\AppData\Roaming\Python\Python39\site-packages\urx\urrobot.py", line 277, in movej self._wait_for_move(joints[:6], threshold=threshold, joints=True) File "C:\Users\OMISTAJA\AppData\Roaming\Python\Python39\site-packages\urx\urrobot.py", line 217, in _wait_for_move raise RobotException("Robot stopped") urx.urrobot.RobotException: Robot stopped

When movel and movej wait=False it works normaly.

Ukkeli12 commented 2 years ago

My python is Python 3.9.7 in Windows 10 64 bit.

Ukkeli12 commented 2 years ago

Also robot is ur5.

jkur commented 2 years ago

Hi, first of all this is no upstream repository. Maybe another fork or the original repo contains newer and working code. I still use this code but also do run into failures from time to time. I usually restart my application, because it's not critical.

Besides that, it's very important to know which software version you are running. The interface has changed over time and this code does not cover all versions.

The interface is documented here: https://www.universal-robots.com/articles/ur/interface-communication/remote-control-via-tcpip/

See the attached excel-sheets and PDFs.

The actual code is quite easy to read, maybe you can trace your problem yourself. It's somewhere in ursecmon.py i guess. The way how this piece of software solves it, may not be the best way to do it.

Depending on what you're trying to solve it might be easier to just send some URScript code to the primary or secondary interface yourself.

It's as easy as opening a port (30001) and sending your code in plain text.