ROS学习笔记1:ROS的安装

0 更换源(可选)

修改阿里源为Ubuntu 18.04默认的源

备份/etc/apt/sources.list

#备份
cp /etc/apt/sources.list /etc/apt/sources.list.bak

在/etc/apt/sources.list文件前面添加如下条目

#添加阿里源
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

最后执行如下命令更新源

#更新
sudo apt-get update
sudo apt-get upgrade

1 添加ROS软件源

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.tuna.tsinghua.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME 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 安装ROS

sudo apt-get update

sudo apt-get install ros-kinetic-desktop-full

4 初始化

sudo rosdep init

rosdep update

5 设置环境变量

echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

6 安装一些必备的工具包

sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential

7 安装完成:测试

roscore

结果如下图所示:

ROS学习笔记1:ROS的安装_第1张图片

你可能感兴趣的:(ROS)