Detecting when contact is lost?

For my use-case I’d like to perform a move-until-contact, immediately switch into force mode, and only stop force mode when the tool isn’t in contact with an object anymore. I’ve tried figuring this out based on the force readings from the sensor but that isn’t working well. Is there another approach you guys can think of to achieve this goal?

Can you not just use the auto-retract feature of the Move Until Contact? Just touch the part and back off a millimeter or 2 or whatever?

Thanks for the reply @eric.feldmann ! My post may not be clear sorry. After contact is initially detected the intention is to maintain contact while performing movements in force mode. When we lose contact we’d like to switch back out of force mode and move normally.

Truth be told, this is a work around because we have not found a way to mimic the dynamic force mode approach via RTDE since this method requires two threads running on the cobot which I don’t believe is possible while using RTDE. If you’re aware of how to use force mode with varying speeds via RTDE that would also be extremely helpful! For example, move to a point with 10N of force at one speed. Then move to a separate point with 10N but double the speed.

Hmm sounds like your first approach is what I would do then. Just be sure to tare the ft sensor before using it. That command is zero_ftsensor(). Then I’d just have a thread monitoring the force() readout, and when it goes below whatever value, set a variable. Then you’d have your move inside a check_continuously if block, where that if is checking the state of the variable your thread sets. When it’s set, terminate the move and do whatever else you need.

If your force readouts still aren’t working right, maybe you can monitor the TCP’s Z coordinate instead? Kind of assuming you’re on a flat surface which may not be the case. I am not familiar enough with the RTDE to be of help there unfortunately.