为了加快下载速度建议换成国内的软件源具体操作如下:
sudo gedit /etc/apt/sources.list
然后复制下列的代码替换源文件里面的内容:
# deb cdrom:[Ubuntu 18.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic main universe restricted multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main universe restricted multiverse #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main universe restricted multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main universe restricted multiverse #Added by software-properties
deb http://security.ubuntu.com/ubuntu/ bionic-security main universe restricted multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main universe restricted multiverse #Added by software-properties
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
注意:上述命令如果下载速度过慢,可以使用以下命令重新添加软件源(经测试均可正常安装):
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
如果报错:
安装ROS时遇到E: 文件 list 第 1 行的记录格式有误 /etc/apt/sources.list.d/ros-latest.list (Component)解决办法
此时执行:
sudo rm /etc/apt/sources.list.d/ros-latest.list
sudo apt-get install ros-melodic-desktop-full
安装前需要手动添加清华源,(原来用其他云都可以,最近貌似被和谐了)具体操作如下:
sudo gedit /etc/apt/sources.list
复制下列文件粘贴在打开的文件中。
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
更新一下
sudo apt-get update
然后在安装管理员模式:
sudo apt-get install nautilus-admin
安装失败 apt-get install E: 无法定位软件包问题
##+++++++++++++++++++++++++++++++++++++++++++++++++++++++
重点内容
+++++++++++++++++++++++++++++++++++++++++++++++++++++++##
这里会失败,网上很多教程都无法解决,这里使用本地文件初始化。
蓝奏云:https://wwa.lanzoui.com/idWatqk3a2b(文件下载链接)
下载好了以后将文件解压放置在英文路径下,这里推荐放到home文件夹下。在home文件夹下使用管理员权限打开,然后再复制文件进去。
rosdistro-master->rosdep->source.list.d->20-default.list
以下所改动的路径都来源于上一步改动的20-default.list文件
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/sources_list.py
step1:打开/usr/lib/python2.7/dist-packages/rosdep2下面的sources_list.py要使用管理员权限(右键就有管理员权限运行)
sudo gedit /usr/lib/python2.7/dist-packages/rosdep2/rep3.py
step3:打开/usr/lib/python2.7/dist-packages/rosdep2/rep3.py(以管理员身份)改动文件
sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/__init__.py
step4:打开/usr/lib/python2.7/dist-packages/rosdistro/init.py(以管理员身份)改动文件
报错是因为在系统中也存在了文件包中的20-default.list文件,找到并删除就好了(以管理员身份打开文件夹即可右键删除 )
再试一次sudo rosdep init,就可以成功了。
如果出现rosdep命令不存在,运行:
sudo apt install python-rosdep2 -y
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
ROS安装已经完成了。
step1:打开一个终端(crtl+alt+T)运行:
roscore
step2:再打开一个终端(crtl+alt+T),运行:
rosrun turtlesim turtlesim_node
step3:然后再打开一个终端(crtl+alt+T),运行:
rosrun turtlesim turtle_teleop_key
step4:此时(鼠标定位在Step3生成的窗口)按着键盘方向键就可以控制小海龟移动。