I have developed next script in order to modify by fliying the speed. As I am using an old robot version I have no “speedrefresh” and I have realized that I can not refresh speed value using “velset” if I do not make again a new one MOVEL.
What I get in pendant is an error which tells me about unhandled error. Following the procedures structure Error should be raise to Movements procedure is it?.
Hi, Your error handler must have code to deal with the error especially if it is one you have created, e.g.
TRAP trp_func
RAISE Err_move_stop;
ERROR
IF ERRNO=Err_move_stop THEN
!do code to handle the error
ENDIF
RAISE; !only raise if a higher level error handler has code to handle the error or if the error is not Err_Move_Stop and you want to see it’s error message
ENDPROC
The solution is to use “error recovery with long jump”.
It sounds like a fancy term but it is just explicitly stating any errors you want to catch that you have raised from a trap routine.
Here is a basic example, check out the code below, the key is the brackets next to the ERROR statement:
Any error numbers listed in brackets next to the ERROR statement are handled in that error handler, up to any amount you like, e.g. ERROR(ErrNum1, ErrNum2, Errnum3) etc.
This is primarily used to handle errors that occur in trap routines at specific levels of execution. An interrupt could occur anywhere in the code and raise an error, so this just provides a way of catching them in specific places. For some more info and examples see: Technical reference manual - System parameters, section Basic Characteristics - Error Recovery, page 47.
VAR intnum in_Interrupt;
VAR errnum en_Interrupt := -1;
PROC Main()
RoutineA;
ENDPROC
! Procedure to set up an interrupt
PROC RoutineA()
! Book the error number to be raised by the trap routine
BookErrNo en_Interrupt;
! Connect the interrupt to the trap routine
CONNECT in_Interrupt WITH TrapRoutineB;
! Execute some code to set up the interrupt, i.e. on a timer or input
! Other code that is executing when the interrupt occurs
ERROR(en_Interrupt) ! Any errors in brackets are caught here specifically
! Execute code to warn the user or retry a movement
StartMove;
RETRY;
ENDPROC
TRAP TrapRoutineB
! Execute trap routine code for example:
StopMove\Quick;
ClearPath;
! Raise the error to be caught in routine A
RAISE en_Interrupt;
ERROR
RAISE;
ENDTRAP