使用思岚A2激光雷达结合cartographer建图算法手持建图

上篇博客按照古老师书上说的已经完成跑通谷歌的demo,这一节我将使用A2雷达建立地图,参考了文章:

https://blog.csdn.net/u014662384/article/details/103332901?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.channel_param

https://www.getit01.com/p20181212250511558/

1、将思岚的雷达驱动包放在src目录下并编译测试

catkin_make_isolated --install --use-ninja

roslaunch rplidar_ros rplidar.launch

雷达转起来后,命令窗口如下所示:

2.修改revo_lds.lua文件

文件路径:~/catkin_google_ws/src/cartographer_ros/cartographer_ros/configuration_files/revo_lds.lua
修改之前文件内容如下:

include "map_builder.lua"

include "trajectory_builder.lua"



options = {

map_builder = MAP_BUILDER,

trajectory_builder = TRAJECTORY_BUILDER,

map_frame = "map",

tracking_frame = "laser",

published_frame = "laser",

odom_frame = "odom",

provide_odom_frame = true,

publish_frame_projected_to_2d = false,

use_pose_extrapolator = on,

use_odometry = false,

use_nav_sat = false,

use_landmarks = false,

num_laser_scans = 1,

num_multi_echo_laser_scans = 0,

num_subdivisions_per_laser_scan = 1,

num_point_clouds = 0,

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 = true



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



POSE_GRAPH.optimization_problem.huber_scale = 1e2

POSE_GRAPH.optimize_every_n_nodes = 35

POSE_GRAPH.constraint_builder.min_score = 0.65



return options

 

注意:use_pose_extrapolator = on,  这个之前官方写的是true,按照我参考的博文测试,报错:

F0803 19:00:47.287873 14354 lua_parameter_dictionary.cc:410] Check failed: 1 == reference_counts_.count(key) (1 vs. 0) Key 'use_pose_extrapolator' was used the wrong number of times. [FATAL] [1596452447.288220107]: F0803 19:00:47.000000 14354 lua_parameter_dictionary.cc:410] Check failed: 1 == reference_counts_.count(key) (1 vs. 0) Key 'use_pose_extrapolator' was used the wrong number of times. *** Check failure stack trace: *** @ 0x7fd6681080cd google::LogMessage::Fail() @ 0x7fd668109f33 google::LogMessage::SendToLog() @ 0x7fd668107c28 google::LogMessage::Flush() @ 0x7fd66810a999 google::LogMessageFatal::~LogMessageFatal() @ 0x562312a188a6 (unknown) @ 0x562312a18a75 (unknown) @ 0x5623129ff0a3 (unknown) @ 0x5623129d4a33 (unknown) @ 0x5623129d25b4 (unknown) @ 0x7fd663e31b97 __libc_start_main @ 0x5623129d472a (unknown) [cartographer_node-2] process has died [pid 14354, exit code -6, cmd /home/ubuntu/catkin_google_ws/install_isolated/lib/cartographer_ros/cartographer_node -configuration_directory /home/ubuntu/catkin_google_ws/install_isolated/share/cartographer_ros/configuration_files -configuration_basename revo_lds.lua scan:=scan __name:=cartographer_node __log:=/home/ubuntu/.ros/log/9549cd64-d578-11ea-98be-28392648c2f5/cartographer_node-2.log]. log file: /home/ubuntu/.ros/log/9549cd64-d578-11ea-98be-28392648c2f5/cartographer_node-2*.log

参考国外的博文,故加上on,总共加了两句:

use_pose_extrapolator = on,

TRAJECTORY_BUILDER.collate_landmarks = on

 

里面的"horizontal_laser_link",改成自己激光雷达的frame_id,我的是laser,一般都是laser,其余的不要动。

3.修改demo_revo_lds.launch文件

定位到文件路径:~/catkin_google_ws/src/cartographer_ros/cartographer_ros/launch/demo_revo_lds.launch文件。

demo_revo_lds.launch并修改代码如下:

<!--
  Copyright 2016 The Cartographer Authors

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<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" />
  </node>

  <node name="rviz" pkg="rviz" type="rviz" required="true"
      args="-d $(find cartographer_ros)/configuration_files/demo_2d.rviz" />" 
</launch>

修改完之后,回到cartographer_ws 目录下再次编译:

catkin_make_isolated --install --use-ninja

4. 启动测试
(1)首先运行激光雷达节点launch文件

roslaunch rplidar_ros rplidar.launch

(2)运行cartographer框架

roslaunch cartographer_ros demo_revo_lds.launch

运行正常将打开rviz,并且显示正常,如下

至此,我们完成雷达的测试。我本打算今天测不好就放弃了,测试了两天多,心不甘,终于在晚上加班之际完成。不看看google,估计我就凉凉了。

 

 

 

 

 

 

 

 

 

 

 

  • 13
    点赞
  • 132
    收藏
    觉得还不错? 一键收藏
  • 15
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值