Avoidance is allways the best solution when possible.
When you don't find a fast avoidance solution a monitoring strategy can help right away to protect the machine or robot from damage.
A highly sensitiv force sensor reacts in 1-2 ms to stop the robot.
There is a force sensor on the market...