A Hamiltonian approach to dynamics and stabilization of spacecraft multibody systems