Hamiltonian description and dynamic control of flexible robots