PD control with on-line gravity compensation for robots with elastic joints: Theory and experiments