ROS进阶学习笔记(11)- Turtlebot Navigation and SLAM

2024-01-23 03:08

本文主要是介绍ROS进阶学习笔记(11)- Turtlebot Navigation and SLAM,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

(写在前面: 这里参考rbx书中第八章和ROS社区教程进行学习,先看社区教程)

  ===  Doing the Turtlebot Navigation   ===

ref ros wiki: http://wiki.ros.org/turtlebot_navigation/Tutorials


1. Create the Data under remote control

Referring the RBX book(8.4.2 Collecting and Recording Scan Data),
then log into the TurtleBot's laptop and run:
  $ roslaunch rbx1_bringup turtlebot_minimal_create.launch
Replace the above command with the appropriate launch file for your own robot if you have one.
Next, log into the TurtleBot using another terminal window and run the command:
  $ roslaunch rbx1_bringup fake_laser.launch
(If you have a real laser scanner, you would run its launch file here instead of the fake
laser launch file.)
Next, launch the gmapping_demo.launch launch file. You can launch this file on your desktop workstation or the robot's laptop:
  $ roslaunch rbx1_nav gmapping_demo.launch
  or follow ros wiki: exbot@my_robot1:~$ roslaunch rbx1_nav gmapping_demo.launch

Then bring up RViz with the included gmapping configuration file On_Desktop:
  $ rosrun rviz rviz -d `rospack find rbx1_nav`/gmapping.rviz
  or follow ros wiki: exbot@my_desktop:~$ roslaunch turtlebot_rviz_launchers view_navigation.launch  # I used this, cuz the above causes problem.

Next, launch a teleop node On_Desktop for either the keyboard or joystick depending on your hardware:
  $ roslaunch rbx1_nav keyboard_teleop.launch

The final step is to start recording the data to a bag file. You can create the file
anywhere you like, but there is a folder called bag_files in the rbx1_nav package for
this purpose if you want to use it:
  $ roscd rbx1_nav/bag_files

Now start the recording process:
  $ rosbag record -O my_scan_data /scan /tf

where my_scan_data can be any filename you like. The only data we need to record is
the laser scan data and the tf transforms. (Thetf transform tree includes the
transformation from the /odom frame to the/base_link or/base_footprint frame
which gives us the needed odometry data.)

You are now ready to drive the robot around the area you'd like to map. Be sure to
move the robot slowly, especially when rotating. Stay relatively close to walls and
furniture so that there is always something within range of the scanner. Finally, plan to
drive a closed loop and continue past the starting point for several meters to ensure a
good overlap between the beginning and ending scan data.

Use the Steps above can let your turtlebot move under your control and create the map of the environment.


2. Create the map simutanlously.

There are at least two ways to create the map: Recording or rePlaying the bag data file. Let's see the first here and second next section.

When you are finished driving the robot, type Ctrl-C in the rosbag terminal window
to stop the recording process. Then save the current map as follows:
  $ roscd rbx1_nav/maps
  $ rosrun map_server map_saver -f my_map

where " my_map" can be any name you like. This will save the generated map into the
current directory under the name you specified on the command line. If you look at the
contents of the rbx1_nav/maps directory, you will see two new files: my_map.pgm
which is the map image and my_map.yaml that describes the dimensions of the map. It
is this latter file that you will point to in subsequent launch files when you want to usethe map for navigation.

To view the new map, you can use any image viewer program to bring up the .pgm file
created above. For example, to use the Ubuntu eog viewer ("eye of Gnome") run the

command:
  $ roscd rbx1_nav/maps
  $ eog my_map.pgm

You can zoom the map using your scroll wheel or the +/- buttons.

Here is a video demonstrating the gmapping process using Pi Robot and a Hokuyo laser scanner: http://youtu.be/7iIDdvCXIFM

3. Create the map by bag data file.

You can also create the map from the bag data you stored during the scanning phase
above. This is a useful technique since you can try out different gmapping parameters
on the same scan data without having to drive the robot around again.
当你想调试gmapping 参数的时候,不用每次都重新跑一遍机器人。

把所有的Terminal中运行的node,launch关掉;Next, turn on simulated time by setting the use_sim_time parameter to true:
  $ rosparam set use_sim_time true

Then clear the move_base parameters and re-launch the gmapping_demo.launch file
again:
  $ rosparam delete /move_base
  $ roslaunch rbx1_nav gmapping_demo.launch
You can monitor the process in RViz using the gmapping configuration file:
  $ rosrun rviz rviz -d `rospack find rbx1_nav`/gmapping.rviz
Finally, play back your recorded data:
  $ roscd rbx1_nav/bag_files
  $ rosbag play my_scan_data.bag
You will probably have to zoom and/or pan the display to keep the entire scan area in
view.
When the rosbag file has played all the way through, you save the generated map the
same way we did with the live data:
  $ roscd rbx1_nav/maps
  $ rosrun map_server map_saver -f my_map

where "my_map" can be any name you like.

This will save the generated map into the current directory under the name you specified on the command line. If you look at the
contents of the rbx1_nav/maps directory, you will see two files: my_map.pgm which is the map image and my_map.yamlthat describes the dimensions of the map. It is this latter file that you will point to in subsequent launch files when you want to use the map
for navigation.

To view the map created, you can use any image viewer program to bring up the .pgm
file created above. For example, to use the Ubuntu eog viewer ("eye of Gnome") run
the command:
  $ roscd rbx1_nav/maps
  $ eog my_map.pgm

You can zoom the map using your scroll wheel or the +/- buttons.
NOTE: Don't forget to reset the use_sim_time parameter after you are finished map
building. Use the command:
  $ rosparam set use_sim_time false


4. Conclusion

Now that your map is saved we will learn how to use it for localization in the next section.
For additional details about gmapping, take a look at the gmapping_demo.launch file
in the rbx1_nav/launch directory.  There you will see many parameters that can be
tweaked if needed.  This particular launch file is a copied from the
turtlebot_navigation package and the folks at OSRG have already dialed in the
settings that should work for you.  To learn more about each parameter, you can check
out the gmapping Wiki page.


视频: 结构化环境中机器人导航 - Navigation with Structured Env.SLA  https://youtu.be/EwNl1cfNjt4



这篇关于ROS进阶学习笔记(11)- Turtlebot Navigation and SLAM的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/635055

相关文章

从基础到进阶详解Python条件判断的实用指南

《从基础到进阶详解Python条件判断的实用指南》本文将通过15个实战案例,带你大家掌握条件判断的核心技巧,并从基础语法到高级应用一网打尽,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一... 目录​引言:条件判断为何如此重要一、基础语法:三行代码构建决策系统二、多条件分支:elif的魔法三、

Unity新手入门学习殿堂级知识详细讲解(图文)

《Unity新手入门学习殿堂级知识详细讲解(图文)》Unity是一款跨平台游戏引擎,支持2D/3D及VR/AR开发,核心功能模块包括图形、音频、物理等,通过可视化编辑器与脚本扩展实现开发,项目结构含A... 目录入门概述什么是 UnityUnity引擎基础认知编辑器核心操作Unity 编辑器项目模式分类工程

Python进阶之列表推导式的10个核心技巧

《Python进阶之列表推导式的10个核心技巧》在Python编程中,列表推导式(ListComprehension)是提升代码效率的瑞士军刀,本文将通过真实场景案例,揭示列表推导式的进阶用法,希望对... 目录一、基础语法重构:理解推导式的底层逻辑二、嵌套循环:破解多维数据处理难题三、条件表达式:实现分支

基于Python编写自动化邮件发送程序(进阶版)

《基于Python编写自动化邮件发送程序(进阶版)》在数字化时代,自动化邮件发送功能已成为企业和个人提升工作效率的重要工具,本文将使用Python编写一个简单的自动化邮件发送程序,希望对大家有所帮助... 目录理解SMTP协议基础配置开发环境构建邮件发送函数核心逻辑实现完整发送流程添加附件支持功能实现htm

Python学习笔记之getattr和hasattr用法示例详解

《Python学习笔记之getattr和hasattr用法示例详解》在Python中,hasattr()、getattr()和setattr()是一组内置函数,用于对对象的属性进行操作和查询,这篇文章... 目录1.getattr用法详解1.1 基本作用1.2 示例1.3 原理2.hasattr用法详解2.

基于Python实现进阶版PDF合并/拆分工具

《基于Python实现进阶版PDF合并/拆分工具》在数字化时代,PDF文件已成为日常工作和学习中不可或缺的一部分,本文将详细介绍一款简单易用的PDF工具,帮助用户轻松完成PDF文件的合并与拆分操作... 目录工具概述环境准备界面说明合并PDF文件拆分PDF文件高级技巧常见问题完整源代码总结在数字化时代,PD

javaSE类和对象进阶用法举例详解

《javaSE类和对象进阶用法举例详解》JavaSE的面向对象编程是软件开发中的基石,它通过类和对象的概念,实现了代码的模块化、可复用性和灵活性,:本文主要介绍javaSE类和对象进阶用法的相关资... 目录前言一、封装1.访问限定符2.包2.1包的概念2.2导入包2.3自定义包2.4常见的包二、stati

C语言进阶(预处理命令详解)

《C语言进阶(预处理命令详解)》文章讲解了宏定义规范、头文件包含方式及条件编译应用,强调带参宏需加括号避免计算错误,头文件应声明函数原型以便主函数调用,条件编译通过宏定义控制代码编译,适用于测试与模块... 目录1.宏定义1.1不带参宏1.2带参宏2.头文件的包含2.1头文件中的内容2.2工程结构3.条件编

从入门到进阶讲解Python自动化Playwright实战指南

《从入门到进阶讲解Python自动化Playwright实战指南》Playwright是针对Python语言的纯自动化工具,它可以通过单个API自动执行Chromium,Firefox和WebKit... 目录Playwright 简介核心优势安装步骤观点与案例结合Playwright 核心功能从零开始学习

深度解析Python装饰器常见用法与进阶技巧

《深度解析Python装饰器常见用法与进阶技巧》Python装饰器(Decorator)是提升代码可读性与复用性的强大工具,本文将深入解析Python装饰器的原理,常见用法,进阶技巧与最佳实践,希望可... 目录装饰器的基本原理函数装饰器的常见用法带参数的装饰器类装饰器与方法装饰器装饰器的嵌套与组合进阶技巧