Catching Kinematic Error

Dear colleagues,
I am quite new to RAPID programming, so I apologize if my question is too trivial.

I need a mechanism to catch kinematic errors if they happen and continue execution of the program. Example:
MODULE MyModule
VAR bool error_flag := FALSE;

PROC MyProc()
! The following line generates error 50065 “Kinematic error”
MoveAbsJ somewhere_out_of_reach, speed, zone, tool;

! I want the execution to continue here after the error
TPWrite “The show must go on!”, \Bool=error_flag;

ERROR
TPWrite “Hello from error handler!”;
error_flag := TRUE;
TRYNEXT;
ENDPROC
ENDMODULE

However, the ERROR handler is never executed – the program simply stops and an error message is logged.

What am I missing?

I’ve done something similar;

MODULE MyModule
VAR bool error_flag := FALSE;

PROC MyProc()
! Create a temp jointtarget
VAR jointtarget jntReach;

! The jointtarget is crated from the position, somewhere_out_of_reached should be a robtarget

jntReach := CalcJointT(somewhere_out_of_reach, tool\wobj);

! If this point isn’t reachable, error ERR_OUTSIDE_REACH or ERR_ROBLIMIT is raised

MoveAbsJ somewhere_out_of_reach, speed, zone, tool;

! I want the execution to continue here after the error
TPWrite “The show must go on!”, \Bool=error_flag;

ERROR
SkipWarn; !Don’t raise an error

TPWrite “Hello from error handler!”;
error_flag := TRUE;
TRYNEXT;
ENDPROC
ENDMODULE

@VictorAx I tried adding SkipWarn as you suggest, but it does not change the behavior of the program. The program simply stops with the “Kinematics error” message, and the ERROR handler is never called (also no “Hello from error handler!” message on FlexPendant). What am I missing?

If configuration is not a concern you can turn use ConfJ\Off for singularity issues, for out of reach positions I would verify that the robot can reach the points in RobotStudio prior to execution.

Verifying the motion prior to execution is always a good idea. But what I want to do here is to handle unexpected motion errors and notify a supervising PC than an error has happened.

Actually, the CalcJointT function should error if the calculated Jointtarget is out of reach. If you still do not see it passing into your error handler you might try the RAISE instruction.

Do you have multitasking? You can restart the system in the background with multitasking

Yes I have multitasking. But how can I automatically detect a condition such as a kinematics error?

From the Technical Reference Manual

@xerim your example is very similar to what I wrote in my first post. The problem is that it works for division by 0 but does not work for kinematic error.

You could try to configure a virtual analog output that is connected to the execution error you are experiencing, then create a procedure which restarts the system in the background when that signal is set to high.

– how can I do this?

Change your Error handler handler to what follows, more or less.
TEST ERRNO
CASE 50065:
TPWrite “blah blah”;
TRYNEXT;
DEFAULT
Stop;
! Look in program data for ERRNO value, match it with predefined Error numbers
! This helps in finding unanticipated errors
ENDTEST

@lemster68 The problem is that the error handler NEVER FIRES in case of kinematic error!

That is because you don’t have it set up in the way lemster has suggested. Compare the example code he provided to the code you have in your original post.

I did mention in an earlier post that you may need to use the RAISE instruction for the error. Also, the best way to troubleshoot such things is to single step forward one line at a time instead of pressing the start button. Then you can see how the logic evaluates both TRUE or FALSE.

Hello @lemster68,
have a look at step-by-step execution of the program: https://youtu.be/-XQimhLkxCQ

As I did mention before, in the case of kinematic error the program DOES NOT ENTER THE ERROR HANDLER. Therefore it does not matter what you put there.

What is the error code 194?

@lemster68 it is division by 0, obviously.

I did not look at the values for those variables. There is no CalcJointT function there, which should throw an error if it is out of range. I would normally use the step forward button on the virtual TP.