Robot Web Services overview
Robot Web Services (RWS) is the REST interface of ABB robot controllers. One API covers RWS 1.0 on IRC5 and RWS 2.0 on OmniCore.
Robot Web Services (RWS) is the HTTP interface an ABB controller exposes on the network. The SDK wraps it in nine services, reachable from robot.Rws once the connection is open. Nothing has to be installed on the robot.
Quick tour
Every service is a property of robot.Rws. Read operations need no special right, they only need a valid user account.
// Identity of the controller and version of the system it runsConsole.WriteLine(robot.Rws.Controller.GetIdentity().Name);Console.WriteLine(robot.Rws.System.GetInfo().VersionName);// Operation mode and motors stateConsole.WriteLine(robot.Rws.Panel.GetOperationMode());Console.WriteLine(robot.Rws.Panel.GetControllerState());// RAPID tasks and their execution stateforeach (RapidTaskItem task in robot.Rws.Rapid.GetTasks())Console.WriteLine($"{task.Name} : {task.ExecutionState}");// I/O signalsforeach (IoSignalItem signal in robot.Rws.Io.GetSignals())Console.WriteLine($"{signal.Name} = {signal.LogicalValue}");// Current position of the robotConsole.WriteLine(robot.Rws.MotionSystem.GetRobTarget("ROB_1"));
The nine services
| Service | What it does | Page |
|---|---|---|
robot.Rws.Controller | Controller identity, clock and time zone, network configuration, restart, backup and restore, safety state | Controller |
robot.Rws.Panel | Operation mode, motors on and off, speed ratio, collision detection | Control panel |
robot.Rws.Rapid | RAPID tasks, program execution, modules, variables and symbols | RAPID tasks |
robot.Rws.Io | Digital, analog and group signals, I/O devices and networks | I/O |
robot.Rws.MotionSystem | Robot position, jogging, kinematics, mechanical units, calibration | Motion system |
robot.Rws.File | File system of the controller, download and upload | File system |
robot.Rws.Elog | Event log of the controller | Event log |
robot.Rws.Mastership | Write lock of the controller | Mastership |
robot.Rws.System | System version, options, products, robot types, energy counters | System |
The RAPID service is large, so it is documented on three pages: tasks and execution, variables and symbols, modules and programs.
Two versions, one API
RWS exists in two versions. RWS 1.0 runs on IRC5 controllers with RobotWare 6, RWS 2.0 on OmniCore controllers with RobotWare 7. The version is chosen at connection time with the RwsVersion enum, and the SDK handles the differences internally.
Your code stays the same on both. A few operations only exist on one of the two, they are marked on each page with an availability badge. See IRC5 or OmniCore: which RWS version for the comparison.
Mastership, the write lock
Reading is always allowed. Writing is not: the controller gives the right to change a domain to one client at a time, and this right is called the mastership. Take it before a write, give it back right after, so the operator can still use the teach pendant. A write attempted without it fails with the HTTP status code 403.
// Reading never needs the mastershipvar value = robot.Rws.Rapid.GetSymbolValue("RAPID/T_ROB1/user/reg1");// Writing does. Take it as late as possible and give it back in a finally blockrobot.Rws.Mastership.Request(MastershipDomain.Rapid);try{robot.Rws.Rapid.SetSymbolValue("RAPID/T_ROB1/user/reg1", "5");}finally{robot.Rws.Mastership.Release(MastershipDomain.Rapid);}
Two calls take the mastership for you, Panel.SetSpeedRatio and Controller.Restart. The full rules are on the Mastership page.
Errors
Every failure of an RWS call is reported as an RwsException. It carries the HTTP status code in StatusCode, and the error the controller described in RwsErrorCode, RwsErrorMessage and ResponseBody.
try{robot.Rws.Io.SetSignalValue("Local", "PANEL", "DO_Gripper", 1);}catch (RwsException ex){// StatusCode is the HTTP status code the controller answeredif (ex.StatusCode == 403)Console.WriteLine("Mastership is held elsewhere, or the user account lacks the grant");else if (ex.StatusCode == 404)Console.WriteLine("This signal does not exist on this controller");elseConsole.WriteLine($"RWS error {ex.StatusCode} : {ex.RwsErrorMessage}");}
| Status | Usual meaning |
|---|---|
| 400 | The controller refused the value, for example a speed ratio out of range |
| 403 | Mastership is held elsewhere, or the user account lacks the UAS grant |
| 404 | The resource does not exist on this controller, often a wrong RwsVersion |
| 500 | The controller could not run the operation in its current state |
| 503 | The controller has no free session left |
A parsing failure is reported as an RwsException too, so a single catch covers the whole SDK.
Synchronous and asynchronous
Every service method exists twice. The synchronous version is always available. The asynchronous one has the same name followed by Async, returns a Task and takes an optional CancellationToken.
// Synchronous, available on every target frameworkvar options = robot.Rws.System.GetOptions();// Asynchronous, same name with the Async suffix and an optional cancellation tokenvar products = await robot.Rws.System.GetProductsAsync();using (var cts = new CancellationTokenSource(TimeSpan.FromSeconds(5))){var energy = await robot.Rws.System.GetEnergyAsync(cts.Token);Console.WriteLine(energy.AccumulatedEnergy);}
The asynchronous methods are not compiled for .NET Framework 3.5 and 4.0, which have no async and await. Everything else works on those versions.
Sessions
Each connection uses one session on the controller. An OmniCore accepts around 70 of them at the same time. An application that connects in a loop without calling Disconnect exhausts them, and every following request then answers 503. Connect once, keep the object, disconnect when your application closes.