UnderAutomation
¿Una pregunta?

[email protected]

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

Get the robot position

Read the position of a Yaskawa robot from C# or Python: Cartesian position or joint pulses, which method to choose, and a polling loop. Complete program included.

  • Prerequisites
  • Which method to choose
  • Example
  • Polling period
  • Troubleshooting
  • What to read next

This article shows how to read the position of a Yaskawa Motoman robot from a PC, in C# or Python. It gives a complete program that reads the Cartesian position and the joint pulses, then polls the position 10 times per second.

Prerequisites

  • The SDK is connected to the controller: see Connect to your robot.
  • Nothing else: reading the position works in teach mode and in play mode, without the remote mode.

Which method to choose

NeedMethodUnit
Where the tool is, to log it or to computeGetRobotCartesianPosition()mm and degrees, robot frame
A position to send back with MoveJointsGetRobotJointPosition()Encoder pulses per axis
The load of the axes during a moveGetTorque(), GetPositionError()Percent, pulses
A position taught in a jobReadPositionVariable(n, 1)Raw units of the P variable
A second robot, base axesGetRobotPosition(group)Pulses or raw Cartesian values

Example

using UnderAutomation.Yaskawa;
using UnderAutomation.Yaskawa.HighSpeedEServer;
public class HowToGetPosition
{
static void Main()
{
var robot = new YaskawaRobot();
robot.Connect("192.168.0.1");
// Tool center point in the robot frame: mm and degrees
RobotPositionCartesianData tcp = robot.HighSpeedEServer.GetRobotCartesianPosition();
Console.WriteLine($"X={tcp.X:F3} Y={tcp.Y:F3} Z={tcp.Z:F3} Rx={tcp.Rx:F4} Ry={tcp.Ry:F4} Rz={tcp.Rz:F4}");
Console.WriteLine($"Tool {tcp.ToolNumber}, posture {tcp.Form}");
// Joints: encoder pulses, one value per axis
RobotPositionIntData joints = robot.HighSpeedEServer.GetRobotJointPosition();
Console.WriteLine("Pulses: " + string.Join(", ", joints.Axes));
// Poll the position 10 times per second for 5 seconds
for (int i = 0; i < 50; i++)
{
tcp = robot.HighSpeedEServer.GetRobotCartesianPosition();
Console.WriteLine($"{DateTime.Now:HH:mm:ss.fff} X={tcp.X:F1} Y={tcp.Y:F1} Z={tcp.Z:F1}");
Thread.Sleep(100);
}
robot.Disconnect();
}
}

The program:

  1. reads the Cartesian position of the tool, with its tool number and its posture;
  2. reads the pulses of each axis;
  3. reads the Cartesian position every 100 ms for 5 seconds.

Polling period

Each read is one request and one answer over the network. On a local network, a request takes a few milliseconds: measure it on your cell before you choose the period. Read only what you need in a loop: the Cartesian position alone is one request, the position and the joints are two.

Troubleshooting

  • The values are all 0: check the control group and the number of axes with GetConfigurationInformation.
  • The Cartesian position differs from the pendant: compare the frame and the tool. DataType and ToolNumber give the ones of the answer.
  • The first call fails after a pause: a SocketException means that the controller did not answer before DataTimeoutMilliseconds. Check the network, then call again.

What to read next

  • Positions: the reference of the position methods.
  • Move the robot from a PC.

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

UnderAutomation
ContactosLegal

© All rights reserved.