In this paper, a consensus-based control strategy is presented to gather formation for a group of differential-wheeled robots. The formation shape and the avoidance of collisions between robots are obtained by exploiting the properties of weighted graphs. Since mobile robots are supposed to move in unknown environments, the presented approach to multi-robot coordination has been extended in order to include obstacle avoidance. The effectiveness of the proposed control strategy has been demonstrated by means of analytical proofs. Moreover, results of simulations and experiments on real robots are provided for validation purposes.