The purpose of this article is to control the formation and pass static and dynamic obstacles for the quadrotor group, maintain the continuity and flight formation after crossing the obstacles, and track the moving target. Model Predictive Control (MPC) method has been used to control the status and position of quadrotors and formation control. Flight formation is based on the leader-follower method, in which the followers maintain a certain angle and distance from the leader using the formation controller. The improved Artificial Potential Field (APF) method has been used to pass obstacles, the main advantage of which compared to the traditional APF is to increase the range of the repulsive force of the obstacles, which solves the problem of getting stuck in the local minimum and not passing through the environments full of obstacles. The results of the design of the attitude and position controller showed that the quadrotors were stabilized and converged in less than 3 seconds. Formation control simulations in the spiral path showed that the followers, follow the leader. The results of the quadrotors passing through the obstacles were presented in four missions. In the first mission, 4 quadrotors crossed static obstacles. In the second mission, 4 quadrotors crossed dynamic obstacles. In these two missions, the quadrotors maintained a square flight formation after crossing the obstacles. In the third mission, the number of quadrotors increased to 6. The leader tracked the moving target and the quadrotors crossing the static obstacles. In the last mission, the quadrotors passed through the dynamic obstacles and the leader tracked the static target. In these missions, the quadrotors maintain the hexagonal formation after crossing the obstacles. The results simulations showed that the quadrotors crossed the fixed and moving obstacles and after crossing, they preserved the flight formation.