Connect to your robot
Learn how to configure connection parameters, enable protocols, and connect to a real Fanuc robot or ROBOGUIDE simulation.
The ConnectionParameters class lets you configure which protocols to enable before connecting to the robot. Each protocol is optional and can be enabled independently.
Quick connection
The simplest way to connect is to pass an IP address directly. This enables only the CGTP protocol by default.
static void Main(){var robot = new FanucRobot();robot.Connect("192.168.0.1");}}
Full connection with multiple protocols
To use multiple protocols, create a ConnectionParameters object and enable each protocol you need.
using UnderAutomation.Fanuc;using UnderAutomation.Fanuc.Common;public class Connect{static void Main(){// Create a robot instanceFanucRobot robot = new FanucRobot();// Configure connection parametersConnectionParameters parameters = new ConnectionParameters("192.168.0.1");// Enable Telnet KCL for remote commandsparameters.Telnet.Enable = true;parameters.Telnet.TelnetKclPassword = "your_password";// Enable FTP for file and variable accessparameters.Ftp.Enable = true;parameters.Ftp.FtpUser = "";parameters.Ftp.FtpPassword = "";// Enable SNPX for high-speed register and I/O accessparameters.Snpx.Enable = true;// Enable CGTP Web Server (enabled by default)parameters.Cgtp.Enable = true;// Enable RMI for remote motion commandsparameters.Rmi.Enable = true;// Connect to the robotrobot.Connect(parameters);// Check connection statusbool isConnected = robot.Enabled;// Disconnect when donerobot.Disconnect();}}
Connect to ROBOGUIDE
Instead of an IP address, you can pass the path to a ROBOGUIDE workcell robot folder. The SDK reads the services.txt file in that folder to discover the TCP ports used by the simulator.
{FanucRobot robot = new FanucRobot();var parameters = new ConnectionParameters(@"C:\Users\you\Documents\My Workcells\CRX 10iA L\Robot_1");parameters.Telnet.Enable = true;parameters.Telnet.TelnetKclPassword = "";parameters.Ftp.Enable = true;parameters.Ftp.FtpUser = "";parameters.Ftp.FtpPassword = "";robot.Connect(parameters);}}
Connection options
When PingBeforeConnect is true (default), the SDK sends a ping to the robot before attempting any connection. If the robot does not respond, an exception is thrown immediately. Set it to false when connecting to ROBOGUIDE or when ICMP is blocked on your network.
Set the Language property to match your controller's language so that strings are decoded correctly.
FanucRobot robot = new FanucRobot();ConnectionParameters parameters = new ConnectionParameters("192.168.0.1");// Ping before connecting (default: true)parameters.PingBeforeConnect = true;// Set to false for ROBOGUIDE or when ICMP is blocked// Controller language for correct string decodingparameters.Language = Languages.English; // default (ASCII)// parameters.Language = Languages.Japanese; // Shift-JIS// parameters.Language = Languages.Chinese; // GB2312robot.Connect(parameters);}
Standalone protocol clients
Each protocol can also be used independently without FanucRobot. This is useful when you only need a single protocol:
static void Main(){// Standalone SNPX clientvar snpx = new SnpxClient();snpx.Connect("192.168.0.1");// Standalone Telnet clientvar telnet = new TelnetClient();telnet.Connect("192.168.0.1", "telnet_password");// Standalone CGTP clientvar cgtp = new CgtpClient();cgtp.Connect("192.168.0.1");}}
Disconnect
Always disconnect when you are done to release resources.
FanucRobot robot = new FanucRobot();robot.Connect("192.168.0.1");robot.Disconnect();}}
API reference
Connection parameters
| Member | Type | Description |
|---|---|---|
ConnectionParameters() Constructor | Instanciate a new connection parameters | |
ConnectionParameters(string) Constructor | Instanciate a new connection parameters with a specified address | |
Address Property | string | Address of the robot (IP, host name, or path to ROBOGUIDE project folder) |
Cgtp Property | CgtpConnectParameters | Parameters for CGTP Web Server (HTTP-based COMET RPC interface) |
Ftp Property | FtpConnectParameters | Access controller internal memory to read variables, IO, positions, diagnosis, ... |
Language Property | Languages | Controller language (default: English) |
PingBeforeConnect Property | bool | Send a ping command before initializing any connections |
Rmi Property | RmiConnectParameters | Parameters for RMI (Remote Motion Interface) |
Snpx Property | SnpxConnectParameters | Read and write IOs, read and clear alarms, read current program tasks |
StreamMotion Property | StreamMotionConnectParameters | Parameters for Stream Motion (J519 option) - real-time streaming motion control over UDP |
Telnet Property | TelnetConnectParameters | Sends commands to the robot for remote control |
Connect parameters for remote command
| Member | Type | Description |
|---|---|---|
TelnetConnectParameters() Constructor | ||
Enable Property | bool | Should use this service (default: false) |
Memory access parameters
| Member | Type | Description |
|---|---|---|
FtpConnectParameters() Constructor | ||
Enable Property | bool | Should enable memory access for this connection (default: true) |
SNPX parameters
| Member | Type | Description |
|---|---|---|
SnpxConnectParameters() Constructor | ||
Enable Property | bool | Should enable SNPX for this connection (default: false) |
CGTP Web Server connection parameters
| Member | Type | Description |
|---|---|---|
CgtpConnectParameters() Constructor | ||
Enable Property | bool | Should enable CGTP Web Server for this connection (default: true) |
RMI parameters
| Member | Type | Description |
|---|---|---|
RmiConnectParameters() Constructor | ||
Enable Property | bool | Should enable RMI for this connection (default: false) |
Stream Motion connection parameters (J519 option)
| Member | Type | Description |
|---|---|---|
StreamMotionConnectParameters() Constructor | ||
Enable Property | bool | Should enable Stream Motion for this connection (default: false) |
Ip Property | string | IP address of the robot for standalone Stream Motion connections |