如何使用记录的数据构建地图/如何从记录的变换和激光扫描数据创建二维贴图slam

How to Build a Map Using Logged Data

如何使用记录的数据构建地图

Description: This tutorial shows you how to create a 2-D map from logged transform and laser scan data.   描述:本教程向您展示如何从记录的变换和激光扫描数据创建二维贴图。

Keywords: gmapping  关键词:gmapping

Tutorial Level: BEGINNER     教程级别:初学者

1.Building a map   绘制地图

  1. If you're working from a source checkout (as opposed to a binary installation), build gmapping:如果您是从源代码签出(而不是二进制安装)进行工作,则构建gmapping:
    rosmake gmapping
  2. Get a bag. You have a couple of choices:      您有两个选择:
    1. Create a bag with your robot

    2. Download an existing bag to test with

    Either way, you'll end up with a bag.
  3. Bring up the master:
    roscore
  4. Make sure that use_sim_time is set to true before any nodes are started:                           在启动任何节点之前,请确保将use_sim_time设置为true:
    rosparam set use_sim_time true    rosparam设置使用模拟时间为真
  5. Bring up slam_gmapping, which will take in laser scans (in this case, on the base_scan topic) and produce a map:                                                                            打开slam_gmapping,它将接受激光扫描(在本例中,在base_scan主题上),并生成一张地图:

    rosrun gmapping slam_gmapping scan:=base_scan         
    rosrun gmapping slam_gmapping scan:=基本扫描

    Note: On the PR2, the odom frame is named odom_combined. Use the command:             注意:在PR2上,odom帧被命名为odom_组合。使用以下命令:

    rosrun gmapping slam_gmapping scan:=base_scan _odom_frame:=odom_combined
    rosrun gmapping slam\u gmapping scan:=基本扫描\u odom\u帧:=odom\u组合
  6. In a new terminal, start playing back the bag file to feed data to slam_gmapping:                 在新的终端中,开始播放bag文件,以向slam_gmapping提供数据:                                 
    rosbag play --clock <name of the bag that you downloaded / created in step 2>
    rosbag play——时钟<在步骤2中下载/创建的包的名称>​​​​​​​
    Wait for rosbag to finish and exit.                  等待rosbag完成并退出。
  7. Save your new map to disk using map_saver from the map_server package:                      使用map_服务器包中的map_saver将新地图保存到磁盘:

    rosrun map_server map_saver -f <map_name>
    rosrun地图服务器地图保存程序-f<map\u name>

    You now have a map, saved locally as map.pgm. Congratulations. You can view it with any image viewer (gimp, eog, gthumb, etc.); it should look very much like                                   现在您有了一个地图,在本地保存为map.pgm。祝贺您可以使用任何图像查看器(gimp、eog、gthumb等)进行查看;看起来应该很像

     What's next? You might want to use your new map in the navigation stack, by passing your map to the map_server. As an example, if you're working with a PR2, you would supply your new map at this point in the process of bringing up the navigation stack.                     下一步是什么?您可能希望通过将地图传递给map_服务器,在导航堆栈中使用新地图。例如,如果您使用的是PR2,那么在启动导航堆栈的过程中,您将在此时提供新地图。

Downloading a test bag

  1. Download a bag file to test with here: basic_localization_stage.bag

下载测试包

下载一个bag文件以在此处进行测试:basic_localization_stage.bag

Making your own bag

  1. Bring up your robot, with laser scans and transform data published, and joystick teleoperation enabled (details will vary from robot to robot).

带上你的机器人,发布激光扫描和转换数据,并启用操纵杆遥控操作(细节因机器人而异)。

  1. Start recording scans and transforms (note that the scan topic may vary from robot to robot):
    rosbag record -O mylaserdata /base_scan /tf

    This will start writing a file in the current directory called 'mylaserdata_<DATE>-topic.bag.

开始记录扫描和变换(请注意,扫描主题可能因机器人而异):

rosbag记录-O mylaserdata/base\u scan/tf

这将开始在当前目录中写入名为“mylaserdata”\uDate>-topic.bag的文件。

  1. Drive the robot around. General advice:
    • Try to limit fast rotations, as they are hardest on the scan-matcher. It helps to lower the maximum allowed velocity from the joystick.
    • Visualize what the robot "sees" with its laser; if the laser can't see it, it won't be in the map.

      驾驶机器人四处走动。一般忠告:

      尽量限制快速旋转,因为它们在扫描匹配器上最难。它有助于降低操纵杆允许的最大速度。

      想象机器人用激光“看到”什么;如果激光看不到它,它就不会出现在地图上。

    • People walking around don't usually present a problem, unless they walk along with the robot, in view of its laser.
    • Loop closure is the hardest part; when closing a loop, be sure to drive another 5-10 meters to get plenty of overlap between the start and end of the loop.

人们四处走动通常不会出现问题,除非考虑到机器人的激光,他们与机器人一起行走。

环路闭合是最难的部分;闭合环路时,确保再行驶5-10米,以在环路的起点和终点之间获得足够的重叠。

Kill the rosbag instance, and note the name of the file that was created.

并记下创建的文件名。

Variation: watching the mapping progress     

观察映射过程

If you don't care to wait until the log playback and mapping process has finished before seeing some results, then you can watch the progress in rviz.

  • rosrun rviz rviz

  • Add a display with a map, set to the topic /map

    如果您不想等到日志回放和映射过程完成后再看到一些结果,那么可以在rviz中查看进度。

    rosrun rviz rviz

    添加带有地图的显示,设置为主题/地图

转载原文:slam_gmapping/Tutorials/MappingFromLoggedData - ROS Wiki

------------------------------------------

本篇由bciduino机器人开源项目转载,欢迎关注我们公众号:机器人开源项目。

欢迎采购相关BCI脑电模块及机器人设备。

公众号:机器人开源项目

 添加微信:18810997748魏先生

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值