一、修改launch文件和lua配置文件
(1)修改revo_lds.lua
到目录下,打开文件
home/meng/xx/catographer_ws/src/cartographer_ros/cartographer_ros/configuration_files/revo_lds.lua
修改三个地方,如下有注释的地方,其中--为注释
tracking_frame = "laser", --horizontal_laser_link改为laser
published_frame = "laser", --horizontal_laser_link改为laser
odom_frame = "odom",
provide_odom_frame = true,
publish_frame_projected_to_2d = false,
use_pose_extrapolator = on, --此处将true改为on
本来按照这篇博客修改了四个地方:
https://blog.csdn.net/qq_38212787/article/details/107771684https://blog.csdn.net/qq_38212787/article/details/107771684第四个地方如下,这里已经给注释掉了,之后在再看看能不能改善:
TRAJECTORY_BUILDER_2D.submaps.num_range_data = 35
TRAJECTORY_BUILDER_2D.min_range = 0.3
TRAJECTORY_BUILDER_2D.max_range = 8.
TRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.translation_delta_cost_weight = 10.
TRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.rotation_delta_cost_weight = 1e-1
--TRAJECTORY_BUILDER.collate_landmarks = on --此处增加
第四个地方没有注释时会出现以下错误:
[FATAL] [1641048953.081421031]: F0101 22:55:53.000000 25001 lua_parameter_dictionary.cc:399] Check failed: HasKey(key) Key 'collate_landmarks' not in dictionary:
省略
*** Check failure stack trace: ***
@ 0x7f7afc98c0cd google::LogMessage::Fail()
@ 0x7f7afc98df33 google::LogMessage::SendToLog()
@ 0x7f7afc98bc28 google::LogMessage::Flush()
@ 0x7f7afc98e999 google::LogMessageFatal::~LogMessageFatal()
@ 0x5652b60bd25d (unknown)
@ 0x5652b60bd2ad (unknown)
@ 0x5652b60bd75f (unknown)
@ 0x5652b60df1a4 (unknown)
@ 0x5652b609c332 (unknown)
@ 0x5652b6097d90 (unknown)
@ 0x5652b6062134 (unknown)
@ 0x5652b605ff24 (unknown)
@ 0x7f7af86acbf7 __libc_start_main
@ 0x5652b6061dfa (unknown)
[cartographer_node-1] process has died [pid 25001, exit code -6, cmd /home/elfoot/unmanned_system_2021/catographer_ws/install_isolated/lib/cartographer_ros/cartographer_node -configuration_directory /home/elfoot/unmanned_system_2021/catographer_ws/install_isolated/share/cartographer_ros/configuration_files -configuration_basename revo_lds.lua scan:=scan __name:=cartographer_node __log:=/home/elfoot/.ros/log/0c683a04-6b12-11ec-a2d7-08beac26819a/cartographer_node-1.log].
抱着试一试的态度将第四个修改注释掉,接下来运行程序便可以出map了;同时说一下,下面这篇博客没有对第四个地方进行注释
(2)修改demo_revo_lds.launch
文件地址为:
xx/catographer_ws/src/cartographer_ros/cartographer_ros/launch/demo_revo_lds.launch
修改后的launch文件如下:
<launch>
<param name="/use_sim_time" value="true" />
<node name="cartographer_node" pkg="cartographer_ros"
type="cartographer_node" args="
-configuration_directory $(find cartographer_ros)/configuration_files
-configuration_basename revo_lds.lua"
output="screen">
<remap from="scan" to="scan" />
<!--horizontal_laser_2d改为scan,这里我的激光雷达发出的时scan单线话题-->
</node>
<node name="cartographer_occupancy_grid_node" pkg="cartographer_ros"
type="cartographer_occupancy_grid_node" args="-resolution 0.05" />
<node name="rviz" pkg="rviz" type="rviz" required="true"
args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />
<!--删除了一个rosbag play节点-->
</launch>
(3)重新编译
catkin_make_isolated --install --use-ninja
因为launch文件里面加载了配置文件“configuration_directory”,好像只更改launch文件也需要重新编译
二、使用思岚rplidar雷达进行cartographer建图
(1)启动节点
先启动rplidar驱动
cd xxx/RPlidar_ws
source devel/setup.bash
roslaunch rplidar_ros view_rplidar_s1.launch
后启动cartographer_ros节点
cd xxx/catographer_ws
source install_isolated/setup.bash
roslaunch cartographer_ros demo_revo_lds.launch
(2)建图效果
建图效果如下,环境比较简陋,用手举着,在我工位附近