进官网,选版本,操作系统
开始安装:
noetic/Installation/Ubuntu - ROS Wiki
Configure your Ubuntu repositories to allow "restricted," "universe," and "multiverse." You can follow the Ubuntu guide for instructions on doing this.
Setup your computer to accept software from packages.ros.org.
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
Source Debs are also available |
选择清华的镜像
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
报错了:
~$ sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.tuna.tsinghua.edu.cn/ros/ubuntu/ `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
[sudo] password for wangzhao:
xxx@RedmiBook-14:~$ curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -Command 'curl' not found, but can be installed with:
sudo snap install curl # version 7.76.1, or
sudo apt install curl # version 7.68.0-1ubuntu2.5See 'snap info curl' for additional versions.
gpg: no valid OpenPGP data found.
按照提示安装curl,再来一遍
所有国内的都试遍了,都不行。。。。
最后是日本的可以:
- sudo sh -c 'echo "deb http://packages.ros.org.jsk.imi.i.u-tokyo.ac.jp/ros/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros-latest.list'
- wget http://ros.jsk.imi.i.u-tokyo.ac.jp/jsk.key -O - | sudo apt-key add -
~$ wget http://ros.jsk.imi.i.u-tokyo.ac.jp/jsk.key -O - | sudo apt-key add -
--2021-06-28 22:17:21-- http://ros.jsk.imi.i.u-tokyo.ac.jp/jsk.key
Resolving ros.jsk.imi.i.u-tokyo.ac.jp (ros.jsk.imi.i.u-tokyo.ac.jp)... 133.11.216.230
Connecting to ros.jsk.imi.i.u-tokyo.ac.jp (ros.jsk.imi.i.u-tokyo.ac.jp)|133.11.216.230|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://packages.ros.org.jsk.imi.i.u-tokyo.ac.jp/jsk.key [following]
--2021-06-28 22:17:23-- http://packages.ros.org.jsk.imi.i.u-tokyo.ac.jp/jsk.key
Resolving packages.ros.org.jsk.imi.i.u-tokyo.ac.jp (packages.ros.org.jsk.imi.i.u-tokyo.ac.jp)... 133.11.216.230
Reusing existing connection to ros.jsk.imi.i.u-tokyo.ac.jp:80.
HTTP request sent, awaiting response... 200 OK
Length: 2448 (2.4K)
Saving to: ‘STDOUT’- 100%[===================>] 2.39K --.-KB/s in 0s
2021-06-28 22:17:26 (66.0 MB/s) - written to stdout [2448/2448]
OK
那继续吧。
这步也可以直接用
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt update
sudo apt install ros-noetic-desktop-full
漫长的安装过程,可以干点别的。
装完以后,设置环境
You must source this script in every bash terminal you use ROS in.
source /opt/ros/noetic/setup.bash
安装依赖库
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
Initialize rosdep
rosdep enables you to easily install system dependencies for source you want to compile and is required to run some core components in ROS. If you have not yet installed rosdep, do so as follows.
sudo apt install python3-rosdep
sudo rosdep init
~$ 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.
- raw.githubusercontent.com其实可以ping通,不过没什么用。
- 这个问题很大,网上的方法很多。简单点的:
sudo nano /etc/hosts
- 在文件末尾添加
-
- 199.232.68.133 raw.githubusercontent.com
-
- (也有人在 /etc/hosts文件的末尾添加
- 199.232.68.133 raw.githubusercontent.com)
- 保存退出。我的ubuntu20,这样设置就解决了。
$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please runrosdep update
但是rosdep update,还是没有过:
~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: unable to process source [https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]:
(https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml)
最后一个办法,自己下载rosdistro
,本地init。
首先去github.com/ros/rosdistro把包下载下来。
修改这个包中rosdep/source.list.d/下的文件20-default.list
,将这个文件中指向raw.githubusercontent.com
的url地址全部修改为指向本地文件的地址:
- # os-specific listings first
- yaml file:///home/username/rosdistro-master/rosdep/osx-homebrew.yaml osx
-
- # generic
- yaml file:///home/username/rosdistro-master/rosdep/base.yaml
- yaml file:///home/username/rosdistro-master/rosdep/python.yaml
- yaml file:///home/username/rosdistro-master/rosdep/ruby.yaml
- gbpdistro file:///home/username/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
记得替换/etc/ros/rosdep/sources.list.d下的20-default.list文件,如果没有
/etc/ros/rosdep/sources.list.d就新建路径。
修改python
中的默认的url的地址,
/usr/lib/python3/dist-packages/rosdep2/main.py
- def command_init(options):
- try:
- data = download_default_sources_list()
- except URLError as e:
- print('ERROR: cannot download default sources list from:\n%s\nWebsite may be down.' % (DEFAULT_SOURCES_LIST_URL))
- return 4
- except DownloadFailure as e:
- print('ERROR: cannot download default sources list from:\n%s\nWebsite may be down.' % (DEFAULT_SOURCES_LIST_URL))
download_default_sources_list函数在/usr/lib/python3/dist-packages/rosdep2 文件夹下面的sources_list.py
文件里
DEFAULT_SOURCES_LIST_URL = 'file:///home/xxx/rosdistro/rosdep/sources.list.d/20-default.list'
修改以下两个文件里面的代码:
/usr/lib/python3/dist-packages/rosdep2/rep3.py
/usr/lib/python3/dist-packages/rosdistro/__init__.py
/usr/lib/python3/dist-packages/rosdep2/rep3.py
# location of targets file for processing gbpdistro files
REP3_TARGETS_URL = 'file:///home/xxx/rosdistro/releases/targets.yaml'# seconds to wait before aborting download of gbpdistro data
/usr/lib/python3/dist-packages/rosdistro/__init__.py
# index information
DEFAULT_INDEX_URL = 'file:///home/xxx/rosdistro/index-v4.yaml'
def get_index_url():
然后:
~$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please runrosdep update
rosdep update
~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit file:///home/xxx/rosdistro-master/rosdep/osx-homebrew.yaml
Hit file:///home/xxx/rosdistro-master/rosdep/base.yaml
Hit file:///home/xxx/rosdistro-master/rosdep/python.yaml
Hit file:///home/xxx/rosdistro-master/rosdep/ruby.yaml
Hit file:///home/xxx/rosdistro-master/releases/fuerte.yaml
Query rosdistro index file:///home/xxx/rosdistro-master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Skip end-of-life distro "dashing"
Skip end-of-life distro "eloquent"
Add distro "foxy"
Add distro "galactic"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Skip end-of-life distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/xxx/.ros/rosdep/sources.cache