Quite interesting article. After graduating from a control-theory-heavy program, I have started thinking about animal movement as an optimization problem. A manipulator is moved into a desired position while minimizing the cost function of pain, in order to avoid damage to the body.
That would fall in the "useful painful pain" category, I guess.