Universal Robots Forum

Test script not working

Just wondering what is wrong with my test script.

import socket
import time

HOST = '169.254.63.28'
PORT = 30002

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((HOST, PORT))
    
i = 1
while i < 2:
    s.send(("set_digital_out(0,True)"+"\n").encode('utf8'))
    time.sleep(0.5)
    s.send(("set_digital_out(0,False)"+"\n").encode('utf8'))
    time.sleep(0.5)
    s.send(("popup(hey, title='halt', warning=True, blocking=True)"+"\n").encode('utf8'))
    s.send(("movej([-1.200691048298971, -1.6863962612547816, -1.206042766571045, \
        -1.8198558292784632, 1.5693081617355347, 1.914101481437683], \
        a=1.200691048298971, v=1.200691048298971" + "\n").encode('utf8'))
    time.sleep(5)
    s.send(("movej([-1.2551572958575647, -1.7164651356139125, -1.762454628944397, \
        -1.2335349184325715, 1.5693681240081787, 1.859632134437561], \
        a=1.200691048298971, v=1.200691048298971" + "\n").encode('utf8'))
    time.sleep(5)

The only thing working is digital_out_0 switching on and off
But no popup or movement of the arm.

1 Like

For your popup, is hey a string you defined before this call? If not you will need to put it as a string when you send it like you do ‘halt’ or it may think it is a variable being called. Also, It looks like you are missing a closing ) on your movej commands before the “\n”.

Example popup from URScript manual:
popup(“here I am”, title=“Popup #1”,blocking=True)

I already tried this before but it doesn’t work unfortunately

    s.send(("popup("hey", title="halt", blocking=True)"+"\n").encode('utf8'))
                    ^
SyntaxError: invalid syntax

also I can’t compile the script anymore if I add an closing ) after movej

I believe it would need to be setup as this so that it includes the "

    s.send(("popup(\"hey\", title=\"halt\", blocking=True)"+"\n").encode('utf8'))

If it still gives a syntax error then try

    s.send(("popup('hey', title='halt', blocking=True)"+"\n").encode('utf8'))
1 Like

s.send((“popup(“hey”, title=“halt”, blocking=True)”+"\n").encode(‘utf8’))

this is it, thanks :grinning:
movej works now too with the added )

also I can’t compile the script anymore if I add an closing ) after movej

I guess I messed this up in the first try

1 Like