UnderAutomation
質問ですか?

[email protected]

お問い合わせ
UnderAutomation
⌘Q
このページは英語でのみ提供されています。

Move a robot from a PC in C# and Python

Move Fanuc, Yaskawa, Universal Robots, ABB and Stäubli robots to a Cartesian target with one code: what each controller needs before a move, safety, C# and Python examples.

  • Prerequisites
  • Safety
  • Brand support
  • Example
  • Move each robot of a cell to a Cartesian target
  • Move along a line
  • Stop the motion
  • What changes from one brand to another
  • Errors
  • What to read next

This article shows how to move a Fanuc, Yaskawa, Universal Robots, ABB or Stäubli robot from a PC to a Cartesian target, with one code in C# or Python. The code of the move does not change from one brand to another. What changes is what each controller needs before it accepts a move from the network: the table at the end gives it.

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 servo power on, see State, and the mode that accepts a move from the network on each controller. See the table at the end.
  • The route of the moves enabled when it is marked (manual) in the table below. Until then, a move throws RouteUnavailableException, and its message says what to enable.

Safety

The moves move the robot. A robot is dangerous machinery. Test your code on a simulator or an emulator first, then on the real robot with low speeds and a person at the emergency stop. The safety of the controller applies as for any remote command. StopMotion does not replace the emergency stop. The SDK does not replace a safety system: see the Legal notice.

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.

Motion
MethodFanucYaskawaUniversal RobotsABBStäubli
Motion.MoveJointRMI (manual)Not availablePrimary Interface (Script), Interpreter Mode (manual)Robot Web ServicesSOAP
Motion.MoveJointToPoseRMI (manual)High Speed Ethernet Server, Ethernet ServerPrimary Interface (Script), Interpreter Mode (manual)Robot Web ServicesSOAP
Motion.MoveLinearRMI (manual)High Speed Ethernet Server, Ethernet ServerPrimary Interface (Script), Interpreter Mode (manual)Robot Web ServicesSOAP
Motion.MoveLinearToJointsRMI (manual)Not availablePrimary Interface (Script), Interpreter Mode (manual)Robot Web ServicesSOAP
Motion.StopMotionRMI (manual)High Speed Ethernet Server, Ethernet ServerPrimary Interface (Script), Dashboard ServerRobot Web ServicesSOAP
Motion.WaitForMotionEndRMI (manual)High Speed Ethernet Server, Ethernet ServerDashboard Server, Primary Interface (Primary)Robot Web ServicesNot available
Methods of this article6 of 64 of 66 of 66 of 65 of 6

Example

Move each robot of a cell to a Cartesian target

The example connects to the controllers of a cell one after the other. It reads the current position, raises it by 50 mm and moves there with a joint interpolation at 10 % of the maximum speed. MoveJointToPose returns when the controller accepted the motion, without waiting for its end. WaitForMotionEnd waits for it on the brands that have it. On a brand without it, the example reads the position until it reaches the target.

The parameters of the brand give the settings of the moves. On Fanuc, the example enables RMI, the only route of the moves.

static void Main()
{
// Fanuc: RMI is the only route of the moves, and the library never opens it by itself
UnderAutomation.Fanuc.ConnectionParameters fanuc = new UnderAutomation.Fanuc.ConnectionParameters("192.168.0.1");
fanuc.Rmi.Enable = true;
RobotConnectionParameters[] cell =
{
fanuc,
new UnderAutomation.Yaskawa.ConnectParameters("192.168.0.2"),
new UnderAutomation.UniversalRobots.ConnectParameters("192.168.0.3"),
new UnderAutomation.ABB.ConnectionParameters("192.168.125.1"),
new UnderAutomation.Staubli.ConnectionParameters("192.168.0.254"),
};
foreach (RobotConnectionParameters parameters in cell)
{
// The same code for each controller of this cell
RobotController robot = new RobotController();
robot.Connect(parameters);
// ABB: take the RAPID mastership with the ABB SDK through robot.Native before the move
// 50 mm up from the current position, joint interpolation at 10 % of the maximum speed
RobotPosition target = robot.Motion.ReadPose();
target.Pose.Z += 50;
robot.Motion.MoveJointToPose(target, new MotionSpeed { Percent = 10 });
if (robot.Motion.IsAvailable(MotionFeature.WaitForMotionEnd))
{
robot.Motion.WaitForMotionEnd(30000);
}
else
{
// No end of motion on this brand: wait until Z reaches the target, 30 s at most
for (int i = 0; i < 300 && Math.Abs(robot.Motion.ReadPose().Pose.Z - target.Pose.Z) > 0.5; i++)
Thread.Sleep(100);
}
robot.Disconnect();
}
}
}
Click to see the full code

In Python, the names are in snake_case: robot.motion.move_joint_to_pose(target, speed), robot.motion.wait_for_motion_end(30000), robot.motion.is_available(...).

Move along a line

MoveLinear moves the tool center point along a line to a Cartesian position. Linear of the MotionSpeed is the speed of the tool center point in mm/s. MoveLinearToJoints does it to a joint position, on the brands that have it.

RobotController robot = new RobotController();
robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));
RobotPosition target = robot.Motion.ReadPose();
target.Pose.Z += 50;
// Linear interpolation: tool center point at 100 mm/s
MotionSpeed speed = new MotionSpeed { Linear = 100 };
robot.Motion.MoveLinear(target, speed);
robot.Motion.WaitForMotionEnd(30000);
// Same move to joint values
robot.Motion.MoveLinearToJoints(new JointValues(0, 0, 0, 0, -90, 0), speed);
robot.Disconnect();
}
Click to see the full code

Stop the motion

StopMotion stops a motion that was started by the moves of the library.

RobotController robot = new RobotController();
robot.Connect(RobotConnectionParameters.Create("fanuc", "192.168.0.1"));
robot.Motion.StopMotion();
robot.Disconnect();
}
Click to see the full code

What changes from one brand to another

The code does not change. Each controller has its own conditions for a move from the network. The moves that each brand has are in the support table above.

BrandBefore a moveBrand article
FanucRMI, option R912 of the controller. The library never opens RMI by itself: set Rmi.Enable to true in the connection parameters. RMI takes the motion control of the controller.Move the robot remotely
YaskawaServo power, remote mode and play mode.Move the robot
Universal RobotsOn e-Series and PolyScope X, the robot is in remote control. The default route sends a script: the program that runs on the robot stops.Move the robot
ABBOne RAPID module, UnderAutomationMotion.mod, loaded once in the motion task of the robot, automatic mode, and the RAPID mastership taken with the ABB SDK through robot.Native. Without the module, IsAvailable returns true and a move throws RouteUnavailableException. See Routing.Motion
StäubliRemote mode, and no application that holds the arm. The moves use the flange as the tool and the world as the frame.Move the robot

The page Motion explains the targets, the configuration, the speeds and the joint moves.

Errors

  • FeatureNotSupportedException: the brand has no route for the method, for example MoveJoint on Yaskawa.
  • RouteUnavailableException: the method has routes, but none can be used, for example RMI not enabled on Fanuc, or the RAPID module missing on ABB.
  • ControllerRefusedException: the controller received the move and refused it, for example because it is not in the right mode.
  • RobotControllerException: the route failed. Its inner exception is the exception of the brand SDK. WaitForMotionEnd throws it with an inner TimeoutException when the motion is not finished after the timeout.

The page Errors explains each exception.

What to read next

  • Motion: every method of the Motion service.
  • Get the current position of a robot: read a target before a move.
  • Routing settings: enable a route that is off at start.