Home Programming

Discussion

Left ArrowBack to discussions page
NerialsNerials Posts: 3 Apprentice
The task I want to do: 

If object detected proceed further with program
If object is not detected do something else

How to write program like that? 

Best Answer

  • David_GariepyDavid_Gariepy Beta Tester Beetle, Wrist Camera URCap 1.3.0, Vacuum Beta tester Posts: 186 Handy
    edited November 2017 Accepted Answer
    Hi @Nerials

    To do this kind of logic, you could simply use a variable for each part and update it in the camera locate node.
    In the first example here, the robot will continue searching until it finds the needed part. 
     Program
       BeforeStart
         'initialize variable'
         part_1_detected≔ False 
         part_2_detected≔ False 
         part_3_detected≔ False 
       Robot Program
         MoveJ
           Home
         If part_1_detected≟ False 
           MoveJ
             snapshot1
             Camera Locate
               part_1_detected≔ True 
               'put in assembly station'
         If (part_1_detected≟ True ) and part_2_detected≟ False 
           MoveJ
             snapshot2
           Camera Locate
             part_2_detected≔ True 
             'put in assembly station'
         If (part_1_detected≟ True ) and (part_2_detected≟ True ) and (part_3_detected≟ False )
           MoveJ
             snapshot3
           Camera Locate
             part_3_detected≔ True 
             'put in assembly station'
         If (part_1_detected≟ True ) and (part_2_detected≟ True ) and (part_3_detected≟ True )
           'Do something when assembly is done then reset variable'
           part_1_detected≔ False 
           part_2_detected≔ False 
           part_3_detected≔ False 
    
    <br>

    In the second example here, the robot could execute your extraordinary code if a part isn't found.

    Program
       BeforeStart
         'initialize variable'
         part_1_detected≔ False 
         part_2_detected≔ False 
         part_3_detected≔ False 
       Robot Program
         MoveJ
           Home
         If part_1_detected≟ False 
           MoveJ
             snapshot1
             Camera Locate
               part_1_detected≔ True 
               'put in assembly station'
         If part_1_detected≟ False 
           'part 1 was not detected. execute your extraordinary code here'
         If (part_1_detected≟ True ) and part_2_detected≟ False 
           MoveJ
             snapshot2
           Camera Locate
             part_2_detected≔ True 
             'put in assembly station'
         If (part_1_detected ≟ True ) and (part_2_detected≟ False )
           'part 2 was not detected. execute your extraordinary code here'
         If (part_1_detected≟ True ) and (part_2_detected≟ True ) and (part_3_detected≟ False )
           MoveJ
             snapshot3
           Camera Locate
             part_3_detected≔ True 
             'put in assembly station'
         If (part_1_detected ≟ True ) and (part_2_detected≟ True ) and (part_3_detected≟ False )
           'part 3 was not detected. execute your extraordinary code here'
         If (part_1_detected≟ True ) and (part_2_detected≟ True ) and (part_3_detected≟ True )
           'Do something when assembly is done then reset variable'
           part_1_detected≔ False 
           part_2_detected≔ False 
           part_3_detected≔ False 



    You'll find the 2 programs example attached if needed.
    Regards
    David Gariépy
    Integration Coach

Comments

  • Etienne_SamsonEtienne_Samson Beta Tester Beetle, Wrist Camera URCap 1.3.0, Vacuum Beta tester Posts: 418 Handy
    @Nerials the Robotiq Wrist Camera use a single command line, Camera Locate.

    Camera Locate node act like an "if" statement, so if you detect an object (Camera Locate is "true) everything under the camera locate node is executed.

    For example this is a pick and place with camera and counting the number of parts:
    MoveJ
       Snapshot_position
    Camera Locate
       part_counter = part_counter+1
       MoveL
          Approach_pick
          Pick
          Gripper Close
       MoveJ
          Approach_place
          Gripper Open
    In that example, if you don't have any parts, the part counting, the pick and the place are skipped (they are under the camera locate).

    You could also do a program with an if and else to count if you are having parts or not:
    MoveJ
       Snapshot_position
    If Camera Locate
       part_counter = part_counter+1
       MoveL
          Approach_pick
          Pick
          Gripper Close
       MoveJ
          Approach_place
          Gripper Open
    Else
       no_parts = no_parts+1
    Etienne Samson
    Technical Support Director
    +1 418-380-2788 ext. 207
    [email protected]
  • NerialsNerials Posts: 3 Apprentice
    Maybe I formulated my question in in wrong manner. I understand the idea that camera locate works like IF statement and when it detects a part it does what is inside the camera locate node if not it proceeds further. But what I want to do is to execute some other code or comand when the part is NOT detected and to stop a normal process. Maybe it will be more clear if I describe my task. 

    So I have 3 parts assembly. They need to be assembled in sequence  1, 2 and 3. All these 3 parts are located separetly in different fields of view. 

    So for example robot detects part 1 and puts it in assembly station. Then it goes for part 2 if it detects then it goes to put it into assembly and then go for part 3. 
    BUT if part 2 was NOT detected I do not want to proceed to PART 3 I want robot to stop and give an error message or try to find PART 2 one more time.
    So if everything is detected I want to go with normal flow. But if part is NOT detected I want to execute this "extraordinary" code that would not normally run if parts are detected and everyting is in nice flow. How do I initiate this "extraodinary" code that would stop robot and give an error message ONLY when part 2 is not detected and when it IS detected code would go further with normal comands? 
  • NerialsNerials Posts: 3 Apprentice
     Hi @David_Gariepy

    Thank you for you input with the code example it was really helpfull ! :)

    But now I bumped into some other issue: I used example No. 1 of your template for my script and when I wrote all comands it worked smoothly. But when I SAVED it, it got all messed up. (P.S. Actually I have 4 parts in assembly and two of them are the same Part2 and Part3) . So when I saved my script and run it again the reference frame for Camera Locate node became something totaly different... So when camera detects an object robot dosn't go to pick it up as taught but goes into weird directions nothing like I tought him. 
    Somehow  I managed to get back to initial reference frames (in camera locate node) for Part1 detection and Part2 dectetion by changing Features for Move to some other and then back to what is should be. Never the less it did not helped me to do the same for Part3 even thou it is totaly same part in a same location as Part2 and I even copied Move node with waypoints from Part2 to Part3. So now all the waypoints, features, TCP and settings are identical in Part2 and Part3 but when the time comes to pick up Part3 camera detects part and then robot goes nuts direction...
    Any tips how to solve this? 
  • David_GariepyDavid_Gariepy Beta Tester Beetle, Wrist Camera URCap 1.3.0, Vacuum Beta tester Posts: 186 Handy
    Hi @Nerials

    • For the move in the camera locate, did you use movel and set the snapshot use as the feature?
    • Do you use the same snapshot position for all part?  if you use different snapshot position you need to set the feature accordingly in the movel feature. 
    • You might also have to reteach all position, even if when you "move robot here" it move at the correct position. If the move been recorded under another feature, it won't go at the correct position when the program run. 

    So just be sure the feature in movel is the one used in the camera locate node, and reteach your waypoint then you should be fine. 





    David Gariépy
    Integration Coach
Sign In or Register to comment.
Left ArrowBack to discussions page