Better way to approach this problem?

Edit: The custom tool is attached to the tool flange but the Cobot wrist will not rotate at all during this part extraction.

We have a UR5e with a custom tool (no UR Cap) that will unthread/unscrew parts out of a machine. I’m not sure if we should use an Until Force, Until Distance, or Force node. I want the Cobot to approach the part slowly with a force of 3 or 4 Newtons. The tool must align with the part but it may be off by by a few degrees with the ribs and/or ±2mm in Z and Y axes. The tool is able to twist a bit and adjust into place when some force is applied on the part. Basically it will slip into place. Please see images below to get a visual idea. I like the Force node idea better because as the Cobot applies force towards the part and the tool spins, the part will apply a force back, pushing the Cobot steadily. This allows me to adjust the speed of the tool to whatever I want and I will not need to calculate how many mm/s it needs to move along the X axis to guide the part out. The part where I am stuck on: How to stop the Force mode when a certain distance is met. I have never used the force node on other programs so I’m unsure what to put to trigger the mode off with conditions.





Idea in Pseudo code:

Robot Program

Waypoint: Home_Position
Waypoint : Target_Part
Force: X+ & 3 Newtons (relative to Base)
When X distance reached, DO[3] = HI
When X position met, stop Cobot moving, DO[3] = LOW
Waypoint: Target_Part
Waypoint: Home_Position
Waypoint: Drop_Off

Any other ideas or potential issues I’m not seeing? Is screw_driving(f, v_limit) a better approach? If so, how to implement that in program?

use direction node and add multiple until commands. robot will continue to push until a force is met or distance is achieved. whichever comes first. Just keep in mind the UR5e does not have infinite rotation of the tool so you can only rotate +/- 360 degrees of the tool.

You could also monitor the current TCP position with get_actual_tcp_pose() with a separate thread running continuously and change some variable when certain position is met