编程知识 cdmana.com

Ubuntu18.04使用turblebot3

一、安装和测试

1、下载资源包

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

如果超时,可以在window下面用ssh连接虚拟机进行下载

2、编译

cd ~/turtlebot3_ws
catkin_make

3、启动仿真环境,并打开RVIZ

export TURTLEBOT3_MODEL=burger
source ~/turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_fake turtlebot3_fake.launch

4、新建Terminal(Ctrl+Shft+T),打开键盘控制

export TURTLEBOT3_MODEL=burger
source ~/turtlebot3_ws/devel/setup.bash
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

 可以通过键盘控制小车运动了

 5、打开Gazebo

先把模型移动到一个文件夹

mkdir -p ~/.gazebo/models/
cp -r ~/turtlebot3_ws/scr/turtlebot3_simulations/turtlebot3_gazebo/worlds ~/.gazebo/models/

然后打开模型

export TURTLEBOT3_MODEL=burger
source ~/turtlebot3_ws/devel/setup.bash 
roslaunch turtlebot3_gazebo turtlebot3_empty_world.launch

 如果打开自动关闭,那么关机,然后修改虚拟机设置。

处理器多加几个核,显示器那个√去掉

二、建图

1、启动地图,选择自己想测试的地图即可

source ~/turtlebot3_ws/devel/setup.bash 
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_world.launch
export TURTLEBOT3_MODEL=burger
source turtlebot3_ws/devel/setup.bash 
roslaunch turtlebot3_gazebo turtlebot3_house.launch

2、打开键盘控制

source ~/turtlebot3_ws/devel/setup.bash 
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_teleop turtlebot3_teleop_key.launch

3、创建栅格地图 

source ~/turtlebot3_ws/devel/setup.bash 
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_slam turtlebot3_slam.launch

此时就可以通过控制键盘移动来完成建图了

4、保存地图

source /opt/ros/melodic/setup.bash
mkdir -p ~/worldmap
rosrun map_server map_saver -f ~/worldmap/worldmap

如果没安装则需要安装

sudo apt-get update
sudo rosdep init
rosdep update
sudo apt-get install ros-melodic-map-server

5、导航

加载地图

source /opt/ros/melodic/setup.bash
rosrun map_server map_server worldmap/worldmap.yaml

 打开rviz

rviz

 添加map

 启动Gazebo

source ~/turtlebot3_ws/devel/setup.bash 
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_gazebo turtlebot3_world.launch

打开导航文件

source ~/turtlebot3_ws/devel/setup.bash 
export TURTLEBOT3_MODEL=burger
roslaunch turtlebot3_navigation turtlebot3_navigation.launch map_file:=/home/worldmap/worldmap.yaml

使用2D Pose Estimate设定好小车起始地点,再使用2D Nav Goal设定小车目标地点,小车会规划好路径,自动运行到目标位置,实现自主导航功能

版权声明
本文为[南叔先生]所创,转载请带上原文链接,感谢
https://blog.csdn.net/seek97/article/details/127867789

Scroll to Top