Ubuntu20.04.4安装ROS Noetic教程

一:配置系统软件源,软件源初始化

1:配置系统软件源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup

2:编辑系统软件源

sudo gedit /etc/apt/sources.list

3:20.04LTS源码镜像复制到sources.list·文件中

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse

# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
# deb-src http://security.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse


deb http://archive.ubuntu.com/ubuntu bionic main restricted universe multiverse
deb http://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse

deb http://archive.ubuntu.com/ubuntu/ trusty main universe restricted multiverse



deb http://security.ubuntu.com/ubuntu xenial-security main

4:更新源

sudo apt update

5:添加ROS源:在终端输入如下指令,设置sources.list。

sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'

6:添加密钥:在终端输入如下指令,添加Ros密钥

sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

7:更新源

sudo apt update

8:安装桌面完整版Ros。使用aptitude进行安装

sudo apt-get install aptitude

二:安装ROS,初始化rosdep,下载rosdistro文件

1:安装ROS

sudo aptitude install ros-noetic-desktop-full

2:设置环境变量:对环境变量进行配置

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

3:初始化rosdep:下载rosdistro文件

cd /opt/ros/noetic/
git clone https://github.com/ros/rosdistro.git

三:修改后面文件:20-default.list,gbpdistro_support.py,rep3.py,init.py

1:修改文件1:20-default.list,将里面的URL改为file路径,需要删除默认URL路径中的/master/

cd /opt/ros/noetic/rosdistro/rosdep/sources.list.d/
sudo gedit 20-default.list

1.1修改为如下内容


# os-specific listings first
yaml file:///opt/ros/noetic/rosdistro/rosdep/osx-homebrew.yaml osx

# generic
yaml file:///opt/ros/noetic/rosdistro/rosdep/base.yaml
yaml file:///opt/ros/noetic/rosdistro/rosdep/python.yaml
yaml file:///opt/ros/noetic/rosdistro/rosdep/ruby.yaml
gbpdistro file:///opt/ros/noetic/rosdistro/releases/fuerte.yaml fuerte

# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

在这里插入图片描述

2:修改文件2:gbpdistro_support.py

cd /usr/lib/python3/dist-packages/rosdep2/
sudo gedit gbpdistro_support.py

2.1:修改为如下内容

FUERTE_GBPDISTRO_URL = 'file:///opt/ros/noetic/rosdistro/' \
    'releases/fuerte.yaml'

在这里插入图片描述

3:修改文件3:rep3.py

cd /usr/lib/python3/dist-packages/rosdep2/
sudo gedit rep3.py


3.1:修改为如下内容

REP3_TARGETS_URL = 'file:///opt/ros/noetic/rosdistro/releases/targets.yaml'

在这里插入图片描述

4:修改文件4:init.py

cd /usr/lib/python3/dist-packages/rosdistro/
sudo gedit __init__.py


4.1:修改为如下内容

DEFAULT_INDEX_URL = 'file:///opt/ros/noetic/rosdistro/index-v4.yaml'

在这里插入图片描述

四:安装python-rosdep,安装rosinstall,初始化rosdep。

1:安装python-rosdep

sudo apt-get install python3-rosdep

2:创建20-default.list文件,安装了python-rosdep后,因为国内网络被屏蔽的原因运行sudo rosdep init还出现无法下载或连接失败的错误。所以用如下命令创建这个文件。

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 file:///opt/ros/noetic/rosdistro/rosdep/osx-homebrew.yaml osx
#generic
yaml file:///opt/ros/noetic/rosdistro/rosdep/base.yaml
yaml file:///opt/ros/noetic/rosdistro/rosdep/python.yaml
yaml file:///opt/ros/noetic/rosdistro/rosdep/ruby.yaml
gbpdistro file:///opt/ros/noetic/rosdistro/releases/fuerte.yaml fuerte
#newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead

在这里插入图片描述

3:初始化rosdep。

rosdep update

4:安装rosinstall

安装rosinstall命令:

sudo apt install python3-rosdep 
sudo apt install python3-rosinstall 
sudo apt install python3-rosinstall-generator 
sudo apt install python3-wstool 
sudo apt install build-essential

五:查看是否安装成功

1:先运行ROS

# 启动ROS Master
roscore

2:进行查看是否成功,是否有报错

roswtf

在这里插入图片描述

六:运行ROS,运行小乌龟

1:运行ROS,启动小乌龟

# 启动ROS Master
roscore

# 启动小海龟仿真器
rosrun turtlesim turtlesim_node

# 启动小海龟控制节点
rosrun turtlesim turtle_teleop_key

在这里插入图片描述文章来源地址https://uudwc.com/A/AZGGq

原文地址:https://blog.csdn.net/qq_46107892/article/details/131474836

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请联系站长进行投诉反馈,一经查实,立即删除!

h
上一篇 2023年07月01日 22:00
下一篇 2023年07月01日 22:01