问题描述
参考文章:https://blog.csdn.net/CH_monsy/article/details/107346203
在执行sudo rosdep init时一直连接不上国外的网站
现将完整安装步骤记录如下:
在安装之前先设置一下ubuntu的软件库
运行这个东西
把配置改成这个样子之后就可以开始ros的安装了
一、更改Ubuntu软件源
更改之后可提升ros相关软件包安装速度
输入命令:
sudo gedit /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
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
二、开始Ros安装
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.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
2、添加密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
3、安装Ros软件包
更新系统软件:
sudo apt update
下载完整版Ros-Melodic
sudo apt install ros-melodic-desktop-full
这里至关重要,有可能因为一些网络问题导致软件包下载失败,就一直运行上面的命令,直到全部安装成功为止
4、初始化rosdep
运行命令
sudo apt-get install python-rosdep
sudo rosdep init
rosdep init执行时大概率会报错 这时候采用以下方式解决(没报错的话就不用管)
(1)sudo rosdepc init提示找不到命令
sudo pip install rosdepc
(2)如果显示没有pip就试试pip3
sudo pip3 install rosdepc
(3)如果pip3还没有的话
sudo apt-get install python3-pip
sudo pip3 install rosdepc
接下来就可以用前面的命令来初始化rosdepc了
sudo rosdepc init
rosdepc update
5、设置环境变量:
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
6、安装ros-install
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
到这里就完成了所有ros的安装了
接下来用海龟仿真器测试一下ros
roscore &
运行完后按回车 将roscore转到后台运行
接下来启动海龟仿真器
rosrun turtlesim turtlesim_node &
上面命令完成后也是按回车 将海龟仿真器转后台运行
然后启动海龟控制器
rosrun turtlesim turtle_teleop_key
这一步就不要加&了 因为需要实时捕获按键 将鼠标点在终端上
键盘按上下左右就可以控制小海龟啦