Esta página solo está disponible en inglés.
Transfer files and backups
Copy the programs of a UR cobot to a PC for a backup, send a program to the robot and load it, in C# or Python with SFTP.
This article shows how to copy the programs of a Universal Robots cobot to a PC for a backup, and how to send a program to the robot and load it, in C# or Python. The files are transferred with SFTP, then loaded with the Dashboard Server or the REST API.
Which way to choose
| Task | SDK |
|---|---|
| List the programs | SFTP EnumeratePrograms(), EnumerateInstallations(), ListDirectory() |
| Download, upload a file | SFTP DownloadFile(), UploadFile() |
| Load a program sent by SFTP | Dashboard Server LoadProgram(), REST API LoadProgram() |
| Read or change a program on the PC | URProgram.Load(), URInstallation.Load() |
| Archive a folder on the robot | SSH RunCommand("tar ..."), then SFTP |
The programs are in /programs on a robot, and in /home/ur/ursim-current/programs on URSim. A program uses an installation (.installation): copy both.
Prerequisites
- Secure Shell is enabled on the robot. On PolyScope, open
Settings,Security,Secure Shell. - The Linux user:
rooton a robot,uron URSim, passwordeasybotby default. - To load the program, the robot is in remote control.
Example
The program copies the programs folder of the robot, with its subfolders, into a dated folder of the PC. Then it sends a program and its installation, and loads the program.
using UnderAutomation.UniversalRobots;using UnderAutomation.UniversalRobots.Ssh.Tools.Sftp;class HowToTransferFiles{// /programs on a robot, /home/ur/ursim-current/programs on URSimconst string RobotPrograms = "/programs/";static void Main(string[] args){var robot = new UR();var parameters = new ConnectParameters("192.168.0.1");parameters.Ssh.EnableSftp = true;parameters.Ssh.Username = "root"; // "ur" on URSimparameters.Ssh.Password = "easybot";// Primary Interface and Dashboard Server stay enabled, to load the programrobot.Connect(parameters);// 1. Backup: copy the programs folder of the robot to the PCstring backup = Path.Combine(@"C:\backups", DateTime.Now.ToString("yyyyMMdd-HHmmss"));Download(robot, RobotPrograms, backup);// 2. Send a program and its installation to the robotrobot.Sftp.UploadFile(@"C:\work\pick_and_place.urp", RobotPrograms + "pick_and_place.urp");robot.Sftp.UploadFile(@"C:\work\default.installation", RobotPrograms + "default.installation");// 3. Load it in PolyScopevar load = robot.Dashboard.LoadProgram("pick_and_place.urp");Console.WriteLine(load.Succeed ? "Loaded" : load.Message);robot.Disconnect();}// Copy a folder of the robot and its subfoldersstatic void Download(UR robot, string remoteFolder, string localFolder){Directory.CreateDirectory(localFolder);foreach (SftpFile item in robot.Sftp.ListDirectory(remoteFolder)){if (item.Name == "." || item.Name == "..") continue;string local = Path.Combine(localFolder, item.Name);if (item.IsDirectory)Download(robot, item.FullName + "/", local);elserobot.Sftp.DownloadFile(item.FullName, local);}}}
Notes
- A full backup of the controller (the system, the URCaps, the logs) is made with the backup function of PolyScope, or with a USB key. This article copies the programs and the installations.
UploadFilereplaces a file with the same name. Copy the old file first if you need it.- A program sent while it is loaded in PolyScope is not reloaded: call
LoadProgramagain.
Troubleshooting
ConnectExceptionfor SFTP: Secure Shell is disabled, or the user or the password is wrong (the inner exception is then anSshAuthenticationException). On a robot, the user isroot.SftpPathNotFoundException: the folder does not exist. On URSim, the programs are in/home/ur/ursim-current/programs.LoadProgramfails: the robot is not in remote control, or the path is wrong.
What to read next
- SFTP: the operations of the client.
- Program and installation files: change a program on the PC.
- Run a program.