# Checking for Singularity

**URL:** <https://tech-community.robotics.abb.com/t/checking-for-singularity/7281>\
**Category:** RAPID Programming\
**Tags:** rapid-code, singularity, singarea, interrrupts\
**Created:** [July 25, 2016, 3:17pm UTC](https://tech-community.robotics.abb.com/t/checking-for-singularity/7281 "2016-07-25T15:17:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SteveMob](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/stevemob/32/1600_2.png) [@SteveMob](https://tech-community.robotics.abb.com/u/SteveMob)\
**Post date:** [July 25, 2016, 3:17pm UTC](https://tech-community.robotics.abb.com/t/checking-for-singularity/7281/1 "2016-07-25T15:17:37Z")

</div>

Hello,

I am sending the robot arbitrary target data via Sockets. I am attempting to check for singularity issues while the robot is moving. I am currently using a timed interrupt TRAP routine that is checking the joint angles 10 times a second. If the axis 4 or 5 joint angles are within +/-0.1, I want to turn SingArea\Wrist active, and when it is done with the move, SingArea\Off.  
It isn’t really working how I want it to… Anytime it detects a singularity issue, it ends program execution, but I want the program to continue running, and just have the robot deviate from its linear path for a short time to avoid singularity, then continue linear movement. Has anyone done this before, or can anyone offer any advice on how to get an active singularity detection _while the robot is moving_?  
My code:  
**CONNECT timeInt2 WITH IntRoutineCheckSingularity;**  
**ITimer 0.1,timeInt2;**  
**TRAP IntRoutineCheckSingularity**  
**VAR jointtarget currentJointAngles;**  
**currentJointAngles:=CJointT(\TaskName:=“T\_ROB1”);**

**IF ((currentJointAngles.robax.rax\_5\>-0.1) AND (currentJointAngles.robax.rax\_5\<0.1)) OR ((currentJointAngles.robax.rax\_4\>-0.1) AND (currentJointAngles.robax.rax\_4\<0.1)) THEN**

**SingArea\Wrist;**  
**SocketSend clientSocket\Str:=“_Singularity Off_”;**  
**ELSE**  
**SocketSend clientSocket\Str:=“Singularity On”;**  
**ENDIF**  
**ENDTRAP**

Thanks for any help!  
SM
