UR skips socket send command

I am working on a URCap that will control a outside device that is running on it’s own pc. At this point, I am verifying that the java code on the outside device will work but I am running into a bit of an issue that I do not know the answer to.

I have established a socket in the before start routine. The socket is var_1. Also, I included a loop if var_1 is false in the main program. The socket almost always establishes in the before start routine unless I have left the java program in the external pc running. If I have, then the main program takes over and goes into the loop since var_1 is false.

The UR program( real robot not simulator) goes to waypoint 1 with a two second wait following arrival at waypoint 1, the next node is the socket false loop and the third node is a script command: "socket_send_string(“Center”).

Before I run the UR program, I start the pc which has a server socket program that listens on a specific port and this works well.

During execution of the UR program, the program jumps over the socket_send_string command and moves to the next UR program node.

When I stop UR execution, then the pc java program shows the input for the number of cycles run.

I would appreciate any thoughts you might have and I can supply much more detail if necessary.
Jerry

I got it figured out… a bit of syntax goes a long way…

Hey Jerry

Im new to URcaps developing, and was wondering which functions you use to connect to your server, when node is executed in polyscope?

Kmeld,
I would be happy to give you any help that I can but your question is too general.
If you could sharpen your question by telling me what you are trying to accomplish I may be able to give you some insight.
Jerry

1 Like

Im trying to implement a node that connects to a server (via ethernet/ip tcp) running on my external microcontroller. The IP + port# will be set in installation, but im unsure how the node will connect to the server everytime polyscope exucutes it.
The idea is that polyscope will send a signal to the microcontroller, whether to activate/deactivate my actuator - it is not possible to use the UR controller I/O.
Thnaks

Kmeld17,
Yes, it is possible to do what you are wanting to do. You will most likely need to use XmlRpc to call procedures on your remote computer. You most likely are using HTML in the Installation and Program nodes, gather the required information from the HTML interface, construct XmlRpc to send that info to your remote computer and build your remote procedures in the program language you prefer. You end up with a few discrete operations; Html, Robot Java, Remote Computer XmlRpc handler, Remote Computer execution program.

This is easy to say and may be somewhat difficult to execute ( I speak from experience). You will be mixing several different technologies together to form your end product. I have been through the process and will gladly share my key learnings and offer help where needed.
Jerry

Is the microcontroller capable of hosting a TCP server?
If you have the power to define the protocol yourself, you could create a simple TCP socket communication, where native URScript commands such as socket_send_int(42, "mySocketName") and socket_read_ascii_float(3, "mySocketName") could be used to communicate at runtime.
Consult the URScript manual for documentation on the various script commands.
You could use the URCap to get the IP address to the MCU, and optionally port (or the port could be fixed).

1 Like

Thanks Jerry & JBM
The controller (Raspberri Pi) should be able to host the server.
I’ll consult the URscript manual.

in addiition, I must say that the project is part of my uni c++ course, which is why i have to run the signal through the RPI.
Thanks agian for support

Follow up question:
I’ve now build a URcap, which have been installed on the UR5. But when the urscript attempts an open_socket, it fails. UR5 & MCU are connected via ethernet cable. I tried setting the UR5 controller network to DHCP, static…, but it just wont connect to the server.
Any Thoughts?

The plugin works fine on a virtual machine with a cable from my pc to the MCU

Regards

For just a 1-to-1 connection via an Ethernet cable, you probably want to use a static IP.
Also, remember that both devices should be on the same subnet.
I.e.
UR: IP = 172.16.17.10 Subnet mask = 255.255.255.0
MCU IP = 172.16.17.11 Subnet mask = 255.255.255.0

And ensure that the TCP server is running and accepting connections on the MCU, before trying to open the client from URScript.

Thanks
This works
I’m setting the UR5 IP = to the MCU IP + 1 and same mask (static)

1 Like