How to know movement has stopped when sending movement script through URScript

Hallo everybody,

I’m making a C# program that sends a generated scripts to the robot
On my simulation it it works great.

But the problem is i can’t figure out how to know that robot has stopped when he is finished with the script.

I tried to use the program state but that does not change to running when i send over the script.

I need to know that the robot has finished with his task so that I can send over the next script task.

Thank you

An idea could be to set an output ON/OFF at the start and end of the movement. Can you access the I/O?

set_standard_output(3, True)
movej(goal_point_q)
set_standard_output(3, False)

A similar approach would be to connect to a TCP or XML-RPC server to notify the end of the movement. In your case, the server would be a parallel thread or a function within your C#.

movej(goal_point_q)
server = rpc_factory("xmlrpc", "http://PC_IP_ADDR:PC_PORT")
end = server.notify_finish()

And in your C# side (I don’t know C# so this is in Python):

import sys
import urlib
from xmlrpc.server import SimpleXMLRPCServer 

global ROBOT_FINISHED
ROBOT_FINISHED = False

def notify_finish():
    global ROBOT_FINISHED
    ROBOT_FINISHED = True
    return True # <- send this to the robot

def run_server():
    server = SimpleXMLRPCServer(("", PC_PORT), allow_none=True)
    server.RequestHandlerClass.protocol_version = "HTTP/1.1"
    print(f"Listening on port {PC_PORT}...")
    server.register_function(notify_finish, "notify_finish")
    server.serve_once()

# Example of one movement with notification:
ROBOT_FINISHED = False
send_URscript_code()
run_server()
if ROBOT_FINISHED:
     print("Movement sucessful")
1 Like

PD: my answer with XML-RPC is based on this example

I have developed on C# something similar and once had the same problem as you now have. programState will not give you info on that because, technically, no program is running. You need to use the Dasboard running command. This command verifies whether a script/program is being run or not. Even if the robot is still (like if you have a timer or a while condition), since the script is running, this will signal you the robot is working. If you need anymore information don’t hesitate to ask.

1 Like

Thanks a lot that seems to be the best solution for my problem.
Thank you everyone for helping