Multi-robot system has become a research hotspot because of low demand on the sensors' accuracy, high reliability, and high efficiency. To put all the robots together, formation control is a crucial problem. In this paper, we propose a local position-based method to plan trajectories and build a pyramid pattern for a fleet of NAOs in the obstacle-free environment by refering to the position-based method and giving an O(n log n) collision avoidance strategy inspired from one graph theory, where the local positions are estimated from optical sensors. To get the local positions, an integrated image processing method is developped. Firstly a mask-base is generated to store the features of NAOs, and a cross-correlation method is introduced to recognize the NAO. Subsequently, the distance and angle models are proposed to get the local information from a single image. Then, a visual compass is introduced to obtain the orientation of one NAO. After the local information exchange by the WiFi communication, a neighbor-check method is put foward to distinguish the homogeneous NAOs (all the NAOs look like the same). Further, a common frame is constructed as an artificial global frame, and straight non-intercrossing trajectories are planned according to the O(n log n) collision avoidance strategy. At last, the performance of our proposed local position-based method is verified by the simulations with up to 15 robots and the indoor experiments with 3 NAOs in a real environment. The convergence of the method has been demonstrated in both obstacle-free and static obstacle environments.