最近需要学习多机器人协同控制的相关知识,在古月居看到博主小黑鸭的文章,和我学习的内容很相似,实验室里用的移动机器人都是ROBOTIS公司的Turtlebot3,就参考博主的文章进行了学习。
参考文章:多机器人协同控制①——仿真平台搭建
我的环境:VMware+Ubuntu16.04 + ROS Kinetic
1、Turtlebot3包安装
sudo apt-get install ros-kinetic-joy ros-kinetic-teleop-twist-joy ros-kinetic-teleop-twist-keyboard ros-kinetic-laser-proc ros-kinetic-rgbd-launch ros-kinetic-depthimage-to-laserscan ros-kinetic-rosserial-arduino ros-kinetic-rosserial-python ros-kinetic-rosserial-server ros-kinetic-rosserial-client ros-kinetic-rosserial-msgs ros-kinetic-amcl ros-kinetic-map-server ros-kinetic-move-base ros-kinetic-urdf ros-kinetic-xacro ros-kinetic-compressed-image-transport ros-kinetic-rqt-image-view ros-kinetic-gmapping ros-kinetic-navigation ros-kinetic-interactive-markers
2、在工作空间中安装Tutlebot3的源码,如果没有工作空间需要新建工作空间
新建工作空间可以参考:ROS学习(2)——创建工作空间和创建功能包
cd ~/catkin_ws/src/
git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
cd .. && catkin_make
3、安装仿真系统依赖包
我的环境是Ubuntu16.04 + ROS Kinetic
sudo apt-get install -y ros-kinetic-navigation ros-kinetic-teb-local-planner* ros-kinetic-ros-control ros-kinetic-ros-controllers ros-kinetic-gazebo-ros-control ros-kinetic-ackermann-msgs ros-kinetic-serial qt4-default ros-kinetic-effort-controllers ros-kinetic-joint-state-controller ros-kinetic-tf2-ros ros-kinetic-tf
4、安装 Turtlebot3_Simulation 包
cd ~/catkin_ws/src/
git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
cd .. && catkin_make
实验室的小车是waffle,所以我TURTLEBOT3_MODEL 的型号设定为waffle。
export TURTLEBOT3_MODEL=waffle
可以添加到环境变量中
echo "export TURTLEBOT3_MODEL=waffle" >> ~/.bashrc
5、启动仿真环境
仿真环境要在工作空间中启动
source devel/setup.bash
roslaunch turtlebot3_gazebo turtlebot3_world.launch
Gazebo成功启动:
6、验证环境&建图
验证turtlebot3的包是否安装完成,在上一个步骤已经启动仿真环境的前提下,启动一个新终端,启动SLAM程序。
roslaunch turtlebot3_slam turtlebot3_slam.launch slam_methods:=gmapping
再打开一个新终端,启动键盘控制程序,根据提示通过按键控制小车行走来建立地图
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch
打开新终端,可以保存地图
rosrun map_server map_saver -f ~/catkin_ws/map