ros系统
查看版本代号
lsb_release -a
lhq@lhqubantu:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal
lhq@lhqubantu:~$
这个是源版本代号 focal要在源地址相对应换
国内有很多Ubuntu的镜像源,包括阿里的、网易的,还有很多教育网的源,比如:清华源、中科大源。
我们这里以清华源为例讲解如何修改Ubuntu 20.04里面默认的源。
编辑/etc/apt/sources.list文件, 在文件最前面添加以下条目(操作前请做好相应备份):
ros 版本与ubantu一样有代号
ROS 版本 首选Ubuntu版本
noetic Ubuntu 20.04
melodic Ubuntu 18.04
Lunar Ubuntu 17.04
Kinetic(建议选用) Ubuntu 16.04
Jade Ubuntu 15.04
Indigo Ubuntu 14.04
1、添加ROS软件源
ctrl+alt+t
sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
或
sudo sh -c '. /etc/lsb-release && echo "deb http://mirrors.ustc.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
2、添加密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654b
或
sudo apt-key adv --keyserver hkp://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
成功后会显示如下界面:
lhq@lhqubantu:~/catkin_ws$ sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
Executing: /tmp/apt-key-gpghome.GnMRWmBsct/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
gpg: 密钥 F42ED6FBAB17C654:“Open Robotics <info@osrfoundation.org>” 未改变
gpg: 处理的总数:1
gpg: 未改变:1
3、更新软件源
sudo apt update
成功后会显示如下界面:
lhq@lhqubantu:~/catkin_ws$ sudo apt update
命中:1 http://mirrors.aliyun.com/ubuntu focal InRelease
命中:2 http://mirrors.aliyun.com/ubuntu focal-security InRelease
命中:3 http://mirrors.aliyun.com/ubuntu focal-updates InRelease
命中:4 http://mirrors.aliyun.com/ubuntu focal-proposed InRelease
命中:5 http://mirrors.aliyun.com/ubuntu focal-backports InRelease
命中:6 http://dl.google.com/linux/chrome/deb stable InRelease
命中:7 http://cz.archive.ubuntu.com/ubuntu xenial InRelease
命中:8 http://cn.archive.ubuntu.com/ubuntu focal InRelease
命中:9 http://packages.ros.org/ros/ubuntu focal InRelease
获取:10 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB]
获取:11 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [24.3 kB]
获取:12 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [56.6 kB]
已下载 188 kB,耗时 5秒 (37.9 kB/s)
Can not add an empty (zero-length) key to the cache
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
有 225 个软件包可以升级。请执行 ‘apt list --upgradable’ 来查看它们。
4、安装ROS
选择安装的版本
ros-noetic-desktop-full #完整版
sudo apt-get install ros-noetic-desktop#桌面版安装(包含ROS、rqt、rviz以及通用机器人函数库)
sudo apt-get install ros-kinetic-ros-base#基础版安装(包含ROS核心软件包、构建工具以及通信相关的程序库,无GUI工具)
单独软件包安装(这种安装方式在运行ROS缺少某些package依赖时会经常用到。你可以安装某个指定的ROS软件包,使用软件包名称替换掉下面的PACKAGE)
sudo apt-get install ros-kinetic-PACKAGE
例如系统提示找不到slam-gmapping,你就可以:
sudo apt-get install ros-kinetic-slam-gmapping
要查找可用的软件包,请运行:
apt-cache search ros-kinetic
软件包的依赖问题还可能出现在重复安装ROS、错误安装软件包的过程中,出现有一些软件包无法安装,例如:
下列软件包有未满足的依赖关系:ros-kinetic-desktop-full :
依赖: ros-kinetic-desktop 但是它将不会被安装;
依赖: ros-kinetic-perception 但是它将不会被安装;
依赖: ros-kinetic-simulators 但是它将不会被安装;
E: 无法修正错误,因为您要求某些软件包保持现状,就是它们破坏了软件包间的依赖关系。
出现上述问题,有可能是自己的版本不合适不兼容造成,也可能是镜像源没有更新,具体的设置参考软件和更新的截图。当然也有可能是其他原因,比如更新了忘记刷新环境source一下,重开一个终端等等。具体的问题原因可以去搜索引擎上尝试求助解决,或者登陆ROS Wiki(ROS的百科全书)去查询解决自己的具体问题。
ubantu 18
sudo apt install ros-melodic-desktop-full
ubantu 20 因为20没有melodic
sudo apt install ros-noetic-desktop-full
5、安装和初始化rosdep
sudo rosdep init
出现如下界面即成功
lhq@lhqubantu:~/catkin_ws$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run
rosdep update
lhq@lhqubantu:~/catkin_ws$
问题1未安装
rosdep:未找到命令
建议使用apt进行安装,使用apt安装后rosdep可以自动地更新
# ROS Noetic
sudo apt-get install python3-rosdep
# ROS Melodic and earlier
sudo apt-get install python-rosdep
安装
sudo apt install python-rosdep2
或者
sudo apt install python3-rosdep2
使用pip安装
sudo pip install -U rosdep
也可以使用源代码安装
git clone https://github.com/ros-infrastructure/rosdep
cd rosdep
source setup.sh
2继续初始化Rosdep
sudo rosdep init
问题2域名被墙
出现如下
lhq@lhqubantu:~/catkin_ws$ sudo rosdep init
[sudo] lhq 的密码:
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.
lhq@lhqubantu:~/catkin_ws$
方法1:
sudo vim /etc/hosts
或者
sudo gedit /etc/hosts
然添加静态域名解析dns
151.101.84.133 raw.githubusercontent.com
方法2
挂代理
这里涉及敏感话题不多讲
系统必须得有代理
socks5 127.0.0.1 1080
接下来,是设置shell,即终端的代理,让终端的网络走系统的代理
下载proxychains-ng代码
git clone https://github.com/rofl0r/proxychains-ng
编译,可以不用安装,
./configure --prefix=/usr --sysconfdir=/etc
make
修改src\proxychains.conf配置文件,在最后按照说明加上你系统的代理,
[ProxyList]
#add proxy here ...
socks5 127.0.0.1 1080
在源代码下执行,
./proxychains4 -f src/proxychains.conf rosdep update
从上面的命令可以看出来,proxychains4的作用就是在你需要执行的Linux 命令前加上proxychains4 -f src/proxychains.conf
在使用git时,也会出现类似上面的情况,不过git有自己的代理配置工具,可以是直接使用命令进行设置,也可以编辑~/.gitconfig文件
1使用命令
http代理:
git config --global https.proxy http://127.0.0.1:1080
git config --global https.proxy https://127.0.0.1:1080
socks5代理:
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
2编辑文件~/.gitconfig
在文件添加:
[http]
proxy = socks5://127.0.0.1:1080
[https]
proxy = socks5://127.0.0.1:1080
3取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
用其他代理
vim /etc/resolv.conf
添加
nameserver 8.8.8.8
nameserver 8.8.4.4
或者
nameserver 114.114.114.114
另外加(不用加)
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
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
继续sudo rosdep init
问题2 重复文件
lhq@lhqubantu:~/catkin_ws$ sudo rosdep init
[sudo] lhq 的密码:
对不起,请重试。
[sudo] lhq 的密码:
ERROR: default sources list file already exists:
/etc/ros/rosdep/sources.list.d/20-default.list
Please delete if you wish to re-initialize
lhq@lhqubantu:~/catkin_ws$
解决
sudo rm /etc/ros/rosdep/sources.list.d/20-default.list
恭喜你可以完成sudo rosdep init
接下来
更新rosdep
rosdep update
很容易出现没有找到资源或者链接超时之类的错误,比如:unable to process source或error loading sources list: The read operation timed out
原因1
用户没有权限
分析:
rosdep update 不能用 sudo rosdep update 或者进入root用户可以用
解决
加入用户组
usermod -g root lhq(usermane)
给权限
1.更改目录所有者命令:
chown -R 用户名称 目录名称(python那个文件夹/usr/lib/python2.7/dist-packages/)
2.更改目录权限命令:
chmod -R 755 目录名称
原因 2 网络问题
更换网络,手机热点或者有线
ca-certificates问题,证书不对,重新安装证书
sudo apt-get install ca-certificates
还是ssl certs问题,继续尝试解决
sudo c_rehash /etc/ssl/certs
sudo -E rosdep init
rosdep update 终极方法
sudo vim /etc/ros/rosdep/sources.list.d/20-default.list
粘贴下面内容
# os-specific listings first
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml osx
# generic
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
yaml https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
gbpdistro 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
rosdep update 终极方法第二步
常见报错信息就是各种The read operation timed out.。 解决,直接从对应网址保存所有需要的文件,然后把网络路径改成本地文件路径:
下载所有的文件,整理好文件夹,对于主要的yaml文件的路径都在20-default.list这个里面有,基本套路就是https://raw.githubusercontent.com/ros/rosdistro/master/XXX后面的xxx根据不同文件替换一下,打开index-v4.yaml能看到所有需要的其他子文件夹,yaml文件和gz 压缩包:
https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
%YAML 1.1
# ROS index file
# see REP 153: http://ros.org/reps/rep-0153.html
---
distributions:
ardent:
distribution: [ardent/distribution.yaml]
distribution_cache: http://repo.ros2.org/rosdistro_cache/ardent-cache.yaml.gz
distribution_status: end-of-life
distribution_type: ros2
python_version: 3
bouncy:
distribution: [bouncy/distribution.yaml]
distribution_cache: http://repo.ros2.org/rosdistro_cache/bouncy-cache.yaml.gz
distribution_status: end-of-life
distribution_type: ros2
python_version: 3
crystal:
distribution: [crystal/distribution.yaml]
distribution_cache: http://repo.ros2.org/rosdistro_cache/crystal-cache.yaml.gz
distribution_status: end-of-life
distribution_type: ros2
python_version: 3
dashing:
distribution: [dashing/distribution.yaml]
distribution_cache: http://repo.ros2.org/rosdistro_cache/dashing-cache.yaml.gz
distribution_status: active
distribution_type: ros2
python_version: 3
eloquent:
distribution: [eloquent/distribution.yaml]
distribution_cache: http://repo.ros2.org/rosdistro_cache/eloquent-cache.yaml.gz
distribution_status: active
distribution_type: ros2
python_version: 3
foxy:
distribution: [foxy/distribution.yaml]
distribution_cache: http://repo.ros2.org/rosdistro_cache/foxy-cache.yaml.gz
distribution_status: active
distribution_type: ros2
python_version: 3
groovy:
distribution: [groovy/distribution.yaml]
distribution_cache: http://repositories.ros.org/rosdistro_cache/groovy-cache.yaml.gz
distribution_status: end-of-life
distribution_type: ros1
python_version: 2
hydro:
distribution: [hydro/distribution.yaml]
distribution_cache: http://repositories.ros.org/rosdistro_cache/hydro-cache.yaml.gz
distribution_status: end-of-life
distribution_type: ros1
python_version: 2
indigo:
distribution: [indigo/distribution.yaml]
distribution_cache: http://repositories.ros.org/rosdistro_cache/indigo-cache.yaml.gz
distribution_status: end-of-life
distribution_type: ros1
python_version: 2
jade:
distribution: [jade/distribution.yaml]
distribution_cache: http://repositories.ros.org/rosdistro_cache/jade-cache.yaml.gz
distribution_status: end-of-life
distribution_type: ros1
python_version: 2
kinetic:
distribution: [kinetic/distribution.yaml]
distribution_cache: http://repositories.ros.org/rosdistro_cache/kinetic-cache.yaml.gz
distribution_status: active
distribution_type: ros1
python_version: 2
lunar:
distribution: [lunar/distribution.yaml]
distribution_cache: http://repositories.ros.org/rosdistro_cache/lunar-cache.yaml.gz
distribution_status: end-of-life
distribution_type: ros1
python_version: 2
melodic:
distribution: [melodic/distribution.yaml]
distribution_cache: http://repositories.ros.org/rosdistro_cache/melodic-cache.yaml.gz
distribution_status: active
distribution_type: ros1
python_version: 2
noetic:
distribution: [noetic/distribution.yaml]
distribution_cache: http://repositories.ros.org/rosdistro_cache/noetic-cache.yaml.gz
distribution_status: active
distribution_type: ros1
python_version: 3
rolling:
distribution: [rolling/distribution.yaml]
distribution_cache: http://repo.ros2.org/rosdistro_cache/rolling-cache.yaml.gz
distribution_status: rolling
distribution_type: ros2
python_version: 3
type: index
version: 4
直接输进浏览器地址栏,都能直接打开对应的yaml和.gz文件,ctrl+s保存即可,最后形成这么一个文件夹,文件夹的名字自己随便起都可以,里面的子文件夹一定和index-v4.yaml保持一致,如下图所示(我整理好了,大家也可以直接用)。
修改 index-v4.yaml的路径和20-default.list文件里面的路径: sudo gedit /usr/lib/python2.7/dist-packages/rosdistro/init.py ,比如我最后放那些yaml的文件夹放在/etc/ros/ros_github,将网址地址改为file:///etc/ros/ros_github/index-v4.yaml如下图所示:
from .loader import load_url # noqa
from .manifest_provider.cache import CachedManifestProvider, CachedSourceManifestProvider # noqa
# same version as in:
# - setup.py
# - stdeb.cfg
__version__ = '0.8.3'
# index information
#DEFAULT_INDEX_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml'
DEFAULT_INDEX_URL=file:///etc/ros/ros_github/index-v4.yaml
def get_index_url():
# environment variable has precedence over configuration files
if 'ROSDISTRO_INDEX_URL' in os.environ:
return os.environ['ROSDISTRO_INDEX_URL']
把里面指向网址的路径改为本地,比如我最后放那些yaml的文件夹放在/etc/ros/ros_github,修改如下:
sudo vim /etc/ros/rosdep/sources.list.d/20-default.list
# os-specific listings first
yaml file:///etc/ros/ros_github/osx-homebrew.yaml osx
# generic
yaml file:///etc/ros/ros_github/base.yaml
yaml file:///etc/ros/ros_github/python.yaml
yaml file:///etc/ros/ros_github/ruby.yaml
gbpdistro file:///etc/ros/ros_github/fuerte.yaml fuerte
# newer distributions (Groovy, Hydro, ...) must not be listed anymore, they are being fetched from the rosdistro index.yaml instead
再次执行rosdep update命令,出现下面的结果,
lhq@lhqubantu:~/vpn$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
Skip end-of-life distro "ardent"
Skip end-of-life distro "bouncy"
Skip end-of-life distro "crystal"
Add distro "dashing"
Add distro "eloquent"
Add distro "foxy"
Skip end-of-life distro "groovy"
Skip end-of-life distro "hydro"
Skip end-of-life distro "indigo"
Skip end-of-life distro "jade"
Add distro "kinetic"
Skip end-of-life distro "lunar"
Add distro "melodic"
Add distro "noetic"
Add distro "rolling"
updated cache in /home/lhq/.ros/rosdep/sources.cache
lhq@lhqubantu:~/vpn$
这个办法是我在反复rosdep update都不成功的情况下才去尝试的,如果网络还行,在不修改以上文件的情况下,能够成功执行一半,那多试几次可能还是有戏,我试了不下10多次,甚至用了shell写了循环执行rosdep update的脚本,执行了几个小时都没成功。 这个土办法的核心思路就是避开涉及raw.githubusercontent.com的东西,转为本地文件。 当然我这里针对20-default.list这个文件还是选择了联网下,你也可以把这个也下载到本地,然后把他放在/etc/ros/rosdep/sources.list.d/下面。
rossep 自动安装代码
rosdep install --from-paths src --ignore-src -r -y
rosdep install --from-paths src --ignore-src --rosdistro=noetic -y
libqt4-dev install
sudo apt install libqt4-dev
sudo add-apt-repository ppa:rock-core/qt4
sudo apt update
http://wiki.ros.org/yocs_cmd_vel_mux
行数:1863
字数:7754
主题:默认主题