0


Ubuntu 20.04 安装 ROS

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档

文章目录


一、更换ROS软件源

1、添加ROS安装源

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、更新软件源

sudo apt update

升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 **个软件包未被升级

sudo apt-get upgrade

二、安装ROS

1.安装ROS

Ubuntu 20.04安装Ros Noetic 及 18.04安装ROS Melodic

sudo apt install ros-noetic-desktop-full

2.初始化 rosdep

sudo rosdep init

错误1:找不到命令(rosdep找不到命令)

sudo apt install python3-rosdep2

错误2:

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.

该错误与

rosdep update

相似,处理方式差不多
本人处理方式,参照文献1、文献2、文献3,三种处理方式都是将源文件下载下来,根据自己情况,所放的目录位置不同。
原文件地址:地址1、地址2

下面是本人位置
针对

错误2

,找到

/usr/lib/python2.7/dist-packages/rosdep2/sources_list.py

文件,修改:

#rosdep
DEFAULT_SOURCES_LIST_URL = 'file:///home/xxx/rosdistro/rosdep/sources.list.d/20-default.list'

其中文件

20-default.list

要重新配置

#os-specific listings first

yaml file:///home/***/rosdistro/rosdep/osx-homebrew.yaml osx#generic

yaml file:///home/***/rosdistro/rosdep/base.yaml
yaml file:///home/***/rosdistro/rosdep/python.yaml
yaml file:///home/***/rosdistro/rosdep/ruby.yaml
gbpdistro file:///home/***/rosdistro/releases/fuerte.yaml fuerte#newerdistributions(Groovy, Hydro,...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

再次运行

sudo rosdep init

如果出现下面错误,就删除

20-default.list

文件,是因为该文件是旧文件,无法更新:

ERROR:default sources list file already exists:/etc/ros /rosdep/sources.list.d/20-default.listPlease deleteif you wish to re-initialize
 sudo rm /etc/ros/rosdep/sources.list.d/20-default.list

再次运行

sudo rosdep init

3、更新 rosdep

rosdep update
rosdep

更新超时问题

注意文件路径
文件1:
/usr/lib/python2.7/dist-packages/rosdep2/rep3.py
cd /usr/lib/python2.7/dist-packages/rosdep2 
sudo gedit rep3.py
修改位置
#REP3_TARGETS_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/releases/targets.yaml'
REP3_TARGETS_URL = 'file:///home/***/rosdistro/releases/targets.yaml'
文件2:
/usr/lib/python2.7/dist-packages/rosdistro/__init__.py
cd /usr/lib/python2.7/dist-packages/rosdistro
sudo gedit __init__.py
修改位置
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL = 'file:///home/***/rosdistro/index-v4.yaml'
再次运行
rosdep update

在这里插入图片描述

4、设置环境变量

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

5、安装 rosinstall

sudo apt install python3-rosinstall python3-rosinstall-generator python3-wstool
sudo apt install python3-roslaunch
sudo apt install ros-noetic-desktop-full

三、运行海龟

命令框 1

roscore
命令框 2

rosrun turtlesim turtlesim_node
命令框 3

rosrun turtlesim turtle_teleop_key

修改海龟形状的文件夹在

/opt/ros/humble/share/turtlesim/images

标签: ubuntu linux 运维

本文转载自: https://blog.csdn.net/SEAL0107/article/details/138735830
版权归原作者 SEAL0107 所有, 如有侵权,请联系我们删除。

“Ubuntu 20.04 安装 ROS”的评论:

还没有评论