The ur_rtde provides functions for contact detection which have several use cases, one being providing more reliable pick/place.
Perhaps a good start is to implement RTDEControlInterface::moveUntilContact
bool moveUntilContact(const std::vector<double> &xd, const std::vector<double> &direction = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, double acceleration = 0.5)
The ur_rtde provides functions for contact detection which have several use cases, one being providing more reliable pick/place.
Perhaps a good start is to implement
RTDEControlInterface::moveUntilContact