大半年没写博客了。最近有幸参与机器人导航研究,在学习ROS相关知识。在安装ROS时使用国外的官方源安装非常慢。这里把使用国内镜像的安装方式做一个记录。
笔者用的是Kinetic版本,操作系统是Ubuntu 16.04 LTS。
第一步要做的就是替换系统默认的源为aliyun镜像源:
编辑/etc/apt/sources.list文件,将里面的内容替换为(替换之前建议先备份原始文件):
# deb cdrom:[Ubuntu 16.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
第二步设置ROS的sources.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'
上面是USTC的镜像,也可以设置为Tsinghua University镜像:
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'
到此国内镜像设置完毕,接着按照官方步骤安装ROS就可以了。
添加 keys
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
更新软件包索引
sudo apt-get update
安装桌面完整版ROS
sudo apt-get install ros-kinetic-desktop-full
检测ROS是否安装成功
apt-cache search ros-kinetic
初始化rosdep
sudo rosdep init
rosdep update
配置环境变量
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
安装其他依赖工具包
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
接来下来就可以愉快的进行ROS编程了。编写node,对topic进行publisher、subscribe。
本文只是在官方教程上略作丰富及记录实际操作中的问题解决方法。如需要看官方原始教程请点这里。