RobotStudio event

Return to different positions after stopping simulation

Hello,

I am fairly new to RobotStudio, so I am kind of lost on this question. No matter where in the program simulation I hit "stop" and then "play" again, it goes straight back to my original home position, as it should. My question is, is there a way to specify which "home" positions for the robot to return to depending on where it is at during the program? For example, if I have 4 targets, a home1, and a home2. I want the robot to return to home1 if it is stopped and then pushed play again when its between targets 1 and 2, but I want it to return to home2 if it is between targets 3 and 4. Is this even possible with RS? What my program is doing is if it is stopped during a certain part and then started back over again, the process it takes to get to the original home position is causing some cabling issues (cable running into the wall or twisting itself around the robot). Any ideas to help me with getting multiple home positions for different portions of the program?

Thanks in advanced for any help!

Comments

  • Hello Steve
    You can do something like this

    MODULE PROG

        PERS robtarget pEndPosition;
        PERS robtarget pCurrentPosition;
        PERS robtarget p10;
        PERS robtarget p20;
        PERS num nDist;

        PROC main()

            IF nDistance(p10)>nDistance(p10) THEN
                !Move home1
            ELSE
                !Move home2    
            ENDIF

        ENDPROC

        FUNC num nDistance(robtarget pEnd)

            pCurrentPosition:=CRobT(\Tool:=tool0\WObj:=wobj0);
            nDist:=Distance(pCurrentPosition.trans,pEnd.trans);

            Return nDist;

        ENDFUNC

    ENDMODULE

    /Pavel
  • SteveMob
    SteveMob
    edited December 2015
    Pavel,

    Thank you for your snippet. Like I said though I am fairly new to RS, so I'm not sure I really follow the coding... Where do I actually specify what "home1" or "home2" is? Any examples would be greatly appreciated! Also, wouldn't the IF statement compare p10 and p20?
    Thanks!
  • I added some comments and jointtargets that will clarify a little

    MODULE PROG

        PERS robtarget pEndPosition;
        PERS robtarget pCurrentPosition;
        PERS robtarget p10;
        PERS robtarget p20;
        PERS jointtarget pHome1;
        PERS jointtarget pHome2;
        PERS num nDist;

        PROC main()

            IF nDistance(p10)>nDistance(p20) THEN !If distance from current position is greater to p10 than to p20
                MoveAbsJ pHome1,v200,z50,tool0; !Move to Home position 1
            ELSE
                MoveAbsJ pHome2,v200,z50,tool0;  !Move to Home position 2
            ENDIF

        ENDPROC

        FUNC num nDistance(robtarget pEnd) !This function will measure distance between current position and the input position

            pCurrentPosition:=CRobT(\Tool:=tool0\WObj:=wobj0);
            nDist:=Distance(pCurrentPosition.trans,pEnd.trans);

            Return nDist;

        ENDFUNC

    ENDMODULE
  • SteveMob
    SteveMob
    edited December 2015
    Perhaps this will help me explain better. I have attached a simple program with 3 home positions (Home1, Home2, Home3), and 4 targets (Target_1, Target_2, Target_3, Target_4). This is what I need to happen during simulation:
    If the "stop" button is pushed, and the robot is between Target_1 and Target_2, then the play button is pushed, the robot needs to first go to Home2, then proceed to Home1.
    If the "stop" button is pushed, and the robot is between Target_3 and Target_4, then the play button is pushed, the robot needs to first go to Home3, then proceed to Home1.

    If you don't mind, could you possibly go in to my program and alter the code to do this? I think if I could actually see the code in the works it would help me understand this better, rather than just looking at an algorithm example.

    CODE:

    MODULE Module1
        CONST robtarget Home1:=[[211.807179916,-29.949370435,568.144478505],[0.520572289,0.059862595,0.850928776,-0.036622111],[-1,-1,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        CONST robtarget Home2:=[[181.96531164,-315.661735855,593.999984225],[0.432928775,0.433264133,0.749854853,-0.25014509],[-1,0,-1,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        CONST robtarget Target_10:=[[246.188134296,-384.823890327,161.657986235],[0.034192382,0.479791458,0.876516249,-0.018716382],[-1,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        CONST robtarget Target_20:=[[392.05318618,-234.504420514,161.657986235],[0.037572475,0.266073163,0.963164394,-0.010379357],[-1,-1,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        CONST robtarget Target_30:=[[122.841800553,440.008995444,161.657986235],[0.031048276,-0.604148781,0.795917602,0.023567488],[0,0,-1,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        CONST robtarget Target_40:=[[336.7197606,308.735852884,161.657986235],[0.036327291,-0.362304645,0.931244287,0.014133291],[0,0,-1,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        CONST robtarget Home3:=[[240.020330113,274.1239633,593.999984225],[0.455350888,-0.357723988,0.788691104,0.206531981],[0,-1,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        CONST robtarget Target_1:=[[246.188134296,-384.823890327,161.657986235],[0.034192382,0.479791458,0.876516249,-0.018716382],[-1,0,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        CONST robtarget Target_2:=[[392.05318618,-234.504420514,161.657986235],[0.037572475,0.266073163,0.963164394,-0.010379357],[-1,-1,0,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        CONST robtarget Target_3:=[[122.841800553,440.008995444,161.657986235],[0.031048276,-0.604148781,0.795917602,0.023567488],[0,0,-1,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        CONST robtarget Target_4:=[[336.7197606,308.735852884,161.657986235],[0.036327291,-0.362304645,0.931244287,0.014133291],[0,0,-1,0],[9E9,9E9,9E9,9E9,9E9,9E9]];
        PROC Path_10() !This is just an example path, it could be a number of things. I just threw this in to show what the path COULD be, but still needs to do what is mentioned above
            MoveL Home1,v200,z100,tool0\WObj:=wobj0;
            MoveL Target_1,v200,z100,tool0\WObj:=wobj0;
            MoveL Target_2,v200,z100,tool0\WObj:=wobj0;
            MoveL Home2,v200,z100,tool0\WObj:=wobj0;
            MoveL Target_3,v200,z100,tool0\WObj:=wobj0;
            MoveL Target_4,v200,z100,tool0\WObj:=wobj0;
            MoveL Home3,v200,z100,tool0\WObj:=wobj0;
            MoveL Home1,v200,z100,tool0\WObj:=wobj0;
        ENDPROC
      
        PROC main()
            Path_10;
        ENDPROC

    ENDMODULE


    Thanks for all your help!

  • Hello SteveMob

    You can place a worldzone between your targets. The zone will set an IO as the robot TCP enters it, and you can use the IO as a condition to call different home paths.

    The common way to have safe home paths and avoid collision after a stop is to measure distance to certain targets that you place in areas where the robot needs to choose different paths to go to home position safely.

    To do this you can use my method above but instead of comparing to which target the robot is closest you can just say that if the robot is within 300mm of a target you choose a different home path.

            IF nDistance(p10)<300 THEN
                MoveAbsJ pHome1,v200,z50,tool0; !Move to Home position 1
            ELSE
                MoveAbsJ pHome2,v200,z50,tool0;  !Move to Home position 2
            ENDIF

    Also note that you can reach targets with different configurations, so if you have cables tangling you can try different configurations reaching a target with other joint values, depending on which joint the cable is attached to.

    /Pavel