A system for controlling a robotic arm repeatedly performing an operation including an insertion of a component along an insertion line to assemble a product, wherein a configuration of the robotic arm includes a wrist having a motion with multiple degrees of freedom, comprising: an input interface configured to accept measurements of a force sensor operatively connected to the wrist of the robotic arm, the measurements include data indicative of force experienced by the wrist of the robotic arm at different positions of the wrist of the robotic arm along the insertion line; a memory configured to store a probabilistic relationship for the force experienced by the wrist of the robotic arm along the insertion line as a probabilistic function of the positions of the wrist of the robotic arm along the line of insertion, wherein the probabilistic function is learned from measurements of the operation repeatedly performed by one or multiple robotic arms having the configuration of the robotic arm under the control; and at least one processor configured to run executable components comprising an anomaly detector configured to determine a current value of the force and a current value of the position along the line of insertion based on the measurements of the force sensor; determine the probability of the current value of the force conditioned on the current value of the position according to the probabilistic function; and determine a result of anomaly detection based on the probability of the current value of the force; and a recovery controller configured to control the robotic arm based on the result of anomaly detection. an input interface configured to accept measurements of a force sensor operatively connected to the wrist of the robotic arm, the measurements include data indicative of force experienced by the wrist of the robotic arm at different positions of the wrist of the robotic arm along the insertion line; a memory configured to store a probabilistic relationship for the force experienced by the wrist of the robotic arm along the insertion line as a probabilistic function of the positions of the wrist of the robotic arm along the line of insertion, wherein the probabilistic function is learned from measurements of the operation repeatedly performed by one or multiple robotic arms having the configuration of the robotic arm under the control; and at least one processor configured to run executable components comprising an anomaly detector configured to determine a current value of the force and a current value of the position along the line of insertion based on the measurements of the force sensor; determine the probability of the current value of the force conditioned on the current value of the position according to the probabilistic function; and determine a result of anomaly detection based on the probability of the current value of the force; and a recovery controller configured to control the robotic arm based on the result of anomaly detection. determine a current value of the force and a current value of the position along the line of insertion based on the measurements of the force sensor; determine the probability of the current value of the force conditioned on the current value of the position according to the probabilistic function; and determine a result of anomaly detection based on the probability of the current value of the force; and a recovery controller configured to control the robotic arm based on the result of anomaly detection.