Dynamic control of robots with joint elasticity