The optimal search algorithm based on double-difference carrier phase is one of the methods to solve the attitude angle. An adaptive weighted particle swarm optimization (AWPSO) algorithm based on the Chi-square test is proposed to solve the attitude angle of ultra-short baseline. We establish the fitness function by introducing the relationship between attitude angle and baseline vector into the observation equations of double-difference carrier phase. Searching the attitude according to the fitness model instead of calculating the angle directly, which avoids solving the integer ambiguity. Using adaptive inertial weights and synchronous adaptive learning factors to speed up the convergence of attitude search. Constructing the candidate solution sequence to save the search result and calculating the Mahalanobis distance of the candidate solution. The local optimal solution is eliminated by the Chi-square test, and the attitude angle is gained by weighting the filtered sequence. Various static experimental results show that the new algorithm performs better than the direct solution method, the least square estimation method, and the PSO-based attitude solution method. The RMS error of yaw angle and pitch angle is 0.245° and 0.236° directly at 0.575 m baseline.