TurtleBot3是TurtleBot系列中的第三代产品,它在二代的基础之上做了一些改进,并开发了一些新功能,以补充其前身缺乏的功能和满足用户的需求。TurtleBot3采用机器人智能驱动器Dynamixel驱动,是一款小型的、可编程的、基于ROS的高性价比移动机器人,可用于教育、研究和产品原型制造。
一、Turtlebot3安装
git指令有时候受网络影响提示失败,需要多试几次。
cd ~/catkin_ws/src
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
cd ~/catkin_ws
rosdep install --from-paths src -i -y
catkin_make
执行rosdep intall 时报错:
更换指令:
rosdep install --from-paths src --ignore-src --rosdistro=melodic -y -i -r
安装成功:
source环境变量。
echo "source ~/catkin_ws/devel/setup.bash " >> ~/.bashrc
source ~/.bashrc
根据所选用的TB3机器人是Burger还是Waffle,将其作为环境变量加入~/.bashrc文件,以方便后续使用。否则每次运行程序都需要先输入“export TURTLEBOT3_MODEL=burger”或者“export TURTLEBOT3_MODEL=waffle”。
echo "export TURTLEBOT3_MODEL=burger" >> ~/.bashrc
source ~/.bashrc
检查环境变量设置是否成功:
env | grep TURTLEBOT3
执行结果:
二、运行仿真turtlebot3_fake.launch
roslaunch turtlebot3_fake turtlebot3_fake.launch
报错:
rviz
解决:
#重启终端
catkin_make
roslaunch turtlebot3_fake turtlebot3_fake.launch
节点关系查看:rqt_graph
三、运行仿真 turtlebot3_world.launch
roslaunch turtlebot3_gazebo turtlebot3_world.launch
报错,查信息是虚拟机的原因:
解决:关闭GPU,重启ubuntu:
export SVGA_VGPU10=0
重新运行launch文件:
roslaunch turtlebot3_gazebo turtlebot3_world.launch
gazbo运行成功,但仍然有报错:
解决:将~/.ignition/fuel/config.yaml中的 https://api.ignitionfuel.org 改为 https://api.ignitionrobotics.org即可。
gedit ~/.ignition/fuel/config.yaml
文件内容换成以下:
---
# The list of servers.
servers:
-
name: osrf
url: https://api.ignitionrobotics.org
# -
# name: another_server
# url: https://myserver
# Where are the assets stored in disk.
# cache:
# path: /tmp/ignition/fuel
最终运行结果:
四、turtlebot3在模型中的运动
新终端,启动gazebo节点
roslaunch turtlebot3_gazebo turtlebot3_world.launch
新终端,启动键盘节点
roslaunch turtlebot3_gazebo turtlebot3_house.launch
新终端,启动仿真节点
roslaunch turtlebot3_gazebo turtlebot3_simulation.launch
新终端,启动rviz
roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch
执行后,可以看到在gazebo仿真环境中,仿真小车在环境中走动:
可以在RVIZ看到点云数据和小车的运动:
五、仿真slam建图
步骤一:新终端,打开gazebo仿真
roslaunch turtlebot3_gazebo turtlebot3_world.launch
步骤二:新终端,启动slam程序
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping
第一次有报错,按提示,安装gmapping工具,重新运行roslaunch
sudo apt-get install ros-melodic-gmapping
运行结果可以看到slam扫到的点云数据
步骤三: 新终端,打开键盘控制,使用键盘控制小车运动
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
步骤四:新终端,保存地图
rosrun map_server map_saver -f ~/map