ROS环境安装步骤:(共7步)
在命令行依次执行以下指令进行安装:
-
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
-
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net --recv-key 0xB01FA116
此时可能报错:
解决方案:
依次运行以下命令:
sudo gpg --keyserver keyserver.ubuntu.com --recv F42ED6FBAB17C654
sudo gpg --export --armor F42ED6FBAB17C654 | sudo apt-key add -
再继续运行以下命令:
sudo apt-get install ros-kinetic-ros-base
更多安装包可通过sudo apt-get install ros-kinecit-PACKAGE进行安装,其中“PACKAGE”为指定包名。安装完成后,继续执行:
-
sudo rosdep init
-
rosdep update
这一步必然出错,解决方案见下文:
错误原因:
默认GitHub网址已更新,此时需要更换默认配置文件(即20-default.list)
解决方案:
此时需要编辑list文件里的内容修改信息,本人习惯用vim,用以下命令安装:
sudo apt-get install vim
输入y按enter,安装完成如下图:
将此文件下载到本地,然后复制到本地的共享文件夹内,并解压,将解压后的文件夹名修改为rosdistro,
github链接:rosdistro-master
在Ubuntu终端下将共享文件夹内的此文件夹复制到etc/ros下,
进入Ubuntu的共享文件夹内,即 cd /mnt/hgfs/<你的共享文件夹的名字>
运行以下命令:sudo cp -r rosdistro /etc/ros/rosdistro
进入目标文件夹,命令行输入:cd /etc/ros/rosdep/sources.list.d
编辑list文本里面的内容,运行命令:
sudo vim 20-default.list
将以下内容替换原本内容并保存退出:
yaml file:///etc/ros/rosdistro/rosdep/osx-homebrew.yaml osx
\# generic
\# yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
\# yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
\# yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
\# gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte
yaml file:///etc/ros/rosdistro/rosdep/base.yaml
yaml file:///etc/ros/rosdistro/rosdep/python.yaml
yaml file:///etc/ros/rosdistro/rosdep/ruby.yaml
gbpdistro file:///etc/ros/rosdistro/releases/fuerte.yaml fuerte
\# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
接下来需要修改三个文件:
a. 运行:
sudo vim /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
找到REP3_TARGETS_URL ,
替换为
REP3_TARGETS_URL = 'file:///etc/ros/rosdistro/releases/targets.yaml'
b. 运行:
sudo vim /usr/lib/python2.7/dist-packages/rosdep2/gbpdistro_support.py
找到:FUERTE_GBPDISTRO_URL
替换为
FUERTE_GBPDISTRO_URL = 'file:///ros/rosdistro/' \
'releases/fuerte.yaml'
c. 运行:
sudo vim /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
修改DEFAULT_INDEX_URL内容为:
DEFAULT_INDEX_URL = 'file:///etc/ros/rosdistro/index-v4.yaml'
最后运行:rosdep update,成功
-
至此环境安装完毕。echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc