Why doesn't inverse kinematics work through API in this case?
Code:
import numpy as np
from robodk.robomath import transl, rotx, roty, rotz, Mat
from robodk.robolink import Robolink, ITEM_TYPE_ROBOT
# TM
def pose_from_xyzrxryrz(x, y, z, rx, ry, rz):
return transl(x*1000, y*1000, z*1000) * rotx(rx) * roty(ry) * rotz(rz)
# End-effector pose
x, y, z = -0.11098, -0.30368, 0.12402 #m
rx, ry, rz = 2.303, -2.178, -0.035 #rad
pose = pose_from_xyzrxryrz(x, y, z, rx, ry, rz)
print("MT (End-Effector):\n", pose)
RDK = Robolink(args=['-NOUI']) #RoboDK witout GUI
project_path = r'C:\Users\andre\Desktop\UR3.rdk' # UR3 path
if not RDK.AddFile(project_path):
raise Exception(f"Could not load project file: {project_path}")
#UR5
ROBOT = RDK.Item('UR3', ITEM_TYPE_ROBOT)
if not ROBOT.Valid():
raise Exception("No valid robot selected!")
#INVKIN
joints = ROBOT.SolveIK(pose)
if joints is None:
raise Exception("No solution found for the given pose!")
print("Joint Angles (IK Solution):", joints)