Filter Targets using the API

The following code is an example Python script that uses the RoboDK API to filter a target (pose target or joint target), using the FilterTarget command:

pose_filt, joints = robot.FilterTarget(nominal_pose, estimated_joints)

This example is useful if a 3rd party application (other than RoboDK) generates the robot program using pose targets.

from robolink import*# API to communicate with RoboDK

from robodk import*# basic matrix operations


return KUKA_2_Pose(xyzwpr) # Convert X,Y,Z,A,B,C to a pose


return Pose_2_KUKA(pose) # Convert a pose to X,Y,Z,A,B,C

# Start the RoboDK API and retrieve the robot:

RDK = Robolink()

robot = RDK.Item('', ITEM_TYPE_ROBOT)

ifnot robot.Valid():

raise Exception("Robot not available")

pose_tcp = XYZWPR_2_Pose([0,0,200,0,0,0]) # Define the TCP

pose_ref = XYZWPR_2_Pose([400,0,0,0,0,0]) # Define the Ref Frame

# Update the robot TCP and reference frame



# Very important for SolveFK and SolveIK (Forward/Inverse kinematics)

robot.setAccuracyActive(False)# Accuracy can be ON or OFF

# Define a nominal target in the joint space:

joints =[0,0,90,0,90,0]

# Calculate the nominal robot position for the joint target:

pose_rob = robot.SolveFK(joints) # robot flange wrt the robot base

# Calculate pose_target: the TCP with respect to the reference frame

pose_target = invH(pose_ref)*pose_rob*pose_tcp

print('Target not filtered:')


joints_approx = joints # joints_approx must be within 20 deg

pose_target_filt, real_joints = robot.FilterTarget(pose_target, joints)

print('Target filtered:')