In this paper we introduce a collision avoidance control strategy for groups of mobile robots moving in a three-dimensional environment, whose dynamics are described according to the Lagrangian model. The proposed strategy is based on the use of gyroscopic forces, that ensure obstacle avoidance without interfering with the convergence properties of the multi-robot system's desired control law. Moreover, we introduce a method to define the direction of the force in an optimal way, in order to introduce the smallest possible perturbation with respect to the desired behavior of the system. Collision avoidance and convergence properties are analytically demonstrated, and simulation results are provided for validation purpose