UnderAutomation
¿Una pregunta?

[email protected]

Contactos
UnderAutomation
⌘Q
Esta página solo está disponible en inglés.

Run a program

Power on a UR cobot, release the brakes, load a program and play it from a PC in C# or Python, then follow it until its end.

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

This article shows how to start a program of a Universal Robots cobot from a PC, in C# or Python, and follow it until its end. It gives a complete program: check the remote control, power on, release the brakes, load the program, play it.

Which way to choose

WayRobotsWhat it runsFollow it with
Dashboard ServerCB-Series, e-SeriesA .urp program saved on the robotGetProgramState(), IsProgramRunning()
REST APIPolyScope XA program saved on the robotGetProgramState()
URScriptAllURScript sent by the PC, without a .urp fileRobotModeData.ProgramRunning

The Dashboard Server and the REST API run the programs made in PolyScope: the operator sees them and can stop them. URScript suits a short sequence generated by the PC. See Send URScript.

Prerequisites

  • The service Dashboard Server is enabled (PolyScope 5), or the robot runs PolyScope X: see Prepare the robot.
  • The robot is in remote control.
  • The program exists on the robot. To send it from the PC, see Transfer files and backups.

Steps

StepDashboard ServerREST API (PolyScope X)
Check the remote controlIsInRemoteControl()
Power onPowerOn(), wait for IdlePowerOn()
Release the brakesReleaseBrake(), wait for RunningBrakeRelease()
Load the programLoadProgram("name.urp")LoadProgram("name")
PlayPlay()Play()
FollowGetProgramState()GetProgramState()
Pause, stopPause(), Stop()Pause(), Resume(), Stop()

Example

The program uses the Dashboard Server. For PolyScope X, the same steps are in REST API.

using UnderAutomation.UniversalRobots;
using UnderAutomation.UniversalRobots.Common;
using UnderAutomation.UniversalRobots.Dashboard;
class HowToRunProgram
{
static void Main(string[] args)
{
var robot = new UR();
// Primary Interface and Dashboard Server
robot.Connect("192.168.0.1");
// e-Series: the robot must be in remote control
if (!robot.Dashboard.IsInRemoteControl().Value)
{
Console.WriteLine("Switch the robot to remote control on the teach pendant");
return;
}
// Power on, then release the brakes
robot.Dashboard.PowerOn();
WaitForMode(robot, RobotModes.Idle);
robot.Dashboard.ReleaseBrake();
WaitForMode(robot, RobotModes.Running);
// Load the program: a path relative to the programs folder, or absolute
var load = robot.Dashboard.LoadProgram("pick_and_place.urp");
if (!load.Succeed)
{
Console.WriteLine(load.Message);
return;
}
robot.Dashboard.Play();
// Follow the program until it stops
while (true)
{
ProgramState state = robot.Dashboard.GetProgramState().Value;
Console.WriteLine(state.Name + ": " + state.State);
if (state.State == ProgramStates.Stopped) break;
Thread.Sleep(500);
}
robot.Disconnect();
}
static void WaitForMode(UR robot, RobotModes mode)
{
var timeout = DateTime.Now.AddSeconds(30);
while (robot.Dashboard.GetRobotMode().Value != mode)
{
if (DateTime.Now > timeout) throw new TimeoutException("Robot mode is not " + mode);
Thread.Sleep(250);
}
}
}

GetRobotMode() is polled until the arm is powered (Idle), then until the brakes are released (Running). The program state is polled every 500 ms until Stopped.

Troubleshooting

  • LoadProgram fails: the path is wrong. A relative path starts in the programs folder of the robot (/programs).
  • The commands fail with a message about the remote control: switch the robot to remote control on the teach pendant.
  • ReleaseBrake does nothing: the arm is not powered, or a protective stop is active. See Read and reset alarms.
  • The program stops at once: the installation of the program is not the loaded installation, or a popup waits on the teach pendant.

What to read next

  • Dashboard Server: the list of the commands.
  • Monitor the state of the robot.

Integre fácilmente robots Universal Robots, Fanuc, Yaskawa, ABB o Staubli en sus aplicaciones .NET, Python, LabVIEW o Matlab

UnderAutomation
ContactosLegal

© All rights reserved.