Optimal joint stiffness regulation in a planar robot for packaging operations