In complex and unknown battlefield environments, unmanned vehicle clusters can undertake more complex tasks than single unmanned vehicles. The collaborative formation and obstacle avoidance of unmanned vehicles is one of the research hotspots in the field of swarm intelligence. Aiming at the problem of multiple unmanned ground vehicle (UGV) formation and obstacle avoidance in an unknown environment, this paper proposes a UGV cooperative formation and obstacle avoidance control method based on improved dynamic window approach (DWA). Besides the azimuth evaluation factor, obstacle evaluation factor, and speed evaluation factor of the dynamic window method path evaluation function, has the direction coordination factor and formation maintenance factor are added, which realizes the collaborative adaptive adjustment by improving the dynamic window approach (DWA) algorithm. When multiple unmanned vehicles approach to unknown obstacles, the direction synergy factor in the path evaluation function is used to control the consistency of speed direction during the collaborative driving process of multiple unmanned vehicles. The formation preservation factor can automatically adjust the relative position and distance between multiple vehicles. The adaptive collaborative adjustment of the relative position and speed of each vehicle is carried out through the improved dynamic window algorithm. This method can keep the formation relatively stable while avoiding obstacles. The coefficients of each factor of the path evaluation function are optimized based on the improved Pigeon-inspired Optimization (PIO). Finally, the variable weight pigeon-inspired Optimization (PIO) and improved dynamic window approach (DWA) algorithm is simulated and verified by forming a triangular formation with three UAVs. The results show that the method can effectively avoid collisions between UAVs and obstacles and keep the formation stable, which has verified the feasibility of the improved dynamic window approach (DWA) algorithm.