Robot has been increasingly used in weeding. Taking the quadruped laser weeding robot as an example, this paper presents a method to optimize its four legs using the dynamic scale synthesis. The objective of the optimization was the lengths of the legs, in which, prior to optimizing the driving torque of the joint in each leg, we first optimized the driving torque of the leg based on the load it was required to take. The laser weeding robot used compound cycloid trajectory to plan its trajectory, which is ready for optimizing the driving torque of the joint in the rear leg. The optimization focused on the driving force moment on both the thigh joint and the calf joint, for which obtained a set of optimal thigh bar lengths and calf bar lengths. We first calculated the foot trajectory and the gait parameters of the robot, and then used the thigh joint force moment, the calf joint driving force moment and different leg rod lengths to maximize the dynamic target; the dimensional parameters of the legs were also taken as design parameter in the multi-objective constraint optimization. After the thigh joint driving force moment and the calf joint driving moment were firstly optimized using the particle group algorithm, the maximum torque of the leg joints within the each group of the rods was calculated under a given target trajectory by combining the leg sizes. Based on the smallest set of driving force moments, we found the maximum and minimum driving torque of each joint in the target trajectory, which was further optimized using the ideal dot method and the particle group algorithm. This transformed the multi-objective optimization to a single-objective optimization. These two-step optimizations allowed us to obtain the leg length in the group of optimal four-legged laser weeding robots. We verified the optimal results against experiments. The results showed that the optimized four-legged laser weeding robot significantly improved its dynamic performance compared to that without optimization. It was also found that the optimization reduced the maximum thigh joint driving force by 5.29% and the maximum driving force in the calf joint by 18.05%. The comprehensive methods presented in this paper cannot only help developing four-legged laser weeding robot prototype, but also provide references for studying driving force moment and energy consumption of four-legged robot. [ABSTRACT FROM AUTHOR]