How to combine distance and contact?

So I am programming a UR3e that handles and object, which has a button on it. So the robot holds the object and moves towards a “mechanical finger” to press the button on the object.
Currently it moves on the Z+ axis until it detect a contact, then stays 0.25 seconds on the contact point to make sure the button is pressed and then returns to the start position.

But if there is no object the robot will keep going towards the mechanical finger and that will lead to an elbow singularity.

At the moment neither the tool, nor the mechanical finger have sensors, so from the programmer’s POV you can only run the pick object program and hope for the best.

So the program needs to combine the Direction command with both “until - Use Custom deceleration” (pressing the button), and “until - Distance XX mm” (to avoid going into the singularity).
Is there any way of doing that?

Hi cgs,

You can simply add another Until - Distance condition in the Direction Node. The robot stops at the first detected condition.