admin管理员组

文章数量:1794759

【ROS

【ROS

【ROS-cartographer学习小记-01】使用自己的激光雷达思岚A1运行cartographer

  • 0、前提条件
  • 1、修改revo_Ids.lua文件
  • 3、修改demo_revo_lds.launch文件
  • 4、回到总目录下重新编译
  • 5、启动测试
    • 5.1 运行launch文件
    • 5.2 运行结果
  • 6、这个系列会不停的进行更新,直到完结!

0、前提条件

1、已经完成cartographer的安装,并且成功运行官方的数据包,如果还未成功,可以参考我写的一篇总结,我重装两次成功率100%
【ROS-cartographer安装】无数次失败,终于成功,protobuf、git速度慢、rosdep update等经验分享~~~值得参考
2、我的小车搭载的是rplidar思岚A1激光雷达,使用的是虚拟机VMware虚拟机、ubuntu16.04、ros的kinetic版本、这里为了更快的进行实验,我把场景录制成了bag包文件,直接启动激光雷达数据也可以的,但是需要去思岚的官网去下载激光雷达的驱动包,这里可以参考我之前的一篇文章ROS机器人)操作系统开发视频教程进阶-激光雷达演示(二)去配置。
3、这里提供我自己所录制的bag包文件,可以自行百度网盘下载

我一般都是把所有用到的bag文件包放入一个地址,地址为:

链接: 
提取码:i9sw 

复制这段内容后打开百度网盘手机App,操作更方便哦

~/bagfiles/

如果没有该文件夹,可以自行创建一个,创建命令为:

mkdir ~/bagfiles

1、修改revo_Ids.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 = trueTRAJECTORY_BUILDER_2D.submaps.num_range_data = 35TRAJECTORY_BUILDER_2D.min_range = 0.3TRAJECTORY_BUILDER_2D.max_range = 8.TRAJECTORY_BUILDER_2D.missing_data_ray_length = 1.TRAJECTORY_BUILDER_2D.use_imu_data = falseTRAJECTORY_BUILDER_2D.use_online_correlative_scan_matching = trueTRAJECTORY_BUILDER_2D.real_time_correlative_scan_matcher.linear_search_window = 0.1TRAJECTORY_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-1TRAJECTORY_BUILDER.collate_landmarks = onPOSE_GRAPH.optimization_problem.huber_scale = 1e2POSE_GRAPH.optimize_every_n_nodes = 35POSE_GRAPH.constraint_builder.min_score = 0.65return options

至于为什么这里参考的文章
总结就是修改了两处
1、故加上on,总共加了两句:

use_pose_extrapolator = on,TRAJECTORY_BUILDER.collate_landmarks = on

2、普遍情况下,里面的"horizontal_laser_link",改成自己激光雷达的frame_id,我的是laser,一般都是laser,其余的不要动。
正所谓普遍情况下,也就是我们的相对不太普遍,这种修改方法大多数都适用,但是使用我的bag的时候会出现底座标base_footprint与雷达坐标base_laser_link完全反方向运动,我猜测是因为我的激光雷达在安装时采用是的反向安装,所以会有一个180°之差。
在这里由于我的bag发布的话题以及tf树为:

所以,这里我们里面的"horizontal_laser_link",改成base_footprint,其余的不要动。

3、修改demo_revo_lds.launch文件

该文件路径为:

~/catkin_google_ws/src/cartographer_ros/cartographer_ros/launch/demo_revo_lds.launch

使用bag包修改后的文件为:

<!--Copyright 2016 The Cartographer AuthorsLicensed 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.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations 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="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" /><node name="playbag" pkg="rosbag" type="play"args="--clock $(arg bag_filename)" />
</launch>

不使用bag包修改后的文件,但这种我还没有验证,希望看了本篇文章验证的小伙伴留言说一下:

<!--Copyright 2016 The Cartographer AuthorsLicensed 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.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations 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、回到总目录下重新编译

cd cartographer_ws/catkin_make_isolated --install --use-ninjasource install_isolated/setup.bash

5、启动测试

5.1 运行launch文件

roslaunch cartographer_ros demo_revo_lds.launch bag_filename:=/home/xxx/bagfiles/my322.bag 

xxx为自己的系统名字

5.2 运行结果


可以看到结果好像有点糊,毕竟只是修改了配置,进行最简单的运行,后期会对cartographer进行更深入的了解,通过修改其参数配置对其建图定位结果优化

6、这个系列会不停的进行更新,直到完结!

本文标签: ROS