After creating an instance UR
of your cobot, you need to call the Connect method to initiate communication with the robot.
This method takes as parameter a ConnectParameters
object which describes the functionalities to be activated and the parameters of each feature.
The Connect()
method can throw a InvalidLicenseException
if your trial period is over or if your license key is invalid.
Please refer to the specific page for each protocol to understand the parameters.
using UnderAutomation.UniversalRobots;using UnderAutomation.UniversalRobots.Common;using UnderAutomation.UniversalRobots.Rtde;using UnderAutomation.UniversalRobots.SocketCommunication;public class Connect{static void Main(string[] args){// Create a new robot instancevar robot = new UR();// Create parameters and enable all services you needvar parameters = new ConnectParameters("192.168.0.1");// Enable Primary Interfaceparameters.PrimaryInterface.Enable = true;// Select exchanged dataparameters.Rtde.Enable = true;parameters.Rtde.Frequency = 500; // Hzparameters.Rtde.InputSetup.Add(RtdeInputData.InputDoubleRegisters, 42);parameters.Rtde.InputSetup.Add(RtdeInputData.StandardAnalogOutput0);parameters.Rtde.OutputSetup.Add(RtdeOutputData.ActualTcpPose);parameters.Rtde.OutputSetup.Add(RtdeOutputData.ActualTcpSpeed);parameters.Rtde.OutputSetup.Add(RtdeOutputData.ActualTcpForce);parameters.Rtde.OutputSetup.Add(RtdeOutputData.ActualCurrent);parameters.Rtde.OutputSetup.Add(RtdeOutputData.InputIntRegisters, 0);// Enable Dashboard commandsparameters.Dashboard.Enable = true;// XML-RPC server on port 50000parameters.XmlRpc.Enable = true;parameters.XmlRpc.Port = 50000;// Socket server on port 50001parameters.SocketCommunication.Enable = true;parameters.SocketCommunication.Port = 50001;// Enable SSH commands and filesparameters.Ssh.EnableSsh = true;parameters.Ssh.EnableSftp = true;parameters.Ssh.Username = "ur";parameters.Ssh.Password = "easybot";// Connect to the robotrobot.Connect(parameters);//...// Work with library//...robot.Disconnect();}}
public class ConnectParameters {public ConnectParameters()public ConnectParameters(string ip)public DashboardConnectParameters Dashboard { get; set; }public InterpreterModeConnectParameters InterpreterMode { get; set; }public string IP { get; set; }public bool PingBeforeConnecting { get; set; }public PrimaryInterfaceConnectParameters PrimaryInterface { get; set; }public RtdeConnectParameters Rtde { get; set; }public SocketCommunicationConnectParameters SocketCommunication { get; set; }public SshConnectParameters Ssh { get; set; }public XmlRpcConnectParameters XmlRpc { get; set; }}
The Disconnect()
method stops all services.
Visit the Download page to get the latest desktop example.