RobotStudio event

IF statement question

Hello,

I am receiving a number from Sockets that gets placed into a variable "command". I am trying to test to see of that number is a certain number:
IF command<>42 OR command<>105 OR command<>106 OR command<>5 THEN
                        SocketSend clientSocket\Str:="Unknown command";
                        GOTO MainLoopEnd;
ENDIF

I am sending it the number 42, and it still goes into this IF statement. However, if I compare just IF command<>42 (not all the other OR command<>#'s), it works just fine and skips this loop.
So my question is, how can I compare multiple values? What am I doing wrong? Is there like a certain hierarchy thing I am missing?

Thanks for any help!
SM

Best Answers

Answers

  • Similarly I want to check if a given target approaches singularity so I am checking the joint angles, and if they come within +/- 0.1 degrees, I want to set bool singularity=true, otherwise return false:
    IF ((target.robax.rax_5>-0.1) AND (target.robax.rax_5<0.1)) OR ((target.robax.rax_4>-0.1) AND (target.robax.rax_4<0.1)) THEN
                singularity:=TRUE;
            ELSE
                singularity:=FALSE;
    ENDIF
    RETURN singularity;

    Is there a way that I can do that?

    Thanks,
    SM