Ubuntu18.04安装ROS Melodic
Posted BkbK-
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu18.04安装ROS Melodic相关的知识,希望对你有一定的参考价值。
Ubuntu18.04安装ROS Melodic
文章目录
1.设置软件源
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
2.设置最新的密钥
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F42ED6FBAB17C654
3.更新源
sudo apt-get update
4.安装ros
sudo apt-get install ros-melodic-desktop-full
5.初始化rosdep
sudo rosdep init
出现 sudo: rosdep:找不到命令
解决办法:安装python-rosdep
sudo apt-get install python-rosdep
再次执行初始化:
出现如下错误:
$ sudo 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.
-
解决办法0:
使用手机热点。
-
解决办法1:
打开文件/etc/hosts:
sudo gedit /etc/hosts
在文件末尾添加如下内容:
199.232.28.133 raw.githubusercontent.com
151.101.228.133 raw.github.com保存退出。
成功执行如下:
-
解决办法2:
切换root用户
sudo passwd //接着提示输密码,输入你的用户密码即可
sudo su //或者su root 然后输入密码切换至root用户
创建文件夹
sudo mkdir -p /etc/ros/rosdep/sources.list.d
进入文件夹
cd /etc/ros/rosdep/sources.list.d
编辑文件
sudo gedit 20-default.list
添加如下内容
# os-specific listings first yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx # generic yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml gbpdistro https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml fuerte # newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
退出root用户
exit
上述命令完成后可以进行第六步:更新rosdep
6.更新rosdep
rosdep update
7.添加ROS环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
8.使环境变量生效
source ~/.bashrc
9.安装命令行工具rosinstall
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
10.测试
roscore
ROS安装成功!
以上是关于Ubuntu18.04安装ROS Melodic的主要内容,如果未能解决你的问题,请参考以下文章
树莓派 4B安装ubuntu18.04与melodic版ROS
解决Ubuntu18.04安装ros报错E: Unable to locate package ros-melodic-desktop-full