UnderAutomation
질문이요?

[email protected]

문의하기
UnderAutomation
⌘Q
이 페이지는 영어로만 제공됩니다.

Connect to the robot

Enable the interfaces of the UR cobot, set the network and the remote control, then connect with ConnectParameters. Ports, settings and errors.

  • Interfaces and ports
  • Prepare the robot
  • Network
  • Services
  • Remote control
  • Firewall of the PC
  • Connect
  • Errors
  • Disconnect
  • Try it in the demo application
  • What to read next

This page explains how to prepare a Universal Robots cobot for the SDK, and how to connect to it from C# or Python. It applies to CB-Series and e-Series robots with PolyScope, to the robots with PolyScope X, and to URSim.

Interfaces and ports

The SDK uses the standard interfaces of the robot. Each one is enabled in ConnectParameters, and some must also be enabled on the robot.

InterfacePortConnectParametersDefaultSetting on the robot
Primary Interface30001PrimaryInterfaceenabledService Primary Client Interface
Dashboard Server29999DashboardenabledService Dashboard Server. Not on PolyScope X
RTDE30004RtdedisabledService RTDE
Interpreter Mode30020InterpreterModedisabledService Interpreter Mode Socket
REST API80RestdisabledPolyScope X only
SSH and SFTP22Ssh.EnableSsh, Ssh.EnableSftpdisabledSecure Shell enabled
XML-RPC server50000 (PC)XmlRpcdisabledNone. The robot program connects to the PC
Socket server50001 (PC)SocketCommunicationdisabledNone. The robot program connects to the PC

The Primary Interface can also use the Secondary Interface (30002) and the read only ports (30011, 30012), with PrimaryInterface.Port. The read only ports do not accept URScript.

Prepare the robot

Network

The robot and the PC must be on the same network, with addresses in the same subnet. On PolyScope, the address is set in the menu at the top right, Settings, System, Network.

Before it connects, Connect sends a ping to the robot and stops if the robot does not answer within 500 ms. When a firewall blocks the ping, set PingBeforeConnecting to false.

Services

For security, each interface must be enabled on the robot. On PolyScope, open the menu at the top right, Settings, Security, Services, and enable the interfaces of the table above.

Enable the services

In Settings, Security, General, the inbound connections must not be restricted for the ports that the SDK uses.

Inbound connections

Remote control

On e-Series and PolyScope X, the robot accepts commands from the network only in remote control: Dashboard commands that change its state (power, brakes, load, play), URScript sent with the Primary Interface, and REST commands. Reading data does not need it.

Enable the remote control in Settings, System, Remote Control, then switch the robot from Local to Remote with the icon at the top right of PolyScope.

Enable remote control

Switch to remote control

Firewall of the PC

The antivirus or the firewall of the PC can block these ports. If the connection fails, check them first. The XML-RPC and socket servers listen on the PC: allow their ports in the firewall of the PC.

Connect

Connect("192.168.0.1") opens the Primary Interface and the Dashboard Server. To choose the interfaces and their settings, pass a ConnectParameters:

static void Main(string[] args)
{
var robot = new UR();
var parameters = new ConnectParameters("192.168.0.1");
// Enabled by default
parameters.PrimaryInterface.Enable = true;
parameters.Dashboard.Enable = true;
// RTDE: select the data to exchange and the frequency
parameters.Rtde.Enable = true;
parameters.Rtde.Frequency = 500; // Hz
parameters.Rtde.OutputSetup.Add(RtdeOutputData.ActualTcpPose);
parameters.Rtde.OutputSetup.Add(RtdeOutputData.ActualQ);
parameters.Rtde.InputSetup.Add(RtdeInputData.InputIntRegisters, 24);
// Local XML-RPC server, called by the robot program
parameters.XmlRpc.Enable = true;
parameters.XmlRpc.Port = 50000;
// Local socket server, the robot program connects to it
parameters.SocketCommunication.Enable = true;
parameters.SocketCommunication.Port = 50001;
// SSH and SFTP, with the Linux user of the controller
parameters.Ssh.EnableSsh = true;
parameters.Ssh.EnableSftp = true;
parameters.Ssh.Username = "ur";
parameters.Ssh.Password = "easybot";
// Interpreter Mode and REST API (PolyScope X) are disabled by default
parameters.InterpreterMode.Enable = false;
parameters.Rest.Enable = false;
robot.Connect(parameters);
// ...
// Close every service
robot.Disconnect();
}
}
Click to see the full code
Class
ConnectParameters
C#Python

Contains parameters to connect to the robot

MemberTypeDescription
ConnectParameters()
Constructor
Initializes a new instance of ConnectParameters with default values.
ConnectParameters(string)
Constructor
Initializes a new instance of ConnectParameters with the specified robot IP address.
  • ip : The IP address of the Universal Robots controller.
Dashboard
Property
DashboardConnectParameters
Dashboard Server connection parameters (port 29999).
IP
Property
string
IP address of the Universal Robots controller.
InterpreterMode
Property
InterpreterModeConnectParameters
Interpreter Mode connection parameters for sending URScript lines interactively.
PingBeforeConnecting
Property
bool
If true, a ping is sent to the robot before attempting connection. Default is true.
PrimaryInterface
Property
PrimaryInterfaceConnectParameters
Primary Interface connection parameters (port 30001/30002).
Rest
Property
RestConnectParameters
REST API connection parameters (PolyscopeX only)
Rtde
Property
RtdeConnectParameters
Real-Time Data Exchange (RTDE) connection parameters (port 30004).
SocketCommunication
Property
SocketCommunicationConnectParameters
Socket communication connection parameters for exchanging data with URScript programs.
Ssh
Property
SshConnectParameters
SSH and SFTP connection parameters for file transfer and remote shell access.
XmlRpc
Property
XmlRpcConnectParameters
XML-RPC connection parameters for remote procedure calls.
ToString()
Method
string
Returns a string representation containing the robot IP address.

Each interface is also a class that works without UR: PrimaryInterfaceClient, DashboardClient, RtdeClient, RestClient, SftpClient, SshClient, InterpreterModeClient, XmlRpcServer, SocketCommunicationServer. The page of each interface shows it.

Errors

Connect opens the interfaces one after the other. When one fails, it closes the others and throws:

ExceptionCause
InvalidLicenseExceptionThe trial is over, or the license key is not valid
ConnectExceptionOne interface did not connect. Service names it, RobotIp gives the address
ExceptionThe robot does not answer the ping, or the address is empty

After the connection, the errors of the background threads raise the event InternalErrorOccured, on UR and on each client.

{
var robot = new UR();
try
{
robot.Connect("192.168.0.1");
}
catch (InvalidLicenseException ex)
{
// The trial is over or the license key is not valid
Console.WriteLine(ex.LicenseInfo);
}
catch (ConnectException ex)
{
// One service did not connect: the other services are closed
Console.WriteLine($"{ex.Service} of {ex.RobotIp}: {ex.Message}");
}
catch (Exception ex)
{
// For example, the robot does not answer the ping
Console.WriteLine(ex.Message);
}
// Errors that happen after the connection, in a background thread
robot.InternalErrorOccured += (sender, e) =>
{
Console.WriteLine($"{e.Status}: {e.Message}");
};
}
}
Click to see the full code

Disconnect

Disconnect() closes every interface. Each client also has its own method: robot.Rtde.Disconnect(), robot.Dashboard.Disable()...

Try it in the demo application

Everything on this page can be tried without writing code, in the Connection page of the demo application.

Connection page of the Universal Robots SDK demo application

The demo application is open source. The C# source of this page is ConnectControl.cs.

What to read next

  • Develop without a robot: install URSim.
  • RTDE and Primary Interface: read the state of the robot.
  • Licensing: the 30 day trial and the license key.

Universal Robots, Fanuc, Yaskawa, ABB 또는 Staubli 로봇을 .NET, Python, LabVIEW 또는 Matlab 애플리케이션에 쉽게 통합

UnderAutomation
문의하기Legal

© All rights reserved.