A Lightweight Real-Time 3D LiDAR SLAM for Autonomous Vehicles in Large-Scale Urban Environment

For autonomous vehicles, real-time localization and mapping in the unknown environment is very important. In this paper, a fast and lightweight 3D LiDAR simultaneously localization and mapping (SLAM) is presented for the localization of autonomous vehicles in large-scale urban environments. A novel encoding approach based on depth information is proposed to encode unordered point clouds with various resolutions, which avoids missing dimensional information in the projection of point clouds onto a 2D plane. Principal components analysis (PCA) is modified by dynamically selecting neighborhood points according to the encoded depth information to fit the local plane with less time consuming. The threshold and the number of feature points are adaptive according to distance intervals, results in sparse feature points extracted and uniformly distributed in the three-dimensional space. The extracted significant feature points improve the accuracy of the odometer and speed up the alignment of the point cloud. The effectiveness and robustness of the proposed algorithm are verified on the KITTI odometry benchmark and MVSECD. A fast runtime of 21 ms is obtained for the odometer estimation. Compared to several typical state-of-the-art methods on the KITTI odometry benchmark, the proposed approach reduces translation errors by at least 19% and rotation errors by 7.1%.


I. INTRODUCTION
As one of core techniques in autonomous driving [1], localization and navigation of vehicles have been a research hotspot. The algorithm needs to process a large amount of data [2], and the lightweight algorithm is especially important. These technologies are of great value to the automobile industry [3]. Localization and navigation generally can be realized by high-definition maps and GPS. However, highdefinition maps and GPS are not always available in all urban scenarios, such as out of service induced by tunnels, overpasses, shielding of tall buildings, and technical problems. The localization in the absence of high-definition maps and GPS can be addressed by the ego-motion estimation of SLAM. Stable technical algorithms provide security for The associate editor coordinating the review of this manuscript and approving it for publication was Mohammad Alshabi . autonomous driving [4]. SLAM is capable of solving position estimation problems of vehicles in unknown environment, and constructs the map of the surrounding environment. It generally can be classified by visual SLAM [5], [6], [7] and LiDAR SLAM [8], [9], [10], [11], [12] according to sensors (camera, LiDAR) employed. Passively acquiring information from cameras, visual SLAM is greatly affected by the illumination and texture conditions of surrounding environment. In contrast, 3D LiDAR SLAM relies on the active measurement of the geometric information of environment by LiDAR rather than texture information. Therefore, LiDAR SLAM is more robust and widely used in outdoor scenarios for practical applications. A complete LiDAR SLAM system includes a pose estimation odometer in the front-end and a global pose graph optimization in the back-end. The point cloud registration is the core in the front-end, from which the vehicle pose can be obtained. Typical approaches include Iterative VOLUME 11, 2023 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ Closest Point (ICP) [13], Normalized Distribution Transform (NDT) [14] and feature-based approaches. The classic ICP pairs the nearest points on the basis of Euclidean distance, and constantly optimizes the point-to-point correspondence in an iterative manner to obtain the transformation of the vehicle. However, the transformation of each point pair in a frame point cloud requires a large amount of computation. The NDT divides the point cloud into many small grids and then calculates the probability distribution between grids. The continuous differentiable probability density is employed to estimate the ego-motion between continuous LiDAR frames. However, the algorithm is sensitive to the rotation angle and the registration accuracy is affected by the grid size. Featurebased approaches only extract point clouds with features for matching to achieve excellent real-time performance together with high precision. However, the feature extraction approach is still a challenge for autonomous vehicles in urban scenes where geometric features are not obvious. Based on the above approaches, several 3D LiDAR SLAM methods in outdoor have been proposed. LOAM [8] proposed point-to-line and point-to-plane registration of point clouds based on feature points to achieve an accurate odometer. However, it produced significant drift in the case of few geometric features for large-scale environments due to the lack of back-end optimization. LeGO-LOAM [9] proposed a fast and lightweight SLAM approach utilizing ground optimization, but the absence of ground point clouds brought more errors in the odometer. HDL_GRAPH_SLAM [10] is a 3D LiDAR SLAM framework based on graph optimization with loopback, which can fuse IMU, GPS and road constraints, etc., but the scan-to-scan point cloud registration method of front-end odometer is not accurate enough. LIOM [11] proposed a low drift and robust LiDAR inertial odometer and mapping method in large-scale fast-moving environment, but it has a large memory occupation and poor time performance. These solutions still remain drawbacks in large-scale urban environments.
In this paper, we focus on robust real-time localization and mapping of autonomous vehicles in complex large-scale urban environments. The number of the input point clouds is cut down by the removal of ground points based on plane fitting. Then the preprocessed unordered point clouds are encoded according to the depth information rather than being projected onto 2D plane. A robust dual-adaptive feature extraction algorithm based on the encoded depth information is proposed by modifying PCA. The pose of the vehicle is estimated by registering the extracted edge and plane points. Finally, a two-step loop detection is used to optimize the global map with eliminated cumulative error. The effectiveness and robustness of our system has been verified on the datasets KITTI [15] and MVSECD [16]. The main contributions of this paper are as follows: 1) Unordered point clouds are encoded using the depth information, which avoids the missing of dimensional information induced by the projection of point clouds onto 2D plane. The encoding is adaptive to kinds of resolution of point clouds without ordering point clouds by layers.
2) The approach of selecting neighborhood points in PCA is improved to dynamically select points according to the encoded depth information to fit the local plane, which can effectively reduce the time cost of the algorithm compared with the original PCA of selecting fixed points. 3) An approach is proposed for adaptively selecting the threshold and number of feature points in different distance intervals. This approach extracts more uniform sparse feature points in three-dimensional space than the traditional fixed number feature extraction method, which improves the odometer accuracy and reduces the time cost.

II. RELATED WORK
In 3D LiDAR SLAM, pose estimation is mainly accomplished by registering point clouds of two frames. Common point cloud registration in SLAM includes ICP [13] direct registration and feature point registration. ICP does not need to sort the input point cloud and only needs to find the nearest point to register, however it takes a lot of time to register each point. The method based on feature points needs to order the input disordered point cloud, however it can register quickly. The classical ICP iteration solves the point-to-point transformation. In order to improve the speed and accuracy of point cloud registration, the distance from registered point to plane is used as the error measure to pair points with local planes. GICP [17] modified the loss model by the matching between two local planes by combining the point-to-plane ICP and plane-to-plane ICP approaches. IMLS-SLAM [18] proposed an implicit moving least squares-based point-to-model alignment method that aligns sampled points with an implicit surface by extracting observable sampling points. These works improve ICP to some extent, however the real-time performance is still affected when large amounts of point cloud data are processed. Unlike ICP method, the feature point method only registers a small number of extracted feature points, thus registration is fast. LOAM [8] is a classical outdoor 3D LiDAR SLAM, which is the first to propose a method based on feature point registration. The input point clouds are ordered according to the angular resolution of the lidar. LOAM calculates the smoothness of several neighborhood point clouds on the same line beam to extract edge features and plane features, and optimizes the point-to-line and point-to-plane distance residuals to obtain the odometer poses. On the basis of LOAM, LeGO-LOAM [9] proposed a lightweight SLAM system. It ordered input disordered point clouds by projecting point clouds as distance images. Then, a two-step L-M nonlinear optimization was carried out on the segmented ground points and edge points, and the transformation coefficients of the two sets of point clouds were sequentially solved. However, projecting a point cloud onto 2D plane will lose one dimension information. Lio-sam [19] is a fusion method based on feature points that combines IMU and GPS factors, but it required joint calibration of sensors. F-loam [20] extracts the same number of feature points at different distances as several works above. It employed a noniterative two-stage distortion compensation method to replace the iterative distortion compensation method, providing high computational efficiency and accurate pose. MULLS [21] proposed multi-metric linear least square iterative closest points algorithm based on the classified feature points. Principal components analysis (PCA) approach is employed to extract six fine features, including ground points, facade, roof pillar, beam and vertex. The feature points were classified for point-to-point, point-to-line and point-to-plane ICP registration to obtain a low drift and multifunctional pure LiDAR SLAM system.

III. FRAMEWORK OVERVIEW
The framework of the system proposed in this paper is shown in Figure 1, where the front-end acquires point cloud data from the sensors and pre-processes the raw point cloud to segment ground points. Non-ground points are ordered using depth information. Edge and plane features are extracted from the non-ground points by adaptive extraction method. The relative poses of the vehicle movements are obtained based on the alignment of the feature points in two consecutive frames. The odometer of the vehicle can be estimated by accumulating relative positions over time. The back-end receives the position from the odometer and judges that whether the vehicle has reached its previous position. Finally, a graphbased optimization approach is used to eliminate errors in the matching process to obtain globally consistent trajectories and mapping.

A. GROUND SEGMENTATION
Ground points generically occupy a large proportion of 3D point clouds recorded by autonomous vehicles. The number of point clouds can be reduced by ground segmentation on the input point clouds. The traditional ground segmentation methods include RANSAC [22] and the ray ground filter method [23]. RANSAC estimates model parameters by a random sample of observed data. Ray Ground Filter algorithm calculates the change of point radius on the same angle to acquire ground points. However, the above algorithms randomly select points from the whole point cloud, leading to slow runtime and segmentation errors. In this paper, we employ a fast ground filtering method [24], which selects seed point set as the prior value to speed up the algorithm. Firstly, a frame of point cloud is divided into n segments along the moving direction of the vehicle. The area in the x-axis direction is divided into a number of sub planes. Multiple sub planes are merged into one plane to reduce segmentation errors brought by the change of ground slope. Then, we select points with small values along the z-axis and calculate their average height H m . The term th z is the threshold to select seed point. A point is selected as a seed point set S ∈ R 3 when its z value is less than the threshold H m + th z . The seed points are taken as the prior of the initial plane to speed up the plane fitting. The set of seed points is fitted into the initial plane. The cross-projection distance between each point and the initial plane is calculated. As shown in Figure 2 (a), if the distance is smaller than the artificial threshold th g , the point will be taken as the ground point. The mathematical expression used to estimate the plane model is as follows: By expressing it in vector form: n is solved by the covariance M ∈ R 3×3 and M describes the dispersion of the seed point set of each sub region:  where s ∈ R 3 is the mean of all points The normal n is perpendicular to the plane, which indicates the direction with the least variance. The parameter d can be solved by replacing p in equation (1) with s. The vertical distance between each point and the initial plane is calculated to judge whether it belongs to the next plane by comparing with the threshold Th dist .Finally, all ground points after classification are regarded as the seed point set in the next iteration for iterative optimization. The merged ground point cloud by the sub-planes using the above algorithm is shown in Figure 2 (b).

B. POINT CLOUD ORDERED ENCODING
The input data acquired from LiDAR are usually unordered 3D point clouds, which can be transformed into organized point cloud sequence by projecting onto a 2D plane or classifying according angular information. Here, the depth information is adopted to organize the unordered input point cloud avoiding the loss of dimensional information or dependence on the resolution of LiDAR. The 3D scan is divided into N r rings by equal intervals in the radial direction of the sensor coordinates. The index of rings is calculated as follows: where [·] is an integer symbol, T is the radial gap distance between the different rings, D j is the depth information of each non-ground point cloud When the interval is too large, the feature points are distributed sparsely, which affects the accuracy of odometer. In this paper, we use T = 4 m and N r = 21. According to the distance value D j of each point, the point p N j is divided into corresponding rings N j (as shown in Figure 3). The point clouds subset of each ring is represented as follows: where ρ i is the set of points belonging to the ith ring, After the point cloud is partitioned, each ring R(i) is represented by a point cloud subset as: Thus, the point clouds are classified to be sets with different distance indices D id , and further processing on the point clouds are performed according to the index.

C. COMPUTING DISPERSION BASED ON MODIFIED PCA
Singular value points in the non-ground point cloud have adverse effect on the localization accuracy of the odometer due to no matching points during registering. Therefore, Singular value points need to be removed before feature extraction. Euclidean clustering method is employed to classify objects by clustering non-ground points. Outliers are classified and removed when the number of clustered point clouds is less than the threshold. The removal of outliers before feature extraction can reduce redundantpoints and increase the feasibility of feature points. LOAM [8] proposed a feature extraction method to calculate the local smoothness of several neighborhood points on the same beam. However, it may fail in geometric degradation scenarios due to equal smoothness values. In order to improve the robustness of feature extraction algorithm, principal components analysis (PCA) algorithm is improved to extract point cloud features. In the original PCA algorithm, a fixed number of neighborhood points is used to fit the local plane. We improved the method by adaptively selecting neighborhood points according to distance intervals to fit the local plane. The number of neighborhood points k is defined as: k = α − [βD id (i)], where [·] is an integer symbol, α and β are linear parameters. To reduce the searching computational cost, point clouds are stored in 3D KD-trees. The local domain dispersion is calculated by using these neighborhood points. The distance between the selected neighborhood point p i (x i , y i , z i ) and the local center is: where k is the total number of neighborhood points and i = 1, 2, 3, . . . , k. Then the covariance matrix of the following k points are calculated by: The eigenvalues λ i (i = 1, 2, 3) and the corresponding eigenvectors N i (i = 1, 2, 3) of the covariance matrix C are determined by singular value decomposition (SVD). The eigenvalues are sorted to obtain λ 1 > λ 2 > λ 3 . The eigenvector N 1 corresponding to the maximum eigenvalue λ 1 is the primary vector, and the N 3 corresponding to the λ 3 is the normal vector. These eigenvalues and eigenvectors can be used to extract edge and plane features of local point clouds. According to the relationship between eigenvalues, local linearity and planarity can be defined as [25]: where δ is the planarity and ε is the linearity. The feature points are selected based on the values of δ and ε. The modified PCA algorithm speeds up the feature extraction compared to the original PCA method. The feature extraction using adaptive selection of neighborhood points (k = α − [βD id (i)] , α = 10, β = 0.1) is 4 ms faster than the fixed points (k = 5).

D. ADAPTIVE SELECTION OF FEATURE POINTS
Generally, the selection threshold of feature points is fixed, together with the number of feature points (For example, [8] selects 20 edge points). However, point clouds obtained by LiDAR scanning are sparse at long distance and dense at short distance, resulting the nonuniform distribution of feature points. The nonuniform distribution has adverse effect on the accuracy of the odometer and the stability of the SLAM system. Therefore, we propose an adaptive selection method of feature points based on distance. According to Section 3.3, the index D id of each point cloud is obtained in the encoding stage. The threshold χ of feature point selection is adaptively calculated according to the distance intervals as: where is k the distance number of each point, R k is the range with the distance number k obtained via equation (4), γ is the linear factor. In general, the value of γ plane is set larger than γ edge due to more plane points needed by the pose estimation. As shown in Figure 4, the edge p ε and plane p S feature points are selected by comparing the obtained threshold and local dispersion values according to Equations (9) and (10): Different number of feature points are dynamically selected in different distance intervals. The adaptive number of feature points is mathematically expressed as follows: num = ω t R k , ω < 1, num is an integer. As shown in Figure 5, the feature points obtained by the adaptive selection method are sparser than those obtained by the fixed selection method. The extracted feature points are uniformly distributed in six

Algorithm 1 Feature Extraction
Parameters: p N non-ground point cloud; p current point; δ/ε planarity / linearity value; χ e /χ p edge/ plane point selection threshold; N e /N p number of edge/ plane features to be selected; N * e /N * P number of edge / plane features already selected; p ε /p S edge / plane feature points. Input: p N , p ∈ p N Output: p ε , p S 1 for every Rang ID i = 0 to n do 2 δ, ε ← PCA calculation features (p i ) 3  degrees of freedom. The uniformly distributed feature points in the space of six dimensions brings constraints on each degree of freedom, and improves the accuracy of the odometer and the stability of the SLAM system. The complete process of feature extraction algorithm is shown in algorithm 1.

E. UPDATE MODEL
Pose estimation is to align the current edge feature points and plane feature points in the world coordinate of global map. In order to speed up the search of corresponding points, edge and plane feature points are stored in KD-tree. The world VOLUME 11, 2023 coordinate system is marked as and the LiDAR coordinate system is marked as L. The state transition relationship of a vehicle can be expressed as: By the Lie algebra, the state transformation of the six degrees of freedom is expressed as follows: where ρ and φ respectively represent the corresponding translation and rotation in the tangent vector, Lie algebras and Lie groups are transformed by exponential mapping and logarithmic mapping [24]. The transformation of Lie group T L = [R, t] ∈ SE(3) contains a rotation matrix R ∈ SO(3) and a translation vector t ∈ R 3 . The mapping relationship between the rotation matrix and the translation vector is: where J is the Jacobian matrix [26], which is defined as: θ is the module length of ξ k , and a is a direction vector of ξ k with a length of 1, ||a|| = 1.
The status update model of the vehicle is as follows: δξ k is the increment of pose, which is obtained through continuous iterative optimization.

F. POSE ESTIMATION
The point cloud is transformed into the same coordinate system to estimate odometer pose. The edge features ℓ εk ϵP are transformed to the world coordinate system˜ε k . Two edge points ( , b ) need to be found in the world coordinate system. These two points are connected into a straight line to construct point-to-line residuals. First, five nearby edge points are searched in the world coordinate system. Then, the local center points of the five points are calculated according to equation (7). Finally, the point in front of the center is selected using and the point behind is selected b using. The distance residual equation from point to line is constructed as follows: Similarly, the plane feature point ℓ Sk ϵP are transformed to the world coordinate systemS k . Three nearby plane points ( S , S , S ) are searched in the world coordinate system to form a plane. The residual equation of the distance from the point to the plane is as follows: We combine line residuals and plane residuals to obtain the loss function for pose optimization as follows: The nonlinear optimization problem is solved by Gauss Newton method. A first-order Taylor expansion is carried out to solve the increment as follows: The incremental equation is rewritten as follows: here J is Jacobian matrix, H is a Hessian matrix defined as H = J(x)J T (x), x is the incremental amount, and g= −J(x)f (x). The nonlinear problem is transformed into iterative solution increment x. The Jacobian matrix J ε of edge residual can be calculated by: the Jacobian J C can be estimated by applying left perturbation model with δξ ϵ se(3) 12598 VOLUME 11, 2023 Similarly, the plane Jacobian matrix can be obtained The incremental equation is solved by the Jacobian matrix, of which increments is optimized iteratively until the equation converges.

G. BACK-END OPTIMIZATION
The long-term odometer continuously produces cumulative errors, resulting in poor global mapping. The cumulative error can be eliminated by loop detection and then global optimization of the map. In order to accelerate the map optimization, we adopt the approach based on key frames during loop detection and global optimization. When the attitude change between two frames exceeds a certain threshold, the current frame is selected as the key frame. A frame similar to the current frame is omitted in the historical key frame. The relative poses of two similar frames are added to the graph optimization as constrained edges. We use a two-step loop detection method. Firstly, the fast and efficient loop detection approach Scan Context [27] is used to find the closed-loop candidate frame from the historical key frame. Scan Context introduces a ''rotation invariance'' descriptor to quickly detect loops occurring in different directions. Then, ICP is used to match the current frame with the candidate frame to get the score between the two frames. As shown in Figure 6, a loop occurs in two frames if the score is less than a preset threshold. The relative position between the two frames of the loop is added to the graph optimization system GTSAM [28] as a constrained edge. This optimization system can effectively optimize mapping to eliminate cumulative errors. Historical position and global mapping are updated accordingly.

V. EXPERIMENTAL EVALUATION A. TESTING FRONT-END ODOMETRY IN KITTI
We first validate the accuracy and effectiveness of the front-end odometer in the proposed system on the KITTI odometry benchmark [15]. The data acquisition platform for the KITTI dataset is fitted with two grey-scale cameras, two color cameras, a Velodyne HDL-64E LIDAR, and a GPS navigation system. In the testing, only data from the LIDAR were used. The dataset was collected from large complex scenes including urban, rural and highway. Sequences 00-10, which provided ground truth values, were chosen to evaluate the algorithm. There are 23,201 frames and 22 km of track length in 11 sequences. The accuracy of the odometer was tested using the odometer metric provided by KITTI. The translation and rotation errors were calculated for different lengths, specifically, every 100 m up to 800 m. The average of the errors ARE and ATE defined by the KITTI odometry benchmark are indicators of the average rotational error and average translation error, respectively. The smaller value indicates better accuracy of the algorithm. The proposed algorithm is compared with typical state-of-the-art odometers ALOAM, FLOAM [20] and SUMA [29]. The results of ALOAM are from the paper [12] and the results of SUMA are from its original paper. In Table 1, the average translation error of our method on 11 sequences is 59% smaller than SUMA, 71% smaller than ALOAM and 19% smaller than FLOAM. The average rotation error is 42% smaller than SUMA, 69% smaller than ALOAM and 7.1% smaller than FLOAM. The comparison shows that ours is more accurate than the above methods. The localization error of our algorithm is smaller, especially in large urban environments such as the 00 sequence (The trajectory length of 00 sequence is 3741m).
The proposed odometry method (without the use of loop detection) is compared with the state-of-the-art algorithm FLOAM on the trajectory. Figure 7 shows a comparison of three trajectories among our algorithm, FLOAM and ground truth on 11 sequences. The solid red line is the track of our algorithm, the solid blue line is the FLOAM odometer track, and the dotted green line is the ground truth from GPS/INS. As the proposed algorithm removes some redundant points. The extracted feature points are more uniformly distributed in six degrees of freedom. Therefore, our algorithm is closer to the ground truth than FLOAM on most sequences. All trajectories essentially coincide with the ground truth. Figure 8 shows the accuracy of the proposed odometer estimate, we compare the absolute pose errors (APE) estimated by the odometer between FLOAM and the proposed algorithm. The APE of the proposed algorithm is smaller than FLOAM, our algorithm is more accurate. The error has a smaller range of fluctuations, our system is more stable. The proposed algorithm is also smaller than FLOAM in other evaluation metrics, including root mean square error (RMSE) and standard deviation (STD). Experiments prove that the proposed algorithm can accurately locate in large-scale urban environment.

B. SLAM SYSTEM ROBUSTNESS EXPERIMENTS
We have chosen three representative urban scenario sequences 00, 05 and 07 from the KITTI odometry benchmark to analyze. Figure 9 shows the results of the mapping VOLUME 11, 2023   created by the SLAM system in a large urban environment with KITTI 00 sequences, and the errors in the position and direction of the mapping. The environment 00 sequence is characterized by a large urban area and a complex environment, containing most typical urban scenes with moving objects such as moving vehicles, cyclists and pedestrians,  all of which have impacts on positioning accuracy. The proposed algorithm is able to cope with the above scenarios with moving objects. The localization error of the algorithm is small in the x, y and yaw directions. As shown in Figure 9, the 2D pose components in x, y, and yaw are approaching to the ground truth, while some errors exist in altitude, roll, and pitch directions. The errors can be attributed to the difficulty of capturing slope and transient directional changes by LiDAR. The localization accuracy is less affected in flat urban environments. Therefore, the proposed SLAM system achieves accurate localization in large-scale urban environment. VOLUME 11, 2023   The trajectory of the vehicle is curved in the KITTI 05 sequence with a length of 2,223 m. The vehicle passing the same crossroads from different directions leads to the difficulty of loop detection. Scan Context can effectively detect loops in the above scenario due to the induction of rotation invariants descriptor. As shown in Figure 10, the proposed system can build 3D point cloud map in KITTI 05 scenario which is basically consistent with the real environment. The localization accuracies in x, y and yaw directions approach the ground truth. As shown in Figure 11, sequence 07 is another urban scenario different from sequence 05. The vehicle circles the urban and comes back to its origin in sequence 07. The proposed system locates accurately and builds lowdrift 3D point cloud maps in this scenario. The testing results show that the system can accurately locate and mapping in three different urban scenarios of KITTI.
To verify feasibility of the feature extraction algorithm on LiDAR with different resolutions. The proposed algorithm was tested on MVSECD [16] datasets MVSECD, in which the horizontal and vertical resolutions of LiDAR are different from KITTI's. As shown in Figure 12, The solid blue line is the trajectory of our algorithm, and the red line is the ground truth. Our system achieves excellent positioning accuracy in different urban scenarios. The trajectories obtained by the proposed system are approaching to the ground truth in Day 1 and 2, which verifies the effectiveness of the feature point extraction method using depth information without dependence on LiDAR resolution and the robustness of the proposed SLAM system applied in complex urban environments.

C. RUNTIME ANALYSIS
The real-time performance of the proposed SLAM system was tested on KITTI sequence 00. The running time of our system is compared with that of ALOAM and FLOAM. We conducted the experiments on a PC platform with Intel Core i7-10700 2.90GHz CPU, the testing environment is based on ROS Melodic and Ubuntu 18.04 LTS. In the frontend, the running time of ground segmentation, feature extraction and range attitude estimation were tested respectively. In the back-end, loop detection and pose graph optimization were combined as one module to test the time. As he results shown in Table 2, the average runtimes of running ground segmentation module, feature extraction module, and odometer position estimation module are 26, 29, and 21 ms, respectively. The whole front-end costs an average of 76 ms. The proposed feature extraction algorithm using adaptive selection manner extracts fewer points compared with ALOAM and FLOAM. Therefore, the pose estimation in our system costs less time. The running time of the front-end odometer in our system is 23 ms faster than that of ALOAM. The front-ends in the proposed system and FLOAM cost almost equal time. As the number of point clouds increases during the mapping process, the mapping time of FLOAM and ALOAM are increasing. However, our system has fewer feature points, so the real-time mapping is better. 1 For the back-end, loop occurs after the vehicle running for some time. The map is optimized only when the loops occur. We use a lower frequency of 2 Hz to detect loop. The whole back-end costs an average of 290 ms.
The back-end costs more time compared to the front-end due to the need of optimizing and updating the global map and poses. It is necessary to be noted that the optimization and update of global map performs only when the loop occurs rather than every frame. Therefore, its effect on the real-time performance of the system can be neglected. The testing results show that the proposed SLAM system has achieved excellent real-time performance in all the above testing. The system can be applied to autonomous vehicles with resource constraint devices.

VI. CONCLUSION
A lightweight real-time 3D LiDAR SLAM system is presented to solve the localization and mapping problems of autonomous vehicles in large and complex urban environments. The proposed system consists of ground segmentation, depth encoding, features extraction based on modified PCA and loop detection. The disordered non-ground point clouds are encoded according to depth information. The encoded point clouds maintain three-dimensional information without being projected onto a 2D plane. This coding approach can be applied to LiDAR with different resolutions. The adaptive selection approach of neighbor points in modified PCA improves the speed of feature extraction. Uniformly distributed points can be extracted in six degrees of freedom to increase the localization accuracy of the odometer by selecting different number of feature points according to the distance. The average translation error of the odometer is only 1.17% and the average rotation error is only 0.052 (degree/1m) on KITTI dataset. Due to sparse points extracted by the adaptive feature extraction approach, the pose estimation in the odometer costs only 21 ms. The whole front-end costs 76 ms, achieving real-time performance. Scan Context and ICP are employed for loop detection in order to eliminate mapping accumulation errors. A graph-based optimization method is used to optimize the global mapping. To demonstrate the robustness of the proposed system in different urban scenarios, the performance of the system was evaluated on KITTI and MVSECD datasets. The localization