RobotStudio event

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?

Comments

  • 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. 
  • xerim said:
    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.


    Lee Justice
  • Do you have multitasking? You can restart the system in the background with multitasking
  • xerim said:
    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?
  • xerim
    xerim
    edited January 2021
  • @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. 
  • virtual analog output that is connected to the execution error
    -- 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
    Lee Justice
  • @lemster68 The problem is that the error handler NEVER FIRES in case of kinematic error!
  • mkatliar said:
    @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.
    Lee Justice
  • 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?
    Lee Justice
  • @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.
    Lee Justice
  • xerim
    xerim
    edited January 2021
    The internal error handler of the robot takes over when there is no error handler created by the user, which would indicate that your error handler is incorrectly defined. Take a look at page 74 of the Technical Reference Manual - Rapid Overview
  • @xerim the error handler is correctly defined and works for division by 0.
  • Try this:
    MODULE MainModule
        
            FUNC bool CanRobReach(robtarget ToPoint,
            PERS tooldata Tool,
            \PERS Wobjdata wobj) 
            VAR jointtarget jdump;
    
            jdump:=CalcJointT(ToPoint,tool\wobj?wobj);
            RETURN TRUE;
        ERROR
            SkipWarn;
            RETURN FALSE;
        ENDFUNC
    
        PROC main()
            
            
            CONST robtarget far_away:=[[10000,10000,10000],[0.0208901,-0.980874,-0.19283,-0.016298],[0,0,1,0],[9E+09,9E+09,9E+09,9E+09,9E+09,9E+09]];
            CONST jointtarget far_away2:=[[1000,1000,1000,1000,1000,1000], [9E9,9E9,9E9,9E9,9E9,9E9]];
            
            
            IF CanRobReach(far_away, tool0) THEN
            MoveabsJ far_away2, v100,fine, tool0;
            ELSE
               TpWrite "error caught";
            ENDIF
        
            
    
        
        ENDPROC
    ENDMODULE

  • OK, I made a bit of an oversight.  I took what you said that the error number was, just as it reads and will be written into the error log as such.  BUT, and this is a big but here, Rapid system error numbers are mostly 4 digits some are 3.  The 50065 Kinematic error will go into the motion.  So what will work is code like this:

    PROC Routine1()
    	MyJointTarget:=CalcJointT(myRobtarget,Tool0);
            Stop;
        ERROR
          TEST ERRNO
            CASE ERR_ROBLIMIT:
              TRYNEXT;
            CASE ERR_OUTSIDE_REACH:
              TRYNEXT;
          DEFAULT:
           Stop;
         ENDTEST
    	ENDPROC
    

    This is a very simple example, tested in RS, goes into error handler.  Of course the robtarget is declared way out of reach.
    Lee Justice
  • @mkatliar Were you able to get this to work? 


  • mkatliar
    mkatliar
    edited February 2021
    @xerim @lemster68
    Below is the reply that I got from an ABB engineer:

    Unfortunately it is not working like you try to do, MoveAbsJ instruction does not throw any errors when trying to travel to out of reach point.
    MoveAbsJ can only handle

    Usually robots work in their working envelope and never cross the range border. Only collision errors are handled.

    You can go around and use function CalcJointT(). CalcJoinT() can throw errors like mentioned below or write Your own error handler.

    Please check if GetTrapData instruction is sufficient for you. This instruction should be located in second task to avoid stopping program execution in case of any error in Motion task.

    Then you can use SocketCreate or SocketConnect to establish TCP/IP connection between robot controller and PC to exchange data.

    So the bottomline is: there is no way to catch a kinematic error and continue the execution of the motion task.