This paper proposes a control algorithm for a robotic swarm based on the center of gravity of the local swarm. In order to be compatible with maintaining a high stability of the whole swarm and advancing to the goal, virtual forces; local forces and an advancing force which are produced by the algorithm, are applied to multiple autonomous mobile robots. Local forces such as an attraction and a repulsion, are applied to each robot for increasing the stability of the local swarm. Overlapping each local swarm partially increases the stability of the whole swarm. The advancing force is applied to each robot for advancing to the goal while maintaining the stability of the local swarm. Since obstacles which prevent the robot advancing are considered as a disturbance from the viewpoint of the stability of the whole swarm, an effectiveness of the algorithm in obstacle space is evaluated using a dynamics simulation. As a result, it is found that the algorithm is able to maintain the high stability of the whole swarm advancing to the goal.