谷歌cartographer+EAI的YDLIDAR-X4激光雷达建图实现(二)

这几天在做谷歌cartographer算法实现,前两天实现了谷歌cartographer室内建图的实现,不过所建之图是基于谷歌提供的博物馆的数据,我们只是将数据包下载之后复现而已,并不是我们自己实验室或者周围的地图,由上一篇博客点击打开链接实现的建图我们可以看到,在没有里程计等其他传感器的协助之下,仅仅依靠激光测距仪和算法就完成了效果甚至优于其他多传感器结合的2D地图,如此优秀的开源我们当然希望能用在我们自己的机器人或者传感器上,而不是仅仅做一下仿真。于是拿实验室的EAI的激光雷达X4来进行实验室建图。网上的教程有基于rplidar实现的,但没有找到X4的相关教程。于是自己经过摸索实现了其建图。仅供大家参考,不对之处还望指正。
博主之前的博客中有写EAI的激光雷达X4,在这里就不做过多的赘述。直奔主题:系统要求:Ubuntu16.04(kinetic)硬件要求:EAI激光雷达X4以及与电脑相连数据线,笔记本一台。

运行 launch 文件,打开 rviz 查看 X4 扫描结果。

roslaunch ydlidar lidar_view.launch

在这里插入图片描述
如上图所示则说明激光雷达调试成功,此时红色线条所示为障碍物,还不是地图。

2.安装谷歌cartographer中的三个文件夹(cartographer,cartographer_ros,ceres-solver)步骤见博主的上一篇博客。
3.对cartographer_ros文件夹中的代码及参数修改,首先修改~/slam_ws/src/cartographer_ros/cartographer_ros/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>

其实需要修改的也就是因为这里我们只是利用了激光雷达建图,并未使用机器人本体。
4.接下来对~/slam_ws/src/cartographer_ros/cartographer_ros/configuration_files目录下的revo_lds.lua文件,修改好的文件如下所示

-- 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.
 
include "map_builder.lua"
 
options = {
  map_builder = MAP_BUILDER,
  sensor_bridge={
  horizontal_laser_min_range = 0.3,
  horizontal_laser_max_range = 8.,
  horizontal_laser_missing_echo_ray_length = 1.2,
  constant_odometry_translational_variance = 0.,
  constant_odometry_rotational_variance = 0.,
},
  map_frame = "map",
  tracking_frame = "laser_frame",
  published_frame = "laser_frame",
  odom_frame = "odom",
  provide_odom_frame = true,
  use_odometry_data = false,
  use_laser_scan = true,
  use_constant_odometry_variance = false,
  constant_odometry_translational_variance = 0.,
  constant_odometry_rotational_variance = 0.,
  use_horizontal_laser = true,
  use_horizontal_multi_echo_laser = false,
  horizontal_laser_min_range = 0.3,
  horizontal_laser_max_range = 8.,
  horizontal_laser_missing_echo_ray_length = 1.,
  num_lasers_3d = 0,
  lookup_transform_timeout_sec = 0.2,
  submap_publish_period_sec = 0.3,
  pose_publish_period_sec = 5e-3,
}
 
MAP_BUILDER.use_trajectory_builder_2d = true
TRAJECTORY_BUILDER_2D.use_imu_data = false
TRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = true
SPARSE_POSE_GRAPH.optimization_problem.huber_scale = 1e2
 
return options

其中比较关键的是开始的几个frame的设置,网上转载比较多的是如下修改方式

map_frame = “map”,
tracking_frame = “laser”,
published_frame = “laser”,
odom_frame = “odom”,
这样设置的原因应该是只用了一个激光器,而不是机器人,所以用“laser”,这个“laser”也需要查看激光器在tf_tree中的名称,用实际的名称替换,否则rviz中看不到地图,因为tf有问题。之前的问题一直是tf树的问题,所以所建地图无法出来,通过查看激光雷达的在tf树中的名称如下所示
在这里插入图片描述

可以知道激光雷达的tf树名称为laser_frame,因此将tracking_frame和published_frame后的参数改成laser_frame即可。
5.运行激光雷达

roslaunch ydlidar lidar.launch

6.运行cartographer中的建图命令

roslaunch cartographer_ros demo_revo_lds.launch

结果图如下。

在这里插入图片描述

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值