---
title: "Connect to your robot"
description: "Connect a RobotController to a Fanuc, Yaskawa, Universal Robots, ABB or Stäubli controller: the connection parameters of each brand, a connection from a configuration file, the protocols after the connection and the connection errors. C# and Python examples."
---

# Connect to your robot

This page explains how to connect a `RobotController` to a Fanuc, Yaskawa, Universal Robots, ABB or Stäubli controller. The connection parameters are the ones of the brand SDK: their class gives the brand, and everything after `Connect` uses the same API on every brand.

![The class of the connection parameters gives the brand. The code after Connect is the same.](/robotics/documentation/diagrams/connect-parameters.svg)

## A first connection

### Connect with the parameters of a brand

Create the connection parameters of the brand with the address of the controller and pass them to `Connect`. The brand comes from the class of the parameters. After the connection, `Brand` and `Address` tell which controller this is.

**C# : ConnectQuick**
```csharp
using UnderAutomation.Fanuc;
using UnderAutomation.Robotics.Controllers;

public class ConnectQuick
{
    static void Main()
    {
        /**/
        // The brand comes from the type of the parameters
        RobotController robot = new RobotController();
        robot.Connect(new ConnectionParameters("192.168.0.1"));

        Console.WriteLine($"{robot.Brand} controller at {robot.Address}, connected: {robot.Connected}");

        robot.Disconnect();
        /**/
    }
}
```

**Python : ConnectQuick**
```python
from underautomation.fanuc.connection_parameters import ConnectionParameters
from underautomation.robotics.controllers.robot_controller import RobotController

##
# The brand comes from the type of the parameters
robot = RobotController()
robot.connect(ConnectionParameters("192.168.0.1"))

print(f"{robot.brand.name} controller at {robot.address}, connected: {robot.connected}")

robot.disconnect()
##
```

The methods a brand has depend on the brand: see the Brand support table of each service page. The rest of this page covers the parameters of a protocol, a connection from a configuration file, the protocols that answer after the connection and the connection errors.

## Prerequisites

- The PC reaches the controller on the network. By default, `Connect` pings the controller first and stops when it does not answer. Set `PingBeforeConnect` to `false` when a firewall blocks ICMP.
- The firewalls between the PC and the controller let the ports of the protocols through. The ports and the settings of the controller are public information of the robot makers. They are on the connect page of each brand SDK, see the table in the Reference section.
- The settings of the controller for the methods you call. They depend on the brand and on the method: a protocol to enable, a controller option, a user and a password, the remote mode. The table "Brand support" of each service page gives the protocol of each method, and `(manual)` marks a route that you enable yourself in the parameters.
- The license of the brand of the controller, or the 30 day trial. See [Licensing](/robotics/documentation/license).

The library installs nothing on the PC and nothing on the controller. Some methods need something on the controller: read the page of the service and the connect page of the brand.

## Example

### Change the parameters of a protocol

The parameters of a brand have one object per protocol: `Snpx`, `Rmi`, `Rtde`, `Soap`... Change them before `Connect`. This example of a Fanuc controller disables SNPX and RMI, which the controller of the example does not have, and the ping.

**C# : ConnectParameters**
```csharp
using UnderAutomation.Fanuc;
using UnderAutomation.Robotics.Adapter.Fanuc;
using UnderAutomation.Robotics.Controllers;

public class ConnectParameters
{
    static void Main()
    {
        /**/
        // The parameters of the brand SDK, with the settings of the common API
        ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");
        parameters.PingBeforeConnect = false;

        // This controller has no SNPX option: keep the library away from it
        parameters.Routing.Forbid(new[] { FanucProtocol.Snpx });

        RobotController robot = new RobotController();
        robot.Connect(parameters);
        /**/

        robot.Disconnect();
    }
}
```

**Python : ConnectParameters**
```python
from underautomation.fanuc.connection_parameters import ConnectionParameters
from underautomation.robotics.controllers.robot_controller import RobotController

##
# The parameters of the brand SDK, with the settings of the common API
parameters = ConnectionParameters("192.168.0.1")
parameters.ping_before_connect = False

# This controller has no SNPX option: keep the library away from it
parameters.routing.set_text("!", "Snpx")

robot = RobotController()
robot.connect(parameters)
##

robot.disconnect()
```

### Options of the other brands

Each brand has the settings of its own protocols. This example sets one of each brand: a protocol that the library never opens by itself (RMI of Fanuc, Interpreter Mode of Universal Robots), a timeout, the version of the web services of an ABB IRC5 controller, and the user of a Stäubli controller. The other parameters keep the default values of the brand SDK.

**C# : ConnectBrandOptions**
```csharp
using UnderAutomation.Robotics.Controllers;

public class ConnectBrandOptions
{
    static void Main()
    {
        /**/
        // Fanuc: RMI is never opened automatically, enable it in the parameters
        UnderAutomation.Fanuc.ConnectionParameters fanuc = new UnderAutomation.Fanuc.ConnectionParameters("192.168.0.1");
        fanuc.Rmi.Enable = true;

        // Yaskawa: wait longer for the answers of the controller on a slow network
        UnderAutomation.Yaskawa.ConnectParameters yaskawa = new UnderAutomation.Yaskawa.ConnectParameters("192.168.0.2");
        yaskawa.HighSpeedEServer.DataTimeoutMilliseconds = 3000;

        // Universal Robots: Interpreter Mode is never opened automatically either
        UnderAutomation.UniversalRobots.ConnectParameters ur = new UnderAutomation.UniversalRobots.ConnectParameters("192.168.0.3");
        ur.InterpreterMode.Enable = true;

        // ABB: the default is OmniCore, an IRC5 controller needs its own version of Robot Web Services
        UnderAutomation.ABB.ConnectionParameters abb = new UnderAutomation.ABB.ConnectionParameters("192.168.125.1");
        abb.Rws.Version = UnderAutomation.ABB.Rws.RwsVersion.Irc5_V1_0;

        // Stäubli: the user and the password of the controller
        UnderAutomation.Staubli.ConnectionParameters staubli = new UnderAutomation.Staubli.ConnectionParameters("192.168.0.5");
        staubli.Soap.User = "maintenance";
        staubli.Soap.Password = "my password";

        RobotConnectionParameters[] cell = { fanuc, yaskawa, ur, abb, staubli };

        foreach (RobotConnectionParameters parameters in cell)
        {
            RobotController robot = new RobotController();
            robot.Connect(parameters);
            Console.WriteLine($"{robot.Brand}: {robot.Address}");
            robot.Disconnect();
        }
        /**/
    }
}
```

**Python : ConnectBrandOptions**
```python
from underautomation.abb.connection_parameters import ConnectionParameters as AbbParameters
from underautomation.abb.rws.rws_version import RwsVersion
from underautomation.fanuc.connection_parameters import ConnectionParameters as FanucParameters
from underautomation.robotics.controllers.robot_controller import RobotController
from underautomation.staubli.connection_parameters import ConnectionParameters as StaubliParameters
from underautomation.universal_robots.connect_parameters import ConnectParameters as UrParameters
from underautomation.yaskawa.connect_parameters import ConnectParameters as YaskawaParameters

##
# Fanuc: RMI is never opened automatically, enable it in the parameters
fanuc = FanucParameters("192.168.0.1")
fanuc.rmi.enable = True

# Yaskawa: wait longer for the answers of the controller on a slow network
yaskawa = YaskawaParameters("192.168.0.2")
yaskawa.high_speed_e_server.data_timeout_milliseconds = 3000

# Universal Robots: Interpreter Mode is never opened automatically either
ur = UrParameters("192.168.0.3")
ur.interpreter_mode.enable = True

# ABB: the default is OmniCore, an IRC5 controller needs its own version of Robot Web Services
abb = AbbParameters("192.168.125.1")
abb.rws.version = RwsVersion.Irc5_V1_0

# Stäubli: the user and the password of the controller
staubli = StaubliParameters("192.168.0.5")
staubli.soap.user = "maintenance"
staubli.soap.password = "my password"

for parameters in [fanuc, yaskawa, ur, abb, staubli]:
    robot = RobotController()
    robot.connect(parameters)
    print(f"{robot.brand.name}: {robot.address}")
    robot.disconnect()
##
```

### Connect from a configuration file

When the brand and the address come from a configuration file, `RobotConnectionParameters.Create(brand, address)` creates the parameters from the name of the brand: `fanuc`, `yaskawa`, `universalrobots`, `abb` or `staubli`. The result is the class of the brand, with the default values of the brand SDK. Cast it to the class of the brand to change the parameters of a protocol.

**C# : ConnectFromName**
```csharp
using UnderAutomation.Robotics.Controllers;

public class ConnectFromName
{
    static void Main()
    {
        /**/
        // Brand and address from a configuration file: fanuc, yaskawa, universalrobots, abb or staubli
        string brand = "yaskawa";
        string address = "192.168.0.2";

        RobotController robot = new RobotController();
        robot.Connect(RobotConnectionParameters.Create(brand, address));

        // The same code works for every brand
        Console.WriteLine(robot.Info.Read().Model);

        robot.Disconnect();
        /**/
    }
}
```

**Python : ConnectFromName**
```python
from underautomation.robotics.controllers.robot_controller import RobotController
from underautomation.robotics.controllers.robot_connection_parameters import RobotConnectionParameters

##
# Brand and address from a configuration file: fanuc, yaskawa, universalrobots, abb or staubli
brand = "yaskawa"
address = "192.168.0.2"

robot = RobotController()
# The last argument is the routing settings as text: empty for no setting
robot.connect(RobotConnectionParameters.create(brand, address, ""))

# The same code works for every brand
print(robot.info.read().model)

robot.disconnect()
##
```

**Matlab : ConnectFromName**
```matlab
NET.addAssembly(fullfile(pwd, 'net48', 'UnderAutomation.Robotics.dll'));
import UnderAutomation.Robotics.Controllers.*

%%
% Brand and address from a configuration file: fanuc, yaskawa, universalrobots, abb or staubli
brand = 'yaskawa';
address = '192.168.0.2';

% The third argument is the routing text: '' for no setting
robot = RobotController();
robot.Connect(RobotConnectionParameters.Create(brand, address, ''));

% The same code for each brand: Info.Read has a route on the five brands
info = robot.Info.Read();
disp(char(info.Model));

robot.Disconnect();
%%
```

The third argument is the routing settings as text, the same text that `ToText` of the routing settings writes: settings separated by `;`, each one `path=routes`. This example sends the methods of the Program service to the CGTP route of Fanuc. The names of the routes are the ones of the brand. An invalid text throws an `ArgumentException`, and a route that the brand does not have is refused at the connection. See [Routing](/robotics/documentation/routing).

**C# : ConnectRoutingText**
```csharp
using UnderAutomation.Robotics.Controllers;

public class ConnectRoutingText
{
    static void Main()
    {
        /**/
        // Three values of a configuration file: the brand, the address and the routing settings as text
        string brand = "fanuc";
        string address = "192.168.0.10";
        string routing = "Program.*=Cgtp";

        RobotController robot = new RobotController();
        robot.Connect(RobotConnectionParameters.Create(brand, address, routing));

        Console.WriteLine($"{robot.Brand} controller at {robot.Address}, connected: {robot.Connected}");

        robot.Disconnect();
        /**/
    }
}
```

**Python : ConnectRoutingText**
```python
from underautomation.robotics.controllers.robot_controller import RobotController
from underautomation.robotics.controllers.robot_connection_parameters import RobotConnectionParameters

##
# Three values of a configuration file: the brand, the address and the routing settings as text
brand = "fanuc"
address = "192.168.0.10"
routing = "Program.*=Cgtp"

robot = RobotController()
robot.connect(RobotConnectionParameters.create(brand, address, routing))

print(f"{robot.brand.name} controller at {robot.address}, connected: {robot.connected}")

robot.disconnect()
##
```

### Read the protocols after the connection

`robot.Routing.GetProtocols()` returns the result of each protocol of the brand at the connection, in the order of the brand. Use it to see which interfaces of the controller answered and why one did not.

**C# : RoutingProtocols**
```csharp
using UnderAutomation.Robotics.Controllers;

public class RoutingProtocols
{
    static void Main()
    {
        RobotController robot = new RobotController();
        robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));

        /**/
        // Result of the connection of each protocol of the brand
        foreach (ProtocolInfo protocol in robot.Routing.GetProtocols())
            Console.WriteLine($"{protocol.DisplayName}: {protocol.Status}");
        /**/

        robot.Disconnect();
    }
}
```

**Python : RoutingProtocols**
```python
from underautomation.robotics.controllers.robot_controller import RobotController
from underautomation.robotics.controllers.robot_connection_parameters import RobotConnectionParameters

robot = RobotController()
robot.connect(RobotConnectionParameters.create("fanuc", "192.168.0.1", ""))

##
# Result of the connection of each protocol of the brand
for protocol in robot.routing.get_protocols():
    print(f"{protocol.display_name}: {protocol.status.name}")
##

robot.disconnect()
```

A protocol that no method needed, or that was not reached before the connection stopped, is `NotTested`. A protocol that the library never opens by itself and that you did not enable is `NotProbed`. The other values and their causes are in the page [Errors](/robotics/documentation/errors#protocolinfo).

### Read the error of a failed connection

When `Connect` fails, `RobotControllerException.Protocols` has the same list. Read it before you look at the controller: the status of each protocol says if the controller did not answer, refused the user or the password, or if the protocol was disabled.

**C# : ConnectErrors**
```csharp
using UnderAutomation.Robotics.Controllers;

public class ConnectErrors
{
    static void Main()
    {
        /**/
        RobotController robot = new RobotController();

        try
        {
            robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));
        }
        catch (RobotControllerException ex)
        {
            Console.WriteLine(ex.Message);

            // Result of each protocol: open, no answer, authentication failed, disabled...
            foreach (ProtocolInfo protocol in ex.Protocols)
                Console.WriteLine($"{protocol.DisplayName}: {protocol.Status} {protocol.Error}");
        }
        /**/
    }
}
```

**Python : ConnectErrors**
```python
from underautomation.robotics.controllers.robot_controller import RobotController
from underautomation.robotics.controllers.robot_connection_parameters import RobotConnectionParameters
from UnderAutomation.Robotics.Controllers import RobotControllerException

##
robot = RobotController()

try:
    robot.connect(RobotConnectionParameters.create("fanuc", "192.168.0.1", ""))
except RobotControllerException as ex:
    # The exception comes from the .NET runtime, so its members keep their original names
    print(ex.Message)

    # Result of each protocol: open, no answer, authentication failed, disabled...
    for protocol in ex.Protocols:
        print(f"{protocol.DisplayName}: {protocol.Status} {protocol.Error}")
##
```

### Use the object of the brand SDK

The common API does not cover every function of a brand. `robot.Native` gives the object of the brand SDK, on the same connections.

**C# : ConnectNative**
```csharp
using UnderAutomation.Fanuc;
using UnderAutomation.Robotics.Controllers;

public class ConnectNative
{
    static void Main()
    {
        RobotController robot = new RobotController();
        robot.Connect(new ConnectionParameters("192.168.0.1"));

        /**/
        // The object of the brand SDK, on the same connections: features that the common API does not have
        if (robot.Brand == RobotBrand.Fanuc)
        {
            FanucRobot fanuc = (FanucRobot)robot.Native;
            Console.WriteLine(fanuc.Cgtp.Enabled);
        }
        /**/

        robot.Disconnect();
    }
}
```

**Python : ConnectNative**
```python
from underautomation.fanuc.connection_parameters import ConnectionParameters
from underautomation.fanuc.fanuc_robot import FanucRobot
from underautomation.robotics.controllers.robot_brand import RobotBrand
from underautomation.robotics.controllers.robot_controller import RobotController

robot = RobotController()
robot.connect(ConnectionParameters("192.168.0.1"))

##
# The object of the brand SDK, on the same connections: features that the common API does not have
if robot.brand == RobotBrand.Fanuc:
    fanuc = FanucRobot(robot.native)
    print(fanuc.cgtp.enabled)
##

robot.disconnect()
```

## Reference

In Python, the names are in snake_case: `robot.connect(...)`, `robot.routing.get_protocols()`. `RobotConnectionParameters.create` takes its three arguments: pass an empty text for no routing settings. The classes of the brand parameters are in the modules listed on [Get started with Python](/robotics/documentation/get-started-python).

### Parameters of every brand

`RobotConnectionParameters` is the base class of the parameters of every brand.

| Member | Type | Content |
| --- | --- | --- |
| `Address` | `string` | Address of the controller, an IP address or a host name. |
| `PingBeforeConnect` | `bool` | True to check with a ping that the controller answers before the connection. |
| `CheckComments` | `bool` | True to check the comment written in the name of a variable or of a signal against the comment of the controller. False by default: the comment is ignored. |
| `Routing` | `RoutingSettings` | Which route each method uses. Without settings, the library chooses. See [Routing](/robotics/documentation/routing). |

### Parameters of each brand

The main objects of parameters of each class are listed. The connect page of the brand SDK describes each parameter, the TCP and UDP ports of the protocols and the settings of the controller. The common API uses some of these protocols only. Its route tables show which ones.

| Brand | Class of the parameters | Objects of parameters | Ports, options and settings of the controller |
| --- | --- | --- | --- |
| Fanuc | `UnderAutomation.Fanuc.ConnectionParameters` | `Cgtp`, `Snpx`, `Telnet`, `Ftp`, `Rmi`, `StreamMotion` | [Protocols and controller options](/fanuc/documentation/connect#protocols_and_controller_options) |
| Yaskawa | `UnderAutomation.Yaskawa.ConnectParameters` | `HighSpeedEServer`, `EServer`, `Http`, `Ftp` | [Prerequisites and settings of the controller](/yaskawa/documentation/connect) and [Choose a protocol](/yaskawa/documentation/protocols) |
| Universal Robots | `UnderAutomation.UniversalRobots.ConnectParameters` | `PrimaryInterface`, `Dashboard`, `Rtde`, `InterpreterMode`, `Rest`, `Ssh`, `XmlRpc`, `SocketCommunication` | [Interfaces and ports](/universal-robots/documentation/connect#interfaces_and_ports) |
| ABB | `UnderAutomation.ABB.ConnectionParameters` | `Rws` | [What the controller needs](/abb/documentation/connect#what_the_controller_needs) and [IRC5 or OmniCore](/abb/documentation/irc5-vs-omnicore) |
| Stäubli | `UnderAutomation.Staubli.ConnectionParameters` | `Soap`, `File` | [Prerequisites](/staubli/documentation/connect#prerequisites) |

The address is `Address` on Fanuc, ABB and Stäubli, and `IP` on Yaskawa and Universal Robots. `Address` of the base class works on every brand.

### Methods and properties of the connection

| Member | Content |
| --- | --- |
| `RobotController.Connect(parameters)` | Opens the connections that the brand needs. Throws `RobotControllerException` when it fails. |
| `RobotController.Disconnect()` | Closes the connections. |
| `RobotController.Brand`, `Address`, `Connected` | The brand and the address of the connected controller, and the state of the connection. |
| `RobotController.Routing.GetProtocols()` | A `ProtocolInfo` for each protocol of the brand. |
| `RobotController.Native` | The object of the brand SDK: `FanucRobot`, `YaskawaRobot`, `UR`, `AbbController` or `StaubliController`. Null when the controller is not connected. |

`ProtocolInfo` and `ProtocolStatus` are described on the page [Errors](/robotics/documentation/errors#protocolinfo).

## What to read next

- [How-to articles](/robotics/documentation/how-to-articles): the first calls after the connection, one code per task.
- [Work without a robot](/robotics/documentation/simulator): the simulators of the robot makers.
- [Errors](/robotics/documentation/errors): the exceptions of `Connect` and of the methods.
- [Routing](/robotics/documentation/routing): which protocol each method uses on each brand, and how to change it.
- [Common API](/robotics/documentation/common-api): the services of `RobotController`.
- [Licensing](/robotics/documentation/license): the trial and the license key of each brand.