Tuning of a proportional-integral-derivative (PID) controller for a complex multi-joint structure, such as an exoskeleton, using conventional methods is difficult and imprecise. In this paper, an optimal PID tuning method for a 3-dimensional model of a lower-limb human exoskeleton in gait training condition is presented. The dynamic equation of the human-exoskeleton is determined using a Lagrangian approach, and its transfer function is established in a closed-loop control system. PID controller gains, initialized by the Ziegler–Nichols (Z-N) method, are used as the input to an adaptive particle swarm optimization (APSO) algorithm for minimizing the multi-joint trajectory error. The optimized controller is tested in the Gazebo virtual environment and compared with the Z-N and conventional optimization methods. The numerical analysis shows that the PID controller tuned by a combination of Z-N and APSO improves the performance of a lower-limb human exoskeleton in gait training.