The pulse light detecting and ranging (Lidar) can obtain rich environmental information of the target, and the centroid algorithm can obtain the distance and intensity information of the target from the echo pulse. However, there are problems of sensitivity to noise and fixed window width. Therefore, this paper proposes an adaptive triangle window-width centroid algorithm (ATWC) to improve the ranging accuracy and robustness of Lidar. This algorithm combines the characteristics of the steep front and slow back of the pulse echo waveform. The centroid calculation point is selected by an isosceles triangle envelope in the time domain and a non-isosceles triangle envelope in the intensity domain with a longer front and a shorter back. Further combined with intensity weighting, the distance and intensity values of ATWC are obtained. On the one hand, the simulation verifies the influence of window width selection on the accuracy of the centroid algorithm. On the other hand, real environment comparison experiments are conducted with traditional waveform centroid (TWC), peak ranging (PR), and adaptive threshold methods (ATM) under a pulse Lidar system constructed by our method, and our method achieves significant improvements. At different distances, when the peak signal-to-noise ratio (PSNR) is above 20 dB, the ranging error of ATWC is below 0.3 ns, which is much better than the compared algorithms. When the target is at a distance of 25 m, which is a weak echo signal environment with a PSNR of 15.6 dB, our algorithm can still achieve a ranging error of 0.56 ns, and the detection success rate can still reach 88.8%. In addition, our method can obtain a clearer intensity image, which further demonstrates the research potential and practical utility of the proposed method.