Welcome to WLR722 LiDAR repository
2. Lio Sam Algorithm Mapping
Lio Sam Algorithm Mapping
This algorithm has been successfully compiled and run on the Orin-Nano motherboard. Orin-Nano motherboard system environment: Ubuntu22.04+ROS2-Humble.
Startup Command
Open Terminal 1 and enter the following command to start the Lio-Sam mapping program,
ros2 launch lio_sam run.launch.py
After the program starts, an rviz will open to display the mapping process,
Open Terminal 2 and enter the following command to start the 32-line lidar,
xxxxxxxxxxros2 launch vanjee_lidar_sdk start.py
Then, slowly move the lidar. The point cloud map in rviz will be gradually generated, as shown in the following figure,

Saving the Map
Open Terminal 3 and enter the following command to save the map,
xxxxxxxxxxros2 service call /lio_sam/save_map lio_sam/srv/SaveMap "{resolution: 0.5 , destination: /Downloads/LioSam}"
Here, resolution represents the sampling rate, and destination represents the folder to save. Given /Downloads/LioSam here, it means the saved point cloud map will be placed in the ~/Dowloads/LioSam directory. The code adds a ~.
Then, we can see in the ~/Dowloads/LioSam directory that 5 .pcd files have been generated. Among them, GlobalMap.pcd is the global point cloud map. You can use the following command in the graphical interface to view the global point cloud map,
xxxxxxxxxxcd ~/Dowloads/LioSam # Modify the path here according to the actual save addresspcl_viewer GlobalMap.pcd
The parameter table is as follows,
x/** ros__parameters
# Topics pointCloudTopic"/rslidar_points" # Point cloud data imuTopic"/vanjee_lidar_imu_packets" # IMU data odomTopic"odometry/imu" # IMU pre-preintegration odometry, same frequency as IMU gpsTopic"odometry/gpsz" # GPS odometry topic from navsat, see module_navsat.launch file
# Frames lidarFrame"vanjee_lidar" baselinkFrame"base_link" odometryFrame"odom" mapFrame"map"
# GPS Settings useImuHeadingInitializationfalse # if using GPS data, set to "true" useGpsElevationfalse # if GPS elevation is bad, set to "false" gpsCovThreshold2.0 # m^2, threshold for using GPS data poseCovThreshold25.0 # m^2, threshold for using GPS data
# Export settings savePCDtrue # https://github.com/TixiaoShan/LIO-SAM/issues/3
# Sensor Settings sensorvelodyne # lidar sensor type, either 'velodyne', 'ouster' or 'livox' N_SCAN32 # number of lidar channels (i.e., Velodyne/Ouster: 16, 32, 64, 128, Livox Horizon: 6) Horizon_SCAN2000 # lidar horizontal resolution (Velodyne:1800, Ouster:512,1024,2048, Livox Horizon: 4000) downsampleRate1 # default: 1. Downsample your data if too many # points. i.e., 16 = 64 / 4, 16 = 16 / 1 lidarMinRange0.3 # default: 1.0, minimum lidar range to be used lidarMaxRange40.0 # default: 1000.0, maximum lidar range to be used maxFeatureNum300
# IMU Settings imuAccNoise3.9939570888238808e-03 imuGyrNoise1.5636343949698187e-03 imuAccBiasN6.4356659353532566e-05 imuGyrBiasN3.5640318696367613e-05
imuGravity9.80511 imuRPYWeight0.01
maxVel50.0 maxIter4 maxNoise0.01 accGating0.5 gyrGating0.5
extrinsicTrans 0.0 0.0 0.0 extrinsicRot1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0 extrinsicRPY1.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 1.0
# LOAM feature threshold edgeThreshold0.1 surfThreshold0.1 edgeFeatureMinValidNum5 surfFeatureMinValidNum30
# voxel filter paprams odometrySurfLeafSize0.2 # default: 0.4 - outdoor, 0.2 - indoor mappingCornerLeafSize0.1 # default: 0.2 - outdoor, 0.1 - indoor mappingSurfLeafSize0.2 # default: 0.4 - outdoor, 0.2 - indoor
# robot motion constraint (in case you are using a 2D robot) z_tollerance1000.0 # meters rotation_tollerance1000.0 # radians
# CPU Params numberOfCores3 # number of cores for mapping optimization mappingProcessInterval0. # seconds, regulate mapping frequency
# Surrounding map surroundingkeyframeAddingDistThreshold1.0 # meters, regulate keyframe adding threshold surroundingkeyframeAddingAngleThreshold0.2 # radians, regulate keyframe adding threshold surroundingKeyframeDensity2.0 # meters, downsample surrounding keyframe poses surroundingKeyframeSearchRadius50.0 # meters, within n meters scan-to-map optimization # (when loop closure disabled)
# Loop closure loopClosureEnableFlagfalse loopClosureFrequency1.0 # Hz, regulate loop closure constraint add frequency surroundingKeyframeSize25 # submap size (when loop closure enabled) historyKeyframeSearchRadius15.0 # meters, key frame that is within n meters from # current pose will be considerd for loop closure historyKeyframeSearchTimeDiff30.0 # seconds, key frame that is n seconds older will be # considered for loop closure historyKeyframeSearchNum25 # number of hostory key frames will be fused into a # submap for loop closure historyKeyframeFitnessScore0.3 # icp threshold, the smaller the better alignment
# Visualization globalMapVisualizationSearchRadius1000.0 # meters, global map visualization radius globalMapVisualizationPoseDensity10.0 # meters, global map visualization keyframe density globalMapVisualizationLeafSize1.0 # meters, global map visualization cloud density
Debug and modify according to actual situations.