TurtleBot3 是一个小型,低成本,完全可编程,基于 ROS 的移动机器人。它旨在用于教育,研究,产品原型和爱好应用的目的。TurtleBot3 的目标是大幅降低平台的尺寸和价格,而不会牺牲性能,功能和质量。由于提供了其他选项,如底盘,计算机和传感器,TurtleBot3 可以通过各种方式进行定制。TurtleBot3 应用 了SBC(单板计算机),深度传感器和 3D 打印的最新技术进步等技术。
1.安装依赖
sudo apt-get install ros-melodic-joy ros-melodic-teleop-twist-joy ros-melodic-teleop-twist-keyboard ros-melodic-laser-proc ros-melodic-rgbd-launch ros-melodic-depthimage-to-laserscan ros-melodic-rosserial-arduino ros-melodic-rosserial-python ros-melodic-rosserial-server ros-melodic-rosserial-client ros-melodic-rosserial-msgs ros-melodic-amcl ros-melodic-map-server ros-melodic-move-base ros-melodic-urdf ros-melodic-xacro ros-melodic-compressed-image-transport ros-melodic-rqt-image-view ros-melodic-gmapping ros-melodic-navigation ros-melodic-interactive-markers rviz
2.下载资源包
mkdir -p ~/turtlebot3_ws/src/
cd ~/turtlebot3_ws/src/
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
turtlebot3.ziphttps://download.csdn.net/download/m0_56451176/86400766
turtlebot3_simulations.ziphttps://download.csdn.net/download/m0_56451176/86400770turtlebot3_msgs.ziphttps://download.csdn.net/download/m0_56451176/86400768
注: 此次可能会出现:
fatal: unable to access 'https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git/': Could not resolve host: github.com
这是网络问题,可以切换成手机热点试试,可以多切换几次,多试试。
3.编译
cd ~/turtlebot3_ws
catkin_make
1.先将 TurtleBot3 导入,再启动仿真环境(rviz)
export TURTLEBOT3_MODEL=burger
source turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_fake turtlebot3_fake.launch
2.控制TurtleBot3移动
TurtleBot3 仿真节点不依赖实体机器人,也可以在 rviz 里通过 teleop 节点进行控制。
export TURTLEBOT3_MODEL=burger
source turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
3.加载模型(gazebo )
第一次使用 gazebo 需要比较长的时间加载模型,也可以手动加载模型,第一次使用 Turtlebot3 的 gazebo 仿真,需要把 Turtlebot3 的模型文件,复制到 gazebo 的模型目录里。
mkdir -p ~/.gazebo/models/
cp -r ~/turtlebot3_simulations路径/turtlebot3_simulations/turtlebot3_gazebo/worlds ~/.gazebo/models/
例如我的
mkdir -p ~/.gazebo/models/
cp -r ~/turtlebot3_ws/scr/turtlebot3_simulations/turtlebot3_gazebo/worlds ~/.gazebo/models/
4.设置模型参数
设置模型参数,指定使用那种机器人型号: burger 或者 waffle
export TURTLEBOT3_MODEL=burger
5.启动世界地图
启动世界地图,默认的空白地图环境中加载 Turtlebot3 机器人
source turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch
注:如果是虚拟机装的ubuntu,可能会报错:VMware: vmw_ioctl_command error 无效的参数
解决方法:关闭虚拟机的加速3D
注:该方法虽然解决了gazebo启动闪退问题,但是如果我们在虚拟机中需要使用GPU图形加速功能,别忘了重新打开该处设置。
1. (1)启动更复杂些的地图
source turtlebot3_ws/devel/setup.bash
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_world.launch
1.(2)或者房间地图
export TURTLEBOT3_MODEL=burger
source turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_gazebo turtlebot3_house.launch
2.用键盘控制 turtlebot3
export TURTLEBOT3_MODEL=burger
source turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
3. 启动仿真
export TURTLEBOT3_MODEL=burger
source turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_gazebo turtlebot3_simulation.launch
4. 启动 RVIZ 可视化
export TURTLEBOT3_MODEL=burger
source turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_gazebo turtlebot3_gazebo_rviz.launch
1. 安装 turtlebot3 相关的 ROS 包
sudo apt-get install ros-melodic-turtlebot*
或者:
sudo apt-get install ros-melodic-turtlebot3 ros-melodic-turtlebot3-description
ros-melodic-turtlebot3-gazebo ros-melodic-turtlebot3-msgs
ros-melodic-turtlebot3-slam ros-melodic-turtlebot3-teleop
2. 目前激光 SLAM 的建图方法有很多中,turtlebot3 支持 gmapping、cartographer、hector、 karto、frontier_exploration,ROS Melodic 版本官方的软件源里只有 karto。用户可以根据 需要安装。
sudo apt-get install ros-melodic-slam-karto
3. 建图
(1)每个新终端都要设置环境变量,也可以是burger,waffle,waffle_pi
export TURTLEBOT3_MODEL=burger
(2)加载环境
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_world.launch
也可选择其他环境,或自己搭环境
(3) 建图时要切换到这个终端,用键盘控制turtlebot运动
source turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
(4)创建栅格地图
source turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=karto
4. 保存地图:地图建完以后将地图保存下来:
mkdir -p ~/housemap
rosrun map_server map_saver -f ~/housemap/housemap
5. 导航。利用刚才构建的地图进行 turtlebot 的自主导航仿真实验:
source turtlebot3_ws/devel/setup.bash
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_house.launch
source turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_navigation turtlebot3_navigation.launch
map_file:=/home/zhang/housemap/housemap.yaml
鼠标选择工具栏中的“2D Nav Goal”,在地图上任意设置一个目标,turtlebot3会自动规划路径移动到目标位置