Pay 2 minutes trouble to read my orginal post
You don't need DCS, only a well defined BackGround Logic routine to check your TCP location. Use Diag_GRP[1].CUR_TCP_X, Diag_GRP[1].CUR_TCP_Y, Diag_GRP[1].CUR_TCP_Z system variables. Use your own DOs depending the TCP Location. Create a home routine and use those DO signals to safely exit any danger zone (defined in the BG logic) and return home. BG logic will constantly update those DOs based on its current TCP location. Each time you will call your Home routine, the robot will use some branch logic (IF-ELSE) based on the signal ON from the BG LOGIC to decide the exit strategy and safely return home. You can even use CUR_TCP_W, CUR_TCP_P, CUR_TCP_R which represents your TCP orientation to better define your danger zone. Or you can use Space Function which is a standard function although I find that creating my own Space Function is a lot more reliable than the embedded space function that has a lot of bugs (especially when using continuous turn axis).
This is a sample code that defines 3 "hazard zones" for my robot and constantly checks for them.
IF ($DIAG_GRP[1].$CUR_TCP_X<1050) THEN
DO[4:ON :out of space wheelstabl]=ON
ELSE
DO[4:ON :out of space wheelstabl]=OFF
ENDIF
IF ($DIAG_GRP[1].$CUR_TCP_Y<700) THEN
DO[35:ON :out of space bench]=ON
ELSE
DO[35:ON :out of space bench]=OFF
ENDIF
IF ($DIAG_GRP[1].$CUR_TCP_X<(-90) AND $DIAG_GRP[1].$CUR_TCP_Y<(-700)) THEN
DO[3:ON :out of space barrel]=OFF
ELSE
DO[3:ON :out of space barrel]=ON
ENDIF