Communicating with the robot controller

It is possible for a backend container contribution to communicate with the robots controller using different interfaces. To establish controller communication two parts are required:

  • In the Manifest.yaml describe what service the container should access.

  • From code implement the socket communication using the service name and correct interface port number.

Controller services

These are the available services that can be reached from a container contribution.

Service

DNS name

Description

Controller Primary

urcontrol-primary

Primary interface on controller

Controller Secondary

urcontrol-secondary

Secondary interface on controller

Controller Real-time

urcontrol-real-time

Real-time interface on controller

Controller RTDE

urcontrol-rtde

RTDE interface on controller

Controller interpreter

urcontrol-interpreter

Interpreter interface on controller

Controller primary read-only

urcontrol-primary-read-only

Read-only access

Controller secondary read-only

urcontrol-secondary-read-only

Read-only access

Controller real-time read-only

urcontrol-real-time-read-only

Read-only access

Container services

servicegateway

Ingress access to containers

Controller ports

These are the ports needed when creating a socket from code

Interface

Port

Primary

30001

Secondary

30002

Realtime (Deprecated)

30003

RTDE

30004

Primary read-only

30011

Secondary read-only

30012

Realtime read-only

30013

Interpreter

30020

Communicating with a service

The following is snippets from the calibration-info sample, that demonstrates how to set up a backend contribution for reading the controllers primary interface.

manifest.yaml

The following shows how the backend contribution of the calibration-info sample is configured to read from the controllers primary interface.

....
containers:
  - id: calibration-info
  image: calibration-info:latest
  services:
    - service: urcontrol-primary-read-only
...

The “services” section describe what services should be made available to the contribution (see “Controller services” table). “urcontrol-primary-read-only” will allow reading from the controller primary socket

Socket implementation

When implementing the socket communication the service name from the manifest must be used as host, the port can be found in the controller ports section above. In this case the host is “urcontrol-primary-read-only” and the port for the primary interface is 30001.

....
private static final String HOST = "urcontrol-primary-read-only";
private static final int PORT = 30011;
private final Socket socket;
private final DataInput input;

public ControllerConnection() throws IOException {
        socket = new Socket(HOST, PORT);
        input = new DataInputStream(new BufferedInputStream(socket.getInputStream()));
}
...

Further reading

See Overview Of Client Interfaces for an overall explanation of the robots client interfaces.