This paper introduces a motion planning and cooperative formation control approach for quadruped robots and multi-agent systems. First, in order to improve the efficiency and safety of quadruped robots navigating in complex environments, this paper proposes a new planning method that combines the dynamic model of quadruped robots and a gradient-optimized obstacle avoidance strategy without Euclidean Signed Distance Field. The framework is suitable for both static and slow dynamic obstacle environments, aiming to achieve multiple goals of obstacle avoidance, minimizing energy consumption, reducing impact, satisfying dynamic constraints, and ensuring trajectory smoothness. This approach differs in that it reduces energy consumption throughout the movement from a new perspective. Meanwhile, this method effectively reduces the impact of the ground on the robot, thus mitigating the damage to its structure. Second, we combine the dynamic control barrier function and the virtual leader-follower model to achieve efficient and safe formation control through model predictive control. Finally, the proposed algorithm is validated through both simulations and real-world scenarios testing.