Ubuntu18.04安装ROS Melodic
没错,被折磨疯了的我选择换了系统,所以换了ros版本melodic
1.设置sources.list
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) 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.安装
还是建议安装完整版,其他的直接看官网教程
sudo apt install ros-melodic-desktop-full
寻找可用包
apt search ros-melodic
5.初始化rosdep
sudo rosdep init
rosdep update
6.环境设置
为了不每次打开终端都要source一次,我们将其加到bash中
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
7.安装依赖
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
接下来是
sudo rosdep init
总是出错的地方
正确的rosdep update
输出
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Add distro "groovy"
Add distro "hydro"
Add distro "indigo"
Add distro "jade"
Add distro "kinetic"
Add distro "lunar"
Add distro "melodic"
updated cache in /home/tjx/.ros/rosdep/sources.cache
错误1:
ERROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize
解决方法:
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
sudo apt-get update
sudo rosdep init
rosdep update
错误2:
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml]:
<urlopen error [Errno 104] Connection reset by peer> (https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml)
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
解决方法:
sudo apt-get update && sudo apt-get install python-rosdep
sudo rosdep init
rosdep update
错误3:
Traceback (most recent call last):
File "/usr/bin/rosdep", line 3, in <module>
from rosdep2.main import rosdep_main
ModuleNotFoundError: No module named 'rosdep2'
解决方法:
切换自己的python为python2
我自己尝试了很多次,最好还是使用切换python2的方法,因为如果你用的是python3,后面会提示你缺少很多东西,然后在补充安装的时候会自动卸载ros包里的东西。进入一个死循环
或者
sudo apt-get install python3-rosdep