Setting Wait DI for UR10e Based on TCP Force

Hi guys, what I’m trying to do is let TCP descend and fit onto a plane in force mode, and stop force mode after feeling a certain amount of force from TCP.
I’m looking for the script manual and figure out how to enter and end force mode. I also find the code to get force on TCP, but I don’t know how to let it return a digital output when force on TCP reach a certain amount so I can set a wait DI.
Attaching the code for getting force on TCP.
I think maybe this is a very generic question for all robots, looking forward your help!
Thank you guys!
20230623112812
20230623112820

Hey,
Do you want to solve this in URscript or as a Polyscope Program?

If you are trying to implement it as a Polyscope program have a look at this article:

https://www.universal-robots.com/articles/ur/programming/seek-using-force/
While this example is not exactly what you need it shows one way of using the force value to stop a motion and trigger another motion.
You can download the finished file at the bottom of the page.

Thank you so much, I download the file it seems good with Polyscope but I need to set this with script code cause I am using it in a GH Robots program to do a customized command.
I need to figure out the script code to do this “if do” stuff.

If you want to do it in grasshopper it will be much more difficult to implement:
If you are using the robots plugin you may not be able to simply create a custom command as the custom command is executed after a point is reached. Some workarounds are necessary in order to do it at the right moment in the program.
I have not tested the solution mentioned below. You may need to make some changes before it runs as you want it to.

  1. Define a Thread that continually runs and evaluates the amount of force at the tcp in your init commands :
thread ForceCheck():
    maxforce = 50  # The thread will stop if a force of more than 50N (~5kg) is reached
    touched = False
    while force() < maxforce: 
        touched = False
    end

    #  if the force is exceeded the following code will run: 
    touched = True
    stopj() # stop the robot from moving any further
    movel(pose_add(get actual tcp pose(), p[0, 0, 0.1, 0, 0, 0])) # move up by 100 mm
    return
end

This thread creates a while-loop that runs until the force is exceeded.
If the force is higher than maxforce the while loop ends and the robot will stop and move 100mm in Z+ direction.
You need this thread as you will need to check the force continually while motion commands.

  1. You will then need to run the thread at the right time.
    Usually this wouldn’t be a problem but it is made more difficult when trying to do it in robots in Grasshopper.
  • Create a Target 100mm above the location you want to probe.
  • add a custom command to the target with this code:
target_below = pose_add(get actual tcp pose(), p[0, 0, -0.2, 0, 0, 0])
# creates a target location 200mm below the current position
thrd = run ForceCheck() # start the thread
movel(target_below)  # move to the target 

The robot will try to move downwards by 200mm. If it encounters an obstacle it will stop.


As mentioned I have not tested it but this is how I would approach the task.
If you try it, use extreme caution and test it with a very simple toolpath.
If you run into problems let me know.

1 Like

Thank you so much!!! I will try it.