UnderAutomation
有问题吗?

[email protected]

联系我们
UnderAutomation
⌘Q
本页面仅提供英文版本。

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.

  • Which way to choose
  • Prerequisites
  • Example
  • Notes
  • Troubleshooting
  • What to read next

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

TaskSDK
List the programsSFTP EnumeratePrograms(), EnumerateInstallations(), ListDirectory()
Download, upload a fileSFTP DownloadFile(), UploadFile()
Load a program sent by SFTPDashboard Server LoadProgram(), REST API LoadProgram()
Read or change a program on the PCURProgram.Load(), URInstallation.Load()
Archive a folder on the robotSSH 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: root on a robot, ur on URSim, password easybot by 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 URSim
const 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 URSim
parameters.Ssh.Password = "easybot";
// Primary Interface and Dashboard Server stay enabled, to load the program
robot.Connect(parameters);
// 1. Backup: copy the programs folder of the robot to the PC
string backup = Path.Combine(@"C:\backups", DateTime.Now.ToString("yyyyMMdd-HHmmss"));
Download(robot, RobotPrograms, backup);
// 2. Send a program and its installation to the robot
robot.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 PolyScope
var 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 subfolders
static 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);
else
robot.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.
  • UploadFile replaces 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 LoadProgram again.

Troubleshooting

  • ConnectException for SFTP: Secure Shell is disabled, or the user or the password is wrong (the inner exception is then an SshAuthenticationException). On a robot, the user is root.
  • SftpPathNotFoundException: the folder does not exist. On URSim, the programs are in /home/ur/ursim-current/programs.
  • LoadProgram fails: 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.

轻松将 Universal Robots、Fanuc、Yaskawa、ABB 或 Staubli 机器人集成到您的 .NET、Python、LabVIEW 或 Matlab 应用程序中

UnderAutomation
联系我们Legal

© All rights reserved.