Transfer files to and from a robot controller
List, download and upload the files of Fanuc, Yaskawa, Universal Robots, ABB and Stäubli controllers with one code: paths and file services of each brand, C# and Python examples.
This article shows how to list the files of Fanuc, Yaskawa, Universal Robots, ABB and Stäubli controllers and transfer them to and from a PC, with one code in C# or Python. Only the address of the controller and the paths change from one brand to another: the table at the end gives the paths and the settings 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, with the file service of the controller enabled. See Connect to your robot and the table at the end.
- The license of each brand you connect, or the 30 day trial. See Licensing.
- On most controllers, an upload replaces the file of the same path (Yaskawa does not replace an existing job, see the table at the end). Keep a copy of the files of the controller before you upload, and do not replace a program that runs.
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.
| Method | Fanuc | Yaskawa | Universal Robots | ABB | Stäubli |
|---|---|---|---|---|---|
| File.List | FTP, CGTP (Cgtp) | FTP, High Speed Ethernet Server, HTTP | SFTP | Robot Web Services | Files |
| File.Download | FTP | FTP, High Speed Ethernet Server, HTTP | SFTP | Robot Web Services | Files |
| File.Upload | FTP | FTP, High Speed Ethernet Server | SFTP | Robot Web Services | Files |
| File.Delete | FTP | FTP, High Speed Ethernet Server | SFTP | Robot Web Services | Files |
| File.Exists | FTP | FTP | SFTP | Robot Web Services | Files |
| Methods of this article | 5 of 5 | 5 of 5 | 5 of 5 | 5 of 5 | 5 of 5 |
Example
List a directory and download a file on each controller of a cell
The example connects to the controllers of a cell one after the other. It lists one directory, then downloads one file to the PC. List returns a RemoteFileInfo per file and directory: IsDirectory, Size and FullPath, a path that you can give to the other methods. Download writes the file of the controller to a local file, and replaces the local file when it exists.
static void Main(){// One line per controller: the brand, the address, a directory and a file, in the native syntax of the controllervar cell = new[]{(Brand: "fanuc", Address: "192.168.0.1", Directory: "md:/", File: "md:/MAIN.TP"),(Brand: "yaskawa", Address: "192.168.0.2", Directory: "/JOB", File: "/JOB/TEST.JBI"),(Brand: "universalrobots", Address: "192.168.0.3", Directory: "/programs", File: "/programs/main.urp"),(Brand: "abb", Address: "192.168.125.1", Directory: "$home", File: "$home/main.mod"),(Brand: "staubli", Address: "192.168.0.254", Directory: "/usr/usrapp", File: "/usr/usrapp/myApp/myApp.pjx"),};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));foreach (RemoteFileInfo file in robot.File.List(controller.Directory))Console.WriteLine($"{robot.Brand} {(file.IsDirectory ? "[dir]" : file.Size + " bytes")} {file.FullPath}");// Copy of the file on the PC, for example C:\Temp\Fanuc_MAIN.TPstring local = Path.Combine(@"C:\Temp", robot.Brand + "_" + Path.GetFileName(controller.File));robot.File.Download(controller.File, local);robot.Disconnect();}}}
In Python, the names are in snake_case: robot.file.list(...), robot.file.download(...), robot.file.upload(...).
Upload a file
Upload writes a local file on the controller. This example uses the path of a Fanuc controller: on another brand, give a path of the table below.
RobotController robot = new RobotController();robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));// Replaces the file when it existsrobot.File.Upload(@"C:\Temp\MAIN.TP", "md:/MAIN.TP");robot.Disconnect();}
ReadBytes and WriteBytes do the same with the content in memory. The page File gives the other methods: text files, delete, rename, directories and the progress of a transfer.
What changes from one brand to another
The code does not change. The paths follow the syntax of the controller, and each controller has its own file service.
| Brand | Paths | Examples | Settings | Brand article |
|---|---|---|---|---|
| Fanuc | Device and path of the controller. | md:/, md:/MAIN.TP | The FTP server of the controller. | Upload, download and back up files |
| Yaskawa | Folder of the type of file, then the file name. | /JOB, /JOB/TEST.JBI | The FTP function of the controller, or the High Speed Ethernet Server. The controller does not replace an existing job: delete it first. No rename of a file, and no directory to create or delete. | Transfer files |
| Universal Robots | Linux path of the controller. | /programs, /programs/main.urp | SFTP, with the SSH user and password of the robot. | Transfer files |
| ABB | Path of the controller, from $home. | $home, $home/main.mod | The user of the connection has the grants to write files, for an upload or a delete. | Back up and restore a controller |
| Stäubli | Path of the controller. On a controller emulated by Stäubli Robotics Suite, the same paths in the folder of the controller. | /usr/usrapp, /usr/usrapp/myApp/myApp.pjx | The FTP server of the controller. | Transfer files |
Errors
FeatureNotSupportedException: the brand has no route for the method.RouteUnavailableException: the method has routes, but none can be used, for example because the file service did not answer at the connection.ControllerRefusedException: the controller received the command and refused it.RobotControllerException: the route failed. Its inner exception is the exception of the brand SDK.
The page Errors explains each exception.
What to read next
- File: every method of the File service.
- Start, stop and select a robot program: start a program that you uploaded.
- Work without a robot: test the transfers on a simulator.