一、turtlebot3依赖安装
1、安装turtlebot3
sudo apt-get install ros-noetic-turtlebot3-*
//安装gmapping建图算法依赖
apt-get install ros-noetic-gmapping
//安装dwa局部路径规划算法
apt-get install ros-noetic-dwa-local-planner
2、安装键盘依赖
sudo apt-get install ros-noetic-gazebo-ros-pkgs ros-noetic-gazebo-ros-control
turtlebot3键盘控制依赖
建议使用rosrun teleop_twist_keyboard teleop_twist_keyboard.py
更方便
二、slam建图与nav导航
slam建图与保存
1、启动roscore
roscore
2、开启仿真环境
export TURTLEBOT3_MODEL=waffle_pi
roslaunch turtlebot3_gazebo turtlebot3_house.launch
3、开启SLAM功能,建图算法选择gmapping
export TURTLEBOT3_MODEL=waffle_pi
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping
4、启动键盘控制节点,控制小车在环境内转一圈,尽可能扫出完整封闭的地图
export TURTLEBOT3_MODEL=waffle_pi
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
5、使用map_server保存地图:
rosrun map_server map_saver -f /home/$用户名$/$MapName$
地图读取与nav导航
6、加载保存好的地图
rosrun map_server map_server $MapName$.yaml
7、打开gazebo仿真环境
export TURTLEBOT3_MODEL=waffle_pi
roslaunch turtlebot3_gazebo turtlebot3_house.launch
8、打开自主导航功能
export TURTLEBOT3_MODEL=waffle_pi
roslaunch turtlebot3_navigation turtlebot3_navigation.launch
map_file:=/home/$用户名$/$MapName$.yaml
使用2D Nav Goal
设置导航目标点,进行自主导航: