Welcome to WLR722 LiDAR repository
1. Cartographer 2D Mapping
Cartographer 2D Mapping
Algorithm Installation
Taking ros2-humble as an example, enter the following command in the terminal to install,
xxxxxxxxxx# Core packagessudo apt install ros-humble-cartographer ros-humble-cartographer-ros -y# Supplementary packagessudo apt install ros-humble-cartographer-rviz -ysudo apt install ros-humble-nav2-map-server -yTransplanting Source Code
Place the [cartographer Source Code] from the [Attachments] folder into the src directory of your workspace, then go back to the workspace directory and compile,
xxxxxxxxxxcolcon build
Starting Mapping
Terminal 1: Enter the following command to start the lidar,
xxxxxxxxxxros2 launch vanjee_lidar_sdk start.py
Terminal 2: Enter the following command to start rviz display,
xxxxxxxxxxros2 launch yahboomcar_nav display_map_launch.py
Terminal 3: Enter the following command to start Cartographer mapping,
xxxxxxxxxxros2 launch yahboomcar_nav cartographer_3d_launch.py
The rviz interface will display as follows,

Slowly move the lidar, the point cloud will move accordingly, and the grid map will update as well.
Saving the Map
Terminal 4: Enter the following command to save the map,
xxxxxxxxxxros2 launch yahboomcar_nav save_map_launch.py
The saved map is a 2D grid map used for Nav2 navigation. The saved map is located in the directory,
xxxxxxxxxxyahboomcar_nav/maps/yahboomcar.pgmMapping Parameters
The cartographer mapping parameters are located in the yahboomcar_nav directory,
xxxxxxxxxxyahboomcar_nav/params/lds_3d.lua
For the parameter table as follows,
include "map_builder.lua"include "trajectory_builder.lua"
options = { map_builder = MAP_BUILDER, trajectory_builder = TRAJECTORY_BUILDER, map_frame = "map", --Lidar coordinate system tracking_frame = "vanjee_lidar", published_frame = "base_link", odom_frame = "odom", provide_odom_frame = true, publish_frame_projected_to_2d = false, use_odometry = false, use_nav_sat = false, use_landmarks = false, num_laser_scans = 0, num_multi_echo_laser_scans = 0, num_subdivisions_per_laser_scan = 1, num_point_clouds = 1, lookup_transform_timeout_sec = 0.2, submap_publish_period_sec = 0.3, pose_publish_period_sec = 5e-3, trajectory_publish_period_sec = 30e-3, rangefinder_sampling_ratio = 1., odometry_sampling_ratio = 1., fixed_frame_pose_sampling_ratio = 1., imu_sampling_ratio = 1., landmarks_sampling_ratio = 1.,}
MAP_BUILDER.use_trajectory_builder_2d = false--Declare it is using 3D modeMAP_BUILDER.use_trajectory_builder_3d = true--Lidar detection distanceTRAJECTORY_BUILDER_3D.min_range = 0.3TRAJECTORY_BUILDER_3D.max_range = 70.0TRAJECTORY_BUILDER_3D.num_accumulated_range_data= 1TRAJECTORY_BUILDER_3D.motion_filter.max_angle_radians = math.rad(1.0)TRAJECTORY_BUILDER_3D.voxel_filter_size = 0.05POSE_GRAPH.constraint_builder.min_score = 0.45POSE_GRAPH.constraint_builder.global_localization_min_score = 0.45
--POSE_GRAPH.optimize_every_n_nodes = 30
return options