Python API for returning position

Hi there

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

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

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).