ubuntu安装ROS

进官网,选版本,操作系统

ROS: Home

开始安装:

noetic/Installation/Ubuntu - ROS Wiki

Installation

Configure your Ubuntu repositories

Configure your Ubuntu repositories to allow "restricted," "universe," and "multiverse." You can follow the Ubuntu guide for instructions on doing this.

Setup your sources.list

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'

Mirrors

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'

Set up your keys

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.5

See '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

 安装依赖库

Dependencies for building packages

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 run

    rosdep 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]:
    <urlopen error [Errno 104] Connection reset by peer> (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 run

    rosdep 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值