Python API for returning position

Hi there

Which python API command returns the position coordinates of the robot arm?

1 Like

The end of the arm, each individual link or the current position of the tool center point? You want world or local coordinates?

1 Like

Hello,

is there an API that returns the end of the arm or the current position of the tool center points in any coordinates (world and local)?

Hi @fs3719

Yes. You can get the defined TCPs (Tools) from the robot controller behavior under Tools property.

This example gives the position of the first defined TCP (index 0) in the flange node coordinates and world coordinates:

comp = getComponent()
rc = comp.findBehavioursByType(VC_ROBOTCONTROLLER)[0]
tool = rc.Tools[0]
tool_node_mtx = tool.PositionMatrix
tool_world_mtx = tool.Node.WorldPositionMatrix * tool_node_mtx

print "Node position", tool_node_mtx.P.X, tool_node_mtx.P.Y, tool_node_mtx.P.Z
print "World position", tool_world_mtx.P.X, tool_world_mtx.P.Y, tool_world_mtx.P.Z

In order to get the orientation, use e.g. the WPR property of the matrix: tool_world_mtx.WPR.X or get all rotations with tool_world_mtx.getWPR()

 

Note: if you’re doing this while the TCP is moving, call tool.Node.update() before getting the WorldPositionMatrix (it will refresh the location info).

2 Likes

Hy,

Is this true for getWPR()?

And do getWPR() return Intrinsic or Extrinsic Rotations and in which Rotation Order?

What does the “W” stands for in WPR? W=“?”, P=“Pitch”, R=“Roll”

Refer to: Geht transformation-rotation in Tait–Bryan angles

Thx & Regards
Feature

WPR is the same what e.g. Fanuc and Yaskawa uses. It’s the absolute rotations around the axes (order can vary, in VC it’s XYZ) in the reference coordinates i.e. using static axes (the base frame). Euler is defined as relative, consecutive rotations (i.e. the coordinate axes change after each rotation) and the order also varies, in VC it’s ZYZ.

1 Like