gazebo
rviz安装:
sudo apt-get install ros-kinetic-rviz
Gazebo安装:
sudo apt-get install ros-kinetic-gazebo-ros-pkgs ros-kinetic-gazebo-ros-control
安装turtlebot相关包
sudo apt-get install ros-kinetic-turtlebot-*
可能出现的错误:
错误:1 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 linux-headers-generic amd64 4.4.0.169.177
404 Not Found [IP: 121.194.7.5 80]
错误:1 http://mirrors.aliyun.com/ubuntu xenial-security/main amd64 linux-headers-generic amd64 4.4.0.169.177
404 Not Found [IP: 121.194.7.5 80]
E: 下载 http://mirrors.aliyun.com/ubuntu/pool/main/l/linux-meta/linux-headers-generic_4.4.0.169.177_amd64.deb 404 Not Found [IP: 121.194.7.5 80] 失败
E: 有几个软件包无法下载,要不运行 apt-get update 或者加上 --fix-missing 的选项再试试?
这个问题会导致 roslaunch turtlebot_gazebo turtlebot_world.launch时出现错误:
[turtlebot_world.launch] is neither a launch file in package [turtlebot_gazebo] nor is [turtlebot_gazebo] a launch file name
The traceback for the exception was written to the log file
错误解决是尝试sudo apt-get update,注意加sudo,否则会出现一下错误
正在读取软件包列表… 完成
W: chmod 0700 of directory /var/lib/apt/lists/partial failed - SetupAPTPartialDirectory (1: 不允许的操作)
E: 无法打开锁文件 /var/lib/apt/lists/lock - open (13: 权限不够)
E: 无法对目录 /var/lib/apt/lists/ 加锁
W: 用 unlink 删除文件 /var/cache/apt/pkgcache.bin 出错 - RemoveCaches (13: 权限不够)
W: 用 unlink 删除文件 /var/cache/apt/srcpkgcache.bin 出错 - RemoveCaches (13: 权限不够)
问题解决:sudo apt-get update
下载Gazobo的模型包
链接:http://pan.baidu.com/s/1pKaeg0F 密码:cmxc (来自Gazebo问题修复)
将模型文件夹放到~/.gazebo/models用户文件夹下。
此处在home,因为.gazebo文件夹被隐藏了所以找不到,Ctrl+可以显示出来,解压后如下:
export TURTLEBOT_GAZEBO_WORLD_FILE="/opt/ros/kinetic/share/turtlebot_gazebo/world/playground.world"
这里需要使用环境变量TURTLEBOT_GAZEBO_WORLD_FILE为仿真环境指定地图,否则会显示找不到地图的错误信息
roslaunch turtlebot_gazebo turtlebot_world.launch
安装好模型之后一般再一次打来Gazebo就会显示下图:
但是我打开的时候遇到了问题,Gazebo可以打开,并且在insert中也可以找到各种模型,但是不显示上图,出现的错误代码为[gazebo-1] process has died with exit code 255
在网上找到的解决办法为:
killall gzserver
启动键盘遥控节点:
roslaunch turtlebot_teleop keyboard_teleop.launch --screen
运行gmapping:
roslaunch turtlebot_gazebo gmapping_demo.launch
打开rviz,可以看到相关摄像头,激光雷达点云等信息:
roslaunch turtlebot_rviz_launchers view_navigation.launch
启动仿真环境和gmapping节点:
export TURTLEBOT_GAZEBO_WORLD_FILE="/opt/ros/kinetic/share/turtlebot_gazebo/worlds/playground.world"
roslaunch turtlebot_gazebo turtlebot_world.launch
roslaunch turtlebot_gazebo gmapping_demo.launch
roslaunch turtlebot_rviz_launchers view_navigation.launch
roslaunch turtlebot_teleop keyboard_teleop.launch
SLAM结束后保存地图,并命名为turtlebot_test_map :
rosrun map_server map_saver -f turtlebot_test_map
接下来在构建完成的地图上实现TurtBot自主导航功能。turtlebot_gazebo功能包中提供列实现导航功能的launch启动文件。
打开gazebo仿真环境
roslaunch turtlebot_gazebo turtlebot_world.launch
导入地图
roslaunch turtlebot_gazebo amcl_demo.launch map_file:=/home/[此处为保存地图的文件夹名]/turtlebot_test_map.yaml
导航
roslaunch turtlebot_rviz_launchers view_navigation.launch
在rviz中选择导航目标后,Gazbo中的turtbot机器人开始向目标移动。
上文采用gmapping进行地图构建, gmapping是一个ros自带的地图构建工具包。slam_gmapping采用激光数据(topic:sensor_msgs/LaserScan)生成二维地图(topic:nav_msgs/OccupancyGrid). 在gmappingtutorial中 ,可以发现, 订阅的主题,发布的主题,以及调用的服务。
可能出现的问题:
Map_server could not open /home/hcx/turtlebot_test_map.yaml.
来源:CSDN
作者:Jinterest
链接:https://blog.csdn.net/qq_37417682/article/details/103647179