0.改源
sudo gedit /etc/apt/sources.list
我全删了改成了中科大的,如果用其他的应该也可以。
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
deb-src http://mirrors.ustc.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
保存退出。
1.软件与更新打钩
2.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'
3.设置密钥
sudo -E apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
如果你用的是老密钥421C365BD9FF1F717815A3895523BAEEB01FA116会报错
要删除
sudo apt-key del 421C365BD9FF1F717815A3895523BAEEB01FA116
再重新设置密钥
4.更新
sudo apt-get update
sudo apt-get upgrade
可能由于速度慢报错,多试几次
5.安装
sudo apt-get install ros-kinetic-desktop-full
6.初始化ROS
sudo rosdep init
rosdep update
如果你在执行 rosdep init 过程中出现以下错误
ERROR: cannot download default sources list from:
https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list
Website may be down.
这是由于raw.githubusercontent.com被墙,程序无法下载相应的文件导致的。解决方法就是使得raw.githubusercontent.com能够被正常访问。这个网站被墙的方式是dns污染,所以我们只要能够找到这个网站的正确ip就可以了。
把下面添加到自己电脑的hosts文件里面,文件路径为/etc/hosts就好
199.232.28.133 raw.githubusercontent.com
update同样可能由于速度报错,多试几次
7.添加ROS 环境变量与依赖
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
8.测试
分别三个cmd窗口输入
roscore
rosrun turtlesim turtlesim_node
rosrun turtlesim turtle_teleop_key
再在最后一个cmd窗口敲击上下左右键就可以控制乌龟了
最后推荐一本书https://www.cse.sc.edu/~jokane/agitr/%E6%9C%BA%E5%99%A8%E4%BA%BA%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%EF%BC%88ROS%EF%BC%89%E6%B5%85%E6%9E%90.pdf
不过书有点老,跟着古月居学最好