ubuntu20.04安装ROS极简教程 (noetic)

1.基础安装步骤

# 1.添加 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'
# 2.添加 keys
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
# 3.更新安装源
sudo apt update
# 4.安装桌面完整版
sudo apt install ros-noetic-desktop-full
# 5.安装依赖
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
# 6.设置环境变量
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc

至此,ROS的Noetic版本已经能够使用了,终端运行roscore试一试效果。
但是,为了后续开发,还需要更新ROS库。接下来的操作就有点意思了~~~

2. sudo rosdep init

# 7.修改hosts文件
sudo gedit /etc/hosts
# 8.初始化(多试几次,一次未必能成功)
sudo rosdep init

/etc/hosts里面加入一堆乱七八糟的东西:

192.30.253.118 gist.github.com
185.199.110.153 github.io

151.101.113.194 github.global.ssl.fastly.net
52.216.227.168 github-cloud.s3.amazonaws.com
52.74.223.119 github.com

199.232.28.133 avatars1.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
199.232.28.133 avatars0.githubusercontent.com
199.232.28.133 avatars3.githubusercontent.com
199.232.28.133 raw.githubusercontent.com
199.232.28.133 user-images.githubusercontent.com
199.232.28.133 avatars.githubusercontent.com
199.232.28.133 github.map.fastly.net
199.232.28.133 avatars7.githubusercontent.com
#Amazon AWS Start
54.239.31.69 aws.amazon.com
54.239.30.25 console.aws.amazon.com
54.239.96.90 ap-northeast-1.console.aws.amazon.com
54.240.226.81 ap-southeast-1.console.aws.amazon.com
54.240.193.125 ap-southeast-2.console.aws.amazon.com
54.239.54.102 eu-central-1.console.aws.amazon.com
177.72.244.194 sa-east-1.console.aws.amazon.com
176.32.114.59 eu-west-1.console.aws.amazon.com
54.239.31.128 us-west-1.console.aws.amazon.com
54.240.254.230 us-west-2.console.aws.amazon.com
54.239.38.102 s3-console-us-standard.console.aws.amazon.com
54.231.49.3 s3.amazonaws.com
52.219.0.4 s3-ap-northeast-1.amazonaws.com
54.231.242.170 s3-ap-southeast-1.amazonaws.com
54.231.251.21 s3-ap-southeast-2.amazonaws.com
54.231.193.37 s3-eu-central-1.amazonaws.com
52.218.16.140 s3-eu-west-1.amazonaws.com
52.92.72.2 s3-sa-east-1.amazonaws.com
54.231.236.6 s3-us-west-1.amazonaws.com
54.231.168.160 s3-us-west-2.amazonaws.com
52.216.80.48 github-cloud.s3.amazonaws.com
54.231.40.3 github-com.s3.amazonaws.com
52.216.20.171 github-production-release-asset-2e65be.s3.amazonaws.com
52.216.228.168 github-production-user-asset-6210df.s3.amazonaws.com

如果出现报错:

ERROR: default sources list file already exists:
	/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize

需要删除/etc/ros/rosdep/sources.list.d/20-default.list,重新sudo rosdep init

sudo rm /etc/ros/rosdep/sources.list.d/20-default.list

如果出现下图,证明成功:
ubuntu20.04安装ROS极简教程 (noetic)_第1张图片

3. rosdep update

# 8. 修改文件
sudo gedit /etc/ros/rosdep/sources.list.d/20-default.list
sudo gedit /usr/lib/python3/dist-packages/rosdistro/__init__.py
# 9.更新
rosdep update

(1)在所有https://raw.githubusercontent.com前加上https://ghproxy.com/
修改后的/etc/ros/rosdep/sources.list.d/20-default.list文件:

# os-specific listings first
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx

# generic
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro https://ghproxy.com/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

(2)然后修改/usr/lib/python3/dist-packages/rosdistro/__init__.py文件:
DEFAULT_INDEX_URL前面加上https://ghproxy.com/,修改完成如下所示:

DEFAULT_INDEX_URL = 'https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'

ubuntu20.04安装ROS极简教程 (noetic)_第2张图片

(3)更新成功的截图:
ubuntu20.04安装ROS极简教程 (noetic)_第3张图片
参考链接:
[1] https://blog.csdn.net/zhangsxa/article/details/114167061
[2] https://blog.csdn.net/weixin_51408986/article/details/119754067

你可能感兴趣的:(室内机器人专栏,slam)