步骤一: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://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
步骤三:
sudo apt update
sudo apt install ros-melodic-desktop-full
步骤四:####################最最最容易出错的地方###################
sudo rosdep init
rosdep update
如果失败:#打开hosts文件
sudo gedit /etc/hosts
#在host文件末尾添加
151.101.84.133 raw.githubusercontent.co
#保存后退出再尝试 (若是已经手动下载sources.list,可以移除后再重新操作步骤四初始化)
移除sources.list命令 sudo rm /etc/ros/rosdep/sources.list.d/20-default.list(rm 后是自己的sources.list的文件路径)
来自:https://blog.csdn.net/u013468614/article/details/102917569
sudo rosdep init
rosdep update
若执行上述命令后出现下面状况,可以尝试用电脑连接手机热点进行操作
#rosdep update
##reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: error loading sources list:
('The read operation timed out',)
步骤五:
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
步骤六:
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential