Set values GP registers in runtime using Installation Node

Hi there,

I wanted to use a Installation node that enable to set/reset some GP registers. I research about this fact and I found that from Installation node you cannot “write” URScript in Runtime because the scriptwriter add the lines at the beggining. Hence, if I cannot use scriptwriter, and neither using the secondary client from Installation node… (cause I send script through socket but it seems to not work…)

How can I manipulate the GP register values through Installation window in Runtime?

Thanks for your time

Hi @flopez

Sending to the secondary client should work… have you checked out this example? Are you sure your script syntax is correct?

So when you say at runtime, you want to be able to do this while the main program is running? In that case you could send it at a secondary program like this:

sec prog():
 write_output_integer_register(0,1)
end

https://www.universal-robots.com/how-tos-and-faqs/how-to/ur-how-tos/secondary-program-17257/

Hi!

Yes, I tried to implement this URCap Sample but it seems that doesn’t work…
The method that sends the script is:

// Method Script //

private void sendToSecondary(String command){
try{
// Create a new Socket Client
Socket sc = new Socket(TCP_IP, TCP_port);
if (sc.isConnected()){
System.out.println(“Connected to UR Secondary Client”);
}

		// Create stream for data
		DataOutputStream out;
		out = new DataOutputStream(sc.getOutputStream());
		
		// Wrap command in "sec" and "end"
		String thisCommand = "sec prog():\n "+command+"\n end\n";
					
		// Send command
		out.writeBytes(thisCommand);
		System.out.println("Send this: "+thisCommand);
		out.flush();

		// Perform housekeeping 
		out.close();
		sc.close();
		System.out.println("Disconnected from UR Secondary Client");
	} 
	catch (IOException e){
		System.out.println(e);
	}
}

And this is the command that appears in the terminal.

image

Am I doing something wrong?

I don’t see anything immediately wrong with that… did it work with the sample commands before you changed it? Maybe try set_standard_digital_out(0,True). Easy to see the blue light come on in the I/O tab and no chance that it’s something blocking your RTDE connection that way.

String thisCommand = "sec prog():\n "+command+"\n end\n";

should be

String thisCommand = "sec prog():\n "+command+"\nend\n";

Been there, done that. :slight_smile:

1 Like

ahhaaaa I did look at the indentation before the command… missed that one though :slight_smile: good catch!

Does this mean the sample in it’s original form is broken?

Thank you guys!

That “command” is the problem. Solved!

And another question related to this topic. When I’m trying to send a moveJ or moveL like the sample, it works.

image

But, if instead using a string “p[0.0, -0.3, 0.1, 0, 3.1415, 0]”, I use a variable it doesn’t work.

The variable is i_var_3=: p[0.0, -0.3, 0.1, 0, 3.1415, 0]

So, if I use the complete string, works. If I use a variable that includes the string, doesn’t work…

image

I’m sure I’m doing something wrong :sweat_smile:

When you send the script you create a new, let’s call it, “execution context” without any variables in it. Robot does not retain any variables after the program is stopped.
This would work:

def prog():
    i_var_3=: p[0.0, -0.3, 0.1, 0, 3.1415, 0]
    movej(i_var3,a=1.57,v=0.5)
end

But that is probably not what you want. ¯_(ツ)_/¯

Thanks @dozminkowski :smile:

My idea is to take a installation variable defined by the user and use it to create a move. If everytime I send the script it creates a “execution context” like you called, maybe is not possible.

Anyway, thanks for your time !

I didn’t find it in documentation, but deducted it from scripts generated by Polyscope. Everything you want to use has to be there. Even direction of gravity. However you might want to wait for confirmation from UR.

@dozminkowski is correct here,
Any context you need for your URScript program must be in the script itself.

This includes variables, Waypoint locations etc.