# Handling Inverse Kinematics error on a UR Robot

We're working on a bigger system that'll use two UR robots as well (although we only have one at the moment for development). We're communicating with the robot through its TCP/IP based RTDE protocol to send parameters like command and desired position. This works perfectly. We're using UR Script's get_inverse_kin() function to convert position (TCP) into joint angles near known ones (e.g. along a prerecorded trajectory or the previous joint values). This also works most of the time.

Sometimes however, we get an error, as the desired position is too far for the robot arm to reach, or the orientation is wrong or the robot doesn't like something else. This wouldn't be a problem, but now a get_inverse_kin() call raises a popup, pauses the robot program, and everything stops.

What is the most civilized way to handle an error like that? We can close the popup and start the robot program again through the dashboard protocol, but we need to recognize it, and it looks like a hack. Also, get_inverse_kin doesn't send the robot to that wrong place, just calculates new joint angles, so stopping everything is wrong in the first place (we could use a try-catch block before the movej if the robot program had one).

Any suggestions?

URScript offers a function to check if a pose is within the currently set safety limits. If there are no safety limits set, it should take into account the default joint limits (i.e. it checks reachability of a pose). The function is is_within_safety_limits(pose). It can be used in an if-condition to check reachability, before calling the IK function. This way no try-catch is needed.