URCap to Dashboard server commands

Hello together,

I have a situation which I do not understand.
I am using the UR Script Communicator from GitHub GitHub - BomMadsen/URCap-ScriptCommunicator: Exemplification of how to communicate with URControl from a URCap.
As you can see there is the popup script command there and it works fine.
The strange this is that I want to communicate with the dashboard of the robot so I can load a program, stop a running program, etc.
I have modified in the Script Sender the IP and the Port like below:

private final int TCP_port = 29999;

/**
 * Default constructor, using localhost IP (127.0.0.1)
 */
public ScriptSender() { 
	this.TCP_IP = "127.0.0.1";
}

When I change the popup message with another one lets’s say: load, shutdown, play etc. there is no response. Nothing. Not even in the terminal. My question is what I am doing wrong? What mistake I have made that I cannot connect to the dashboard of the robot and send a command. I have done this and checked with an Python standalone application from the HOST PC to a URSim VM and it works.

public void sendScriptTest() {
// Create a new ScriptCommand called “testSend”
ScriptCommand sendTestCommand = new ScriptCommand(“testSend”);

	// Append a popup command to the ScriptCommand
	sendTestCommand.appendLine("load<test.urp>");
	
	// Use the ScriptSender to send the command for immediate execution
	sender.sendScriptCommand(sendTestCommand);

The test.urp is in the right place in the programs folder of the URsim.
I am using the standard URCap Virtual machine without any modifications.

The final goal is to have a User GUI where the operator can choose the program to load and start, stop. There will be some buttons with different program which needs to loads different .urp files. But for this to work I need to connect to the dashboard and send commands.

Thank you in advance for the time and the help provided!

Hi @vl4dutz_1,

the Script Communicator is not designed to send Dashboard Commands. A Dashboard Command is generally just a single line, but by creating a new ScriptCommand() the commands are wrapped with a function definition. In your case the sent script would have looked like:

sec testSend():
    load <test.urp>
end

Having single script commands combined in one function runs them together as one program on the robot. Sending single lines of script code would stop the currently running program immediately and only run the one line received.

Adjusting the ScriptSender() to take the direct Dashboard Command you would like to transmit could be an approach.

sko

Hello,
I have found a solution and I just want to post it here for everyone to know. Below you can find the solution. Maybe not the most elegant.
I just use the code from library which is used to connect to the socket and put it inside the function for when the button is pressed.
I have tested and it works. Maybe it will help someone.
Thank you for your help!

public void sendScriptTest() {

		//String command=new String("play");
		String command ="play";
			
			
			try{
				// Create a new Socket Client
				Socket sc = new Socket("127.0.0.1", 29999);
				if (sc.isConnected()){
					// Create stream for data
					DataOutputStream out;
					out = new DataOutputStream(sc.getOutputStream());
					
					// Send command
					out.write(command.getBytes("US-ASCII"));
					out.flush();

					// Perform housekeeping 
					out.close();
				}
				sc.close();
			} 
			catch (IOException e){
				System.out.println(e);
			}
		}
1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.