Start, stop and select a robot program from a PC
Select, start and pause a program on Fanuc, Yaskawa, Universal Robots, ABB and Stäubli controllers with one code, and stop it where the controller has a stop: program names and modes of each brand, C# and Python examples.
This article shows how to select, start and pause a robot program from a PC on Fanuc, Yaskawa, Universal Robots, ABB and Stäubli controllers, and stop it where the controller has a stop, with one code in C# or Python. Only the address of the controller and the native name of the program change from one brand to another: the table at the end gives the names and the modes of each brand.
Prerequisites
- UnderAutomation.Robotics in your project. See Get started with .NET or Get started with Python.
- The connection settings of each controller. See Connect to your robot.
- The license of each brand you connect, or the 30 day trial. See Licensing.
- The program is on the controller. To send it from the PC, see Transfer files.
- The mode of the controller that accepts a start from the network, and the servo power when the program moves the robot. See the table at the end and State.
- A program that you start moves the robot as if the operator started it. Keep the cell safe: nobody in the working area, a person at the emergency stop for the first tests.
Brand support
Each cell gives the protocol that the method uses on this brand, in the default order. The table is generated from the route data of the library. "Not available" means that the brand has no route for the method: the call throws FeatureNotSupportedException, and IsAvailable returns false before the call. (manual) marks a route that you enable yourself in the connection parameters.
| Method | Fanuc | Yaskawa | Universal Robots | ABB | Stäubli |
|---|---|---|---|---|---|
| Program.List | CGTP (Cgtp), FTP | High Speed Ethernet Server, Ethernet Server, FTP | SFTP | Robot Web Services | SOAP, Files |
| Program.Select | CGTP (Cgtp) | High Speed Ethernet Server, Ethernet Server | Dashboard Server, REST API | Robot Web Services | SOAP |
| Program.Start | CGTP (Cgtp), CGTP (CgtpKcl), Telnet | High Speed Ethernet Server, Ethernet Server | Dashboard Server, REST API | Robot Web Services | SOAP |
| Program.Pause | CGTP (Cgtp), CGTP (CgtpKcl), Telnet | High Speed Ethernet Server, Ethernet Server | Dashboard Server, REST API | Robot Web Services | SOAP |
| Program.Resume | CGTP (CgtpKcl), Telnet | High Speed Ethernet Server, Ethernet Server | Dashboard Server, REST API | Robot Web Services | SOAP |
| Program.Stop | CGTP (Cgtp), CGTP (CgtpKcl), Telnet | Not available | Dashboard Server, REST API | Robot Web Services | SOAP |
| Program.ReadExecution | SNPX, CGTP (CgtpKcl), Telnet, FTP | High Speed Ethernet Server, Ethernet Server | Dashboard Server, REST API | Robot Web Services | SOAP |
| Methods of this article | 7 of 7 | 6 of 7 | 7 of 7 | 7 of 7 | 7 of 7 |
Example
Start a program on each controller of a cell
The example connects to the controllers of a cell one after the other. It selects a program, starts it, reads the execution state, then stops it. Select selects the program, so that Start without a name starts it. ReadExecution returns one ProgramExecution per task: the program, the line and the status.
A brand without Stop returns false for IsAvailable(ProgramFeature.Stop). The example then calls Pause, which keeps the program at its line.
static void Main(){// One line per controller: the brand, the address and the native name of a programvar cell = new[]{(Brand: "fanuc", Address: "192.168.0.1", Program: "MAIN"),(Brand: "yaskawa", Address: "192.168.0.2", Program: "TEST"),(Brand: "universalrobots", Address: "192.168.0.3", Program: "main"),(Brand: "abb", Address: "192.168.125.1", Program: "T_ROB1/Module1/main"),(Brand: "staubli", Address: "192.168.0.254", Program: "myApp"),};foreach (var controller in cell){// The same code for each controller of this cellRobotController robot = new RobotController();robot.Connect(RobotConnectionParameters.Create(controller.Brand, controller.Address));// ABB: take the RAPID mastership with the ABB SDK through robot.Native before the startrobot.Program.Select(controller.Program);robot.Program.Start();foreach (ProgramExecution execution in robot.Program.ReadExecution())Console.WriteLine($"{robot.Brand} {execution.Program}, line {execution.Line}, {execution.Status}");// A brand without Stop: Pause keeps the program at its lineif (robot.Program.IsAvailable(ProgramFeature.Stop))robot.Program.Stop();elserobot.Program.Pause();robot.Disconnect();}}}
In Python, the names are in snake_case: robot.program.select(...), robot.program.read_execution(), robot.program.is_available(...). An empty name (start("")) starts the selected program.
List the programs
List returns the programs of the controller. On ABB, it lists the modules of each task, and Select takes a routine of a module.
RobotController robot = new RobotController();robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));foreach (RobotProgramInfo program in robot.Program.List())Console.WriteLine($"{program.Name} {program.Comment}");robot.Disconnect();}
What changes from one brand to another
The code does not change. The name of the program follows the syntax of the controller, and each controller has its own conditions for a start from the network.
| Brand | Native name | Example | Conditions on the controller | Brand article |
|---|---|---|---|---|
| Fanuc | Name of the program, as the pendant shows it. | MAIN | Remote control enabled on the controller: the system variables $RMT_MASTER and $REMOTE_CFG.$REMOTE_TYPE set to 1. See the brand article. | Run a program remotely |
| Yaskawa | Name of the job, without extension. | TEST | Remote mode and play mode to select and start a job. The controller has no remote abort of a job: Stop is not available, Pause holds the job. | Run a program |
| Universal Robots | Name or path of the .urp program, without extension. | main | On e-Series and PolyScope X, the robot is in remote control. | Run a program |
| ABB | Routine to start: task, module and routine, or module and routine in the first motion task. | T_ROB1/Module1/main, Module1/main | Automatic mode, and the RAPID mastership taken with the ABB SDK through robot.Native. See Mastership. | Start and stop a RAPID program |
| Stäubli | Name of the VAL 3 application, or its project path. | myApp, Disk://myApp/myApp.pjx | The user of the connection can start applications. Select loads the application, Start starts it. | Run a program |
The page Program gives the other methods: start at a line, cycle mode, hold, stop of one task, positions of a program. Their support depends on the brand.
Errors
FeatureNotSupportedException: the brand has no route for the method, for exampleStopon Yaskawa.RouteUnavailableException: the method has routes, but none can be used, for example because the protocol did not answer at the connection.ControllerRefusedException: the controller received the command and refused it, for example because it is not in the right mode. The connection is still good.RobotControllerException: the route failed. Its inner exception is the exception of the brand SDK.
The page Errors explains each exception.
What to read next
- Program: every method of the Program service.
- Monitor the state of a robot controller: follow the mode, the servo power and the execution.
- Read and reset robot alarms: restart after an alarm.