Loop grip check

Hello! I just started my UR Journey about a week ago and I’ve been tasked with a pick place operation with a e3 using a robotiq gripper. The issue I’m having is looping a failed grip check back to beginning of the program. Seems simple.
So what I’m gripping is viewed by a camera on light table, if the camera fails to see the correct orientation of the item and the robot picks the item in the wrong orientation (the item is flanged) or misses the item. I have a location to open the gripper to a dimension so if picked correctly it’ll settle on the flange if not it’ll drop and close the gripper to detect . This where I do the grip check if it’s not detected then I want it to go back to the begining of the program and start over till it picks a good item. To continue with the rest of the program.

I tried looping with function rq_is_object_detected(false) added the grip check after that. I’m stuck on the command to go back to the beginning of the program. Thanks in advance!

Hi @rhacker,
you could try a program structure like this:

while True:
    # camera detection
    camera_detect(...)

    # pick
    pick(...)

    # check grasp
    rq_grasp()

    if  rq_is_object_detected(false):
    	# place
    	place(...)
    end

end

I got it ! I used the grip check detected & validated with a size and nested the rest of the program under that. So when the grip check fails it loops back to the beginning.