Send feedback to PC over socket after robot move

Hi,

I am looking to do the following

  • Send a script command on port 30002 through a socket from a PC program to move the robot to a certain position

  • When the move finishes I need to send a return signal back to the PC to indicate the move has finished

What it the best way to accomplish this?

Thanks

JT

+1 same question, I’m interested if anyone has a tip.

My alternative solution that I use every time:

  • My program builds an urp program file with the UnderAutomation library
  • I transfer the file via ssh
  • I load and run the program through Dashboard server
  • I wait for Primary Interface to tell me that the execution is completed

In your case, you can run the script (which makes a move and writes a global variable) on port 30002. You can then listen and decode the data from port 30002 where there is a message that gives the value of the variable.

Thanks for the inputs

Just on your solution - how can you access / listen to a global variable on port 30002?

What I was thinking was to send code to open up a socket back to my PC and send a return message that way. It’s a bit convoluted though and would be slow creating a new socket for each and every move command sent.

I’m sure there must be a better way??

I was thinking of a solution like this one in C# :

using UnderAutomation.UniversalRobots;
using UnderAutomation.UniversalRobots.PrimaryInterface;
using System.Threading;

// Connect to robot
var robot = new UR();
robot.Connect("192.168.0.56");

// Execute move, then set variable synchro to 1
robot.PrimaryInterface.Script.Send(@"def prog():
movej([-1.5,-1.5,-2,-0.5,1.8,0],a=1.4, v=1.05, t=0, r=0)
global synchro=1
end");

// wait synchro to reach value 1
while (robot.PrimaryInterface.GlobalVariables.GetByName("synchro")?.ToInt() != 1)
{
	Thread.Sleep(100);
}

// Execute a new move, then set variable synchro to 2
robot.PrimaryInterface.Script.Send(@"def prog():
movej([-1.3,-1.2,-2,-0.5,1.7,0],a=1.4, v=0.2, t=0, r=0)
global synchro=2
end");

// wait synchro to reach value 2
while (robot.PrimaryInterface.GlobalVariables.GetByName("synchro")?.ToInt() != 2)
{
	Thread.Sleep(100);
}

As specified in the Primary Interface documentation (see PDF here: Remote Control Via TCP/IP - 16496) you can certainly send script, but the robot also sends messages and one of these messages is the value of program variables. The UnderAutomation library is a commercial library that implements this protocol among others.