一:配置系统软件源,软件源初始化
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
文章来源:https://uudwc.com/A/AZGGq
六:运行ROS,运行小乌龟
1:运行ROS,启动小乌龟
# 启动ROS Master
roscore
# 启动小海龟仿真器
rosrun turtlesim turtlesim_node
# 启动小海龟控制节点
rosrun turtlesim turtle_teleop_key
文章来源地址https://uudwc.com/A/AZGGq