Get started with .NET
Add the Universal Robots SDK to a C#, VB.NET or F# project from NuGet or from the zip, and write a first program. .NET Framework 3.5 to .NET 10, Windows, Linux and macOS.
This page shows how to add the Universal Robots SDK to a C#, VB.NET or F# project and write a first program for a UR cobot. The SDK is one fully managed DLL, UnderAutomation.UniversalRobots.dll, that uses the standard interfaces of the robot: Primary Interface, RTDE, Dashboard Server, REST API, Interpreter Mode, XML-RPC, sockets, SSH and SFTP.
Supported frameworks
The DLL is compiled in AnyCPU for these targets:
| Family | Versions |
|---|---|
| .NET Framework | 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
| .NET Standard | 2.0, 2.1 |
| .NET Core | 3.0 |
| .NET | 5.0, 6.0, 8.0, 9.0, 10.0 |
.NET and .NET Core run on Windows, Linux and macOS, on x64, x86, ARM and ARM64. For Mono or Universal Windows Platform (UWP), use .NET Standard 2.1. For the Unity engine, use a .NET Framework or a .NET Standard version, or the package of UniversalRobots.Unity.
The only dependency is System.Text.Encoding.CodePages, for the .NET Standard 2.0 DLL. NuGet installs it. The other targets have no dependency. The same API is available on every target.
Supported robots: UR3, UR5, UR10 (CB-Series), UR3e, UR5e, UR7e, UR10e, UR12e, UR16e (e-Series), UR8 Long, UR15, UR18, UR20, UR30, with PolyScope or PolyScope X, and the URSim simulator.
Install the SDK
From NuGet
NuGet picks the right DLL for your project and makes updates easy.
dotnet add package UnderAutomation.UniversalRobots
With the Package Manager console of Visual Studio:
Install-Package UnderAutomation.UniversalRobots
Or right click the Dependencies node of your project, select Manage NuGet Packages..., search for UnderAutomation.UniversalRobots and install the latest version.
Package page: nuget.org/packages/UnderAutomation.UniversalRobots
Or download the DLL
The latest release of the GitHub repository UniversalRobots.NET contains:
- UnderAutomation.UniversalRobots.zip: the DLL and its XML documentation, in one folder per target (
net48,netstandard2.0,net8.0...). Reference the DLL of your target in your project. - UnderAutomation.UniversalRobots.Showcase.Forms.exe: the demo application for Windows. See Demo application.
- The console demo for Windows, Linux and macOS: see Try the SDK on Linux and macOS below.
On Windows, a downloaded file can be blocked. Before you extract the zip, right click it, open Properties, check Unblock and click OK. A blocked DLL can fail to load.
First program
Import the namespace UnderAutomation.UniversalRobots, create a UR, connect and read a value.
static void Main(string[] args){// Only after the 30 day trial: register your license key// UR.RegisterLicense("YourCompanyName", "YOUR_LICENSE_KEY");var robot = new UR();// Connect with the default services: Primary Interface and Dashboard Serverrobot.Connect("192.168.0.1");// The Primary Interface receives the state of the robot at 10 HzThread.Sleep(500);// Cartesian position of the tool, in meters and radiansvar pose = robot.PrimaryInterface.CartesianInfo.AsPose();Console.WriteLine($"X={pose.X} Y={pose.Y} Z={pose.Z}");// Mode of the robot, read with the Dashboard Servervar mode = robot.Dashboard.GetRobotMode();Console.WriteLine($"Robot mode: {mode.Value}");robot.Disconnect();}}
The SDK runs for 30 days without a key. After that, RegisterLicense is needed: see Licensing.
Connect("192.168.0.1") opens the Primary Interface and the Dashboard Server. The other interfaces are enabled with a ConnectParameters, and some must be enabled on the robot first: see Connect to the robot.
Demo application
The demo application is a Windows program that calls every interface of the SDK, without writing code. It is a single executable, with no installation. Its C# sources are in the folder UnderAutomation.UniversalRobots.Showcase.Forms of UniversalRobots.NET, and a VB.NET version is in UnderAutomation.UniversalRobots.Showcase.Forms.vb. See Demo application.
Try the SDK on Linux and macOS
A console demo, built for 6 platforms, connects to a robot and prints its data in a terminal. Each file is self contained: the .NET runtime is not needed.
On Linux and macOS, make the file executable before you run it:
chmod +x UnderAutomation.UniversalRobots.Showcase.Console.linux-x64./UnderAutomation.UniversalRobots.Showcase.Console.linux-x64
Its sources are in the folder UnderAutomation.UniversalRobots.Showcase.Console of UniversalRobots.NET.
Shell sources
The folder UnderAutomation.UniversalRobots.ObfuscatedSources of UniversalRobots.NET contains every public type and member of the SDK, with its XML documentation. The bodies of the methods are replaced by "Source is hidden". Use it to:
- browse the API and its documentation on GitHub, without installing anything;
- jump to a definition from your code editor, with the same names and signatures as the DLL;
- see the structure of the code that the source license delivers.
Source license
The Standard and Pro licenses deliver the obfuscated DLL. The Source license delivers the full C# code of the library and its Visual Studio solution. You can change it and build it yourself, within the limits of the license agreement. See the licenses on the pricing page and Licensing.
What to read next
- Connect to the robot: the settings of the robot, the connection parameters, the errors.
- Develop without a robot: install URSim.
- RTDE and Primary Interface: the data of the robot.
- API reference: the shell sources.