全文的环境为: Ubuntu 16.04 + ROS kinetic + Gazebo7
安装过程中遇到问题,请先跳到本文最后一节查看
一、安装 Ubuntu
1. 切换系统的源为国内的源,北京高校建议选择清华的源,如下图所示。
首先进入 Settings -> Software & Updates -> Ubuntu Software, Download from 处选择对应的源即可。
二、安装 ROS kinetic
1. 加入ROS的源
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
2. 添加秘钥
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
3. 更新索引
sudo apt update
4. 安装ROS
sudo apt install ros-kinetic-desktop-full
sudo rosdep init
rosdep update
5. 添加环境变量到系统中
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
- 如果使用的是zsh (比如很多人使用的ohmyzsh)
echo "source /opt/ros/kinetic/setup.zsh" >> ~/.zshrc
source ~/.zshrc
6. 安装其他的工具链
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
三、安装Gazebo
gazebo7在安装ROS的时候就已经安装了,使用以下命令可检查是否安装成功 roslaunch gazebo_ros empty_world.launch
四、安装 hector_quadrotor 包
1. 安装相关的依赖:
sudo apt install -y ros-kinetic-gazebo-ros-control ros-kinetic-controller-interface ros-kinetic-hardware-interface ros-kinetic-hector-gazebo-plugins ros-kinetic-hector-pose-estimation ros-kinetic-hector-sensors-description ros-kinetic-message-to-tf
2. 建立工作空间:
cd ~
mkdir -p catkin_ws/src
3. 将hector_quadrotor
程序包拷贝到~/catkin_ws/src
4. 进入到~/catkin_ws
目录下,然后编译
cd ~/catkin_ws/
catkin_make
source devel/setup.bash
5. 运行命令roslaunch hector_quadrotor_gazebo quadrotor_empty_world.launch
即可测试编译及安装是否成功。
五、可能遇到的问题
1. 安装ROS的时候遇到关于...simulator broken packages ros...
的错误
解决办法:运行以下命令,清除损坏的依赖包,重新安装ROS
sudo apt remove '.*gazebo.*' '.*sdformat.*' '.*ignition-math.*' '.*ignition-msgs.*' '.*ignition-transport.*'
2. 执行Gazebo相关程序时遇到的以下这种错误
Warning [ModelDatabase.cc:334] Getting models from[http://gazebosim.org/models/]. This may take a few seconds.
Warning [gazebo.cc:215] Waited 1seconds for namespaces.
解决办法:
- 进入
https://bitbucket.org/osrf/gazebo_models/downloads
用运营商网络(手机开热点)下载更快 - 解压文件到
~/.gazebo/models/
目录下,如果没有这个目录,使用命令mkdir -p ~/.gazebo/models
先创建这个目录。
3. 遇到类似以下这种的错误
X Error of failed request: BadValue (integer parameter out of range for operation)
Major optcode of failed request: 154 (GLX)
Minor optcode of failed request: 3 (X_GLXCreateContext)
Value in failed request: 0x0
Serial number of failed request: 26
Current serial number in output stream: 27
可能的解决办法:
首先这是显卡驱动的锅,如果对显卡没有很强烈的要求,使用集成显卡就可以了。如果需要NVIDIA的显卡,建议先检查显卡驱动。如果依然遇到这个问题,可尝试开启两个终端,第一个终端运行roscore
,第二个终端再执行相关的gazebo程序。
4. 使用gazebo结束的时候注意先关闭图形界面,再关掉终端里的进程,否则会有gzserver
残留进程,导致不能再次正确打开程序。如果遇到这种情况建议重启系统。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)