ubuntu 18.04 安装ROS melodic教程。

1.首先,我这个ubuntu 18.04是刚刚安装好的,所以我们先换源。

sudo nano /etc/apt/sources.list

然后将里面的内容清空,把下面的内容复制进去保存退出。

##中科大源

deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

然后打开一个终端:

sudo apt update
sudo apt upgrade

2.然后开始正式安装这个步骤了,设置软件源:

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 apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

4.更新源地址:

sudo apt-get update

如果在这一步出现如下报错,则看接下来的解决方法(没有报错则直接调至第5步):

解决办法:

将公钥添加至服务器,即终端中输入:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys '公钥编码'

//将上面单引号‘’中的公钥编码替换为你上面报错信息那里的公钥编码,下方为我的示例:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654

5.安装ros melodic完整版:

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

6.安装rqt工具并初始化rosdep:

sudo apt-get install ros-melodic-rqt*
sudo rosdep init

如果提示:sudo: rosdep: command not found,则执行下方命令:

sudo apt-get install python-rosdep

,然后继续,如果提示:ERROR: cannot download default sources list from:这样的错误,如下图:

然后通过以下方式解决:https://blog.csdn.net/qqliuzhitong/article/details/113095518

继续就可以了。

然后执行:

rosdep update

7.环境变量设置:

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

source ~/.bashrc

8.安装编译依赖库:

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

9.运行roscore测试:

roscore

成功:

10.运行自带小乌龟例程:

rosrun turtlesim turtlesim_node

rosrun turtlesim turtle_teleop_key

可以用方向键控制小乌龟前后左右运动:

猜你喜欢

转载自blog.csdn.net/qqliuzhitong/article/details/115329516