Turtlebot3的gazebo仿真

创建和编译工作空间

$ mkdir -p ~/catkin_ws/src
$ cd catkin_ws/src
$ catkin_init_workspace
$ cd ..
$ catkin_make

下载Turtlebot3相关工具包

$ cd ~/catkin_ws/src
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3.git
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git
$ git clone https://github.com/ROBOTIS-GIT/turtlebot3_simulations.git
$ git clone https://github.com/ros-teleop/teleop_twist_keyboard.git

安装相关的依赖项及编译

$ cd ..
$ rosdep install --from-paths src --ignore-src --rosdistro=kinetic -y  
$ catkin_make

启动机器人模型

Turtlebot3有三种型号的机器人,Burger、Waffle和Waffle Pi,在每次启动launch文件的时候都需要通过export命令来导入选择的机器人模型,当然也可以通过修改~/.bashrc文件而不必每次都要输入带来的麻烦。

以waffle为例

Gazebo是一款3D仿真器,由于使用了物理引擎和图形效果,因此会占据大量的CPU、GPU和RAM的资源,第一次加载模型时可能会比较慢,耐心等等。

$ roscore
$ source ~/catkin_ws/devel/setup.bash
$ export TURTLEBOT3_MODEL=waffle
$ roslaunch turtlebot3_gazebo turtlebot3_world.launch

可以在Gazebo环境中用键盘控制虚拟TurtleBot3

$ roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

gazebo导航

先运行gazebo环境

$ export TURTLEBOT3_MODEL=waffle
$ roslaunch turtlebot3_gazebo turtlebot3_world.launch

启动导航文件

$ export TURTLEBOT3_MODEL=waffle
$ roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=$HOME/map.yaml

运行RViz

$ export TURTLEBOT3_MODEL=waffle
$ rosrun rviz rviz -d `rospack find turtlebot3_navigation`/rviz/turtlebot3_nav.rviz

开始时rviz显示激光雷达扫出的平面并没有与地图的重合,点击rviz上方的2D Pose Estimate按钮设置机器人的初始位置,就可以实现边界的重合了。

点击rviz上方的2D New Goal按钮设置机器人的目标位置,设定完后机器人就能自主导航到目标位置。

猜你喜欢

转载自blog.csdn.net/Travis_X/article/details/82973644