# Wander_bot
ROS Gazebo仿真 控制Turtlebots实现扫地机器人算法
# 1.Problem background
The aim of this assignment is to give you a way in to writing software for controlling a (simulated) robot using the Robot Operating System (ROS).
In this assignment you will create a ROS node to drive the robot around with a simple wanderer algorithm, very like a ‘Roomba’ robot vacuum cleaner. The robot should move forward until it reaches an obstacle, then rotate in the same position until the way ahead is clear, then move forward again and repeat.
# 2.Creating a wander_bot Package
In ROS, the programs organized as packages. So, we have to create a ROS package before writing any program. To create a ROS package, we have to give a name of the package,then the dependent packages which help to compile the programs inside the package.
For example, if your package has C++ program, you have to add 'roscpp' as dependency.
Before creating the package, first switch to the src folder.
```bash
$ cd ~/catkin_ws/src
$ catkin_create_pkg wander_bot roscpp rospy std_msgs
```
Figure 1 shows the output when we execute this command.
![Figure 1. Creating the Package](https://img-blog.csdnimg.cn/385971f3ed494297bdc0dc558430637d.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQm9CbyB5ZWFo,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
Figure 1. Creating the Package
# 4.Creating a Wander.cpp
# 5.Creating a ROS wander_bot Node
# 6.Editing the CMakeLists.txt File
After saving the two files in the wander_bot/src folder, the nodes need to be compiled to create the executable. To do this, we have to edit the CMakeLists.txt file, which is not too complicated. We need to add four lines of code to CMakeLists.txt.
Figure 2 shows the additional lines of code to insert (Line 128 - 129)
![在这里插入图片描述](https://img-blog.csdnimg.cn/764eb8fd5c7d41fb9f788669273bdbff.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQm9CbyB5ZWFo,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
Figure 2. Changes to the CMakeLists.txt file (Line 128-129)
# 7.Building C++ Nodes
After saving CMakeLists.txt, we can build the source code. The command to build the nodes is catkin_make. Just switch to the workspace folder and execute the catkin_make command.
To switch to the catkin_ws folder, assume that the workspace is in the home folder.
```bash
$ cd ~/catkin_ws
```
Executing the catkin_make command to build the nodes
```bash
$ catkin_make --pkg wander_bot
```
If everything is correct, you get a message saying that the build was successful (see Figure 3).
![在这里插入图片描述](https://img-blog.csdnimg.cn/6b375a017e104b55b031fbdb06a11eaf.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQm9CbyB5ZWFo,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
Figure 3.Building Successful
So we have successfully built the nodes. Now what? We can execute these nodes, right? That is covered in the next section.
# 8.Creating Launch Files
```xml
<launch>
<param name="/use_sim_time" value="true" />
<!-- Launch turtlebot3 world -->
<include file="$(find turtlebot3_gazebo)/launch/turtlebot3_world.launch"/>
<!-- Launch stopper node -->
<node name="wander_bot" pkg="wander_bot" type="wander_bot" output="screen"/>
</launch>
```
The following is the command to execute this launch file. We can execute it from any terminal path.
```bash
$ roslaunch wander_bot wander_bot.launch
```
After the roslaunch command, use the package name and then the launch file name
![在这里插入图片描述](https://img-blog.csdnimg.cn/eb470b508b0c43bdbcff30fb4201c13d.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQm9CbyB5ZWFo,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
Figure 4. Talker and Listener working together
# 9.Visualising a Computing Graph
The rqt_graph GUI tool visualises the ROS computation graph. Use any of the launch files that we created in the previous section.
```bash
$ roslaunch wonder_bot wonder_bot.launch
```
And in another terminal, run the following.
```bash
$ rqt_graph
```
Figure 5 shows the output of this GUI tool.
![在这里插入图片描述](https://img-blog.csdnimg.cn/9eeff01e21fa4733ab07d3b7820d2163.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQm9CbyB5ZWFo,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
Figure 5. ROS Graph
Check the list of ROS topics in the system by using the following command.
```bash
$ rostopic list
```
![在这里插入图片描述](https://img-blog.csdnimg.cn/2a4e040f428e4982b997442da6b42b65.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAQm9CbyB5ZWFo,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
Figure 6. Rostopic List
# 效果视频
[video(video-GB7asKQy-1648260810233)(type-bilibili)(url-https://player.bilibili.com/player.html?aid=340032941)(image-https://img-blog.csdnimg.cn/img_convert/7aa3ea3b1f9cad6e6e188dff2d9fe7b5.png)(title-wander)]
[视频地址](https://www.bilibili.com/video/BV1U94y1Z7J1/)
热爱嵌入式的小佳同学
- 粉丝: 1w+
- 资源: 2353
最新资源
- 储能变流器三相并网电压矢量控制控制(双向充放电) 0.0~0.7s:储能向电网供电50kW 0.7 ~1.2s:电网向电池充电50kW 0.7秒电池充电切放电,电网380AC,母线电压800V,电池
- 高频注入仿真pmsm 无感控制 解决0速转矩输出问题 插入式永磁同步电机,凸极,高频注入 MATLAB simulink仿真,供研究学习
- 机械设计饺子机sw18可编辑非常好的设计图纸100%好用.zip
- 氢电混合储能系统仿真(光伏,锂电池,燃料电池) 储能共直流母线 光伏储能共交流母线 储能由氢燃料电池锂电池组成 直流母线电压稳定在800v 考虑光伏故障下系统的运行特性
- 机械设计立式超声波焊接设备sw17非常好的设计图纸100%好用.zip
- 磁链观测器(仿真+闭环代码+参考文档) 1.仿真采用simulink搭建,2018b版本 2.代码采用Keil软件编译,思路参考vesc中使用的方法,自己编写的代码能够实现0速闭环启动,并且标注有大量
- 纯Java常用方法工具类
- Ceph一些介绍和使用说明.zip
- 电气仿真 分布式电源接入对配电网的影响 分布式电源是双馈感应发电机(DFIG)实现了变速变桨控制风力涡轮机模型 (lunwen5)参考lunwen可提供
- 机械设计精密电子自动除尘生产线sw17可编辑非常好的设计图纸100%好用.zip
- 机械设计快走丝电火花线切割机床(毕设ug8+cad+说明书)非常好的设计图纸100%好用.zip
- 激光熔覆仿真comsol通过激光进行熔覆工艺进行仿真,对温度与应力进行研究 采用COMSOL中的固体传热等物理场进行耦合仿真 对激光熔覆工艺完成后的温度分布与应力分布以云图形式输出,并研究某一点温度与
- CSS3.0博客学习配套完整参考手册 v4.2.4
- 全新版本码支付个人免签支付系统源码
- 西门子变频器 SINAMICS STARTER V5.6 HF2 软件 STARTER V56 STARTERV56HF2-cd-2.zip.003
- 纯java安全线程池工具类
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈