In this paper, a problem, called the initial formation problem, within the multirobot task allocation domain is addressed. This problem consists in deciding which robot should go to each of the positions of the formation in order to minimize an objective. Two different distributed algorithms that solve this problem are explained. The second algorithm presents a novel approach that uses cost means to model the cost distribution and improves the performance of the task allocation algorithm. Also, we present an approach that integrates distributed task allocation algorithms with a behavior-based architecture to control formations of robot teams. Finally, simulations and real experiments are used to analyze the formation behavior and provide performance metrics associated with implementation in realistic scenarios.