文章目录
1. ubuntu设置为中文界面
2.配置Ubuntu软件仓库



3.设置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'
利用 “sh -c” 命令,它可以让 bash 将一个字串作为完整的命令来执行,这样就可以将 sudo 的影响范围扩展到整条命令,这条命令的意思是把"deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main"双引号中的内容添加到/etc/apt/sources.list.d/ros-latest.list文件中。
4.设置密钥
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
5. 安装ros
安装之前先执行sudo apt update更新软件源,我们这里安装桌面完整版本:
sudo apt install ros-noetic-desktop-full
6. 设置环境
你需要在使用ROS的每个bash终端中source这个脚本。
source /opt/ros/noetic/setup.bash
而下面这些命令可以在每次启动新的shell窗口时很方便地为你自动source一下这个脚本
echo "source /opt/ros/noetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
7. 测试ROS安装是否成功
在终端输入:
roscore 启动RosMaster
再新建一个终端,输入:
rosrun turtlesim turtlesim_node
再新建一个终端,输入:
rosrun turtlesim turtle_teleop_key
- 注意:光标必须聚焦在键盘控制窗口(turtle_teleop_key对应的),否则无法控制乌龟运动。

8. 安装构建依赖
到这里,我们已经安装了运行核心ROS包所需的组件。要创建和管理自己的ROS工作区,需要分别分发各种工具和需求。例如,rosinstall是一个常用的命令行工具,它使您能够使用一个命令轻松地下载ROS包的许多源树。
要安装此工具和其他用于构建ROS包的依赖项,请运行
sudo apt install python3-rosdep python3-rosinstall python3-rosinstall-generator python3-wstool build-essential
8.1 初始化rosdep
开始使用ROS之前,先初始化rosdep,rosdep能够轻松地安装要编译的源代码的系统依赖关系,rosdep是ROS核心组件运行的基础
rosdep是ros的一个功能包,在安装ros时会自动安装.在使用时需要初始化.ros包有两个不同类型的依赖项:build依赖项和run依赖项。rosdep就是用来检查包的丢失依赖项,并且完成下载和安装。
第一次rosdep init和update执行结果:
```bash
telpo@telpo:~$ sudo rosdep init
Wrote /etc/ros/rosdep/sources.list.d/20-default.list
Recommended: please run
rosdep update
telpo@telpo:~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
ERROR: error loading sources list:
The read operation timed out
如果出现rosdep init失败情况,比如:
elpo@telpo:~$ sudo rosdepc init init
ERROR: Rosdep experienced an error: The read operation timed out
Please go to the rosdep page [1] and file a bug report with the stack trace below.
[1] : http://www.ros.org/wiki/rosdep
rosdep version: 0.22.2
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/rosdep2/main.py", line 146, in rosdep_main
...
出现“timed out”问题主要是在国内sudo rosdep init失败主要是由于网络不通引起的,赵老师的此视频有相关介绍有两种方法可以解决:
8.1.1 采用GitHub在国内的备份网址,内网初始化的方法
sudo apt-get install python3-pip -y
sudo pip3 install rosdepc
sudo rosdepc init
rosdepc update
8.1.2 自己手动处理
如果 /etc/ros/rosdep/sources.list.d目录存在,则只需修改/etc/ros/rosdep/sources.list.d目录下的文
件,如果/etc/ros/rosdep/sources.list.d目录不存在,需要手动创建上面所述的目录:
/etc/ros/rosdep/sources.list.d (当然说的是在etc目录下…),自己制作20-default.list文件。
8.1.2.1 如/etc/ros/rosdep/sources.list.d目录存在
cd /etc/ros/rosdep/sources.list.d
sudo gedit 20-default.list
在每一个https://raw.githubusercontent.com/前面添加https://ghproxy.com/
修改好的
# 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
改后后执行rosdep update,前面4个网址访问成功,但最后1个还是访问,错误信息如下:
kandi@ubuntu:/etc/ros/rosdep/sources.list.d$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
ERROR: unable to process source [https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml]:
Failed to download target platform data for gbpdistro:
<urlopen error [Errno 111] Connection refused>
Query rosdistro index https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml
ERROR: error loading sources list:
<urlopen error <urlopen error [Errno 111] Connection refused> (https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml)>
提示无法访问https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml和https://raw.githubusercontent.com/ros/rosdistro/master/index-v4.yaml,此时需要修改index-v4.yaml所在的位置。
需要特别注意:
ros noetic版本基于python3,所以在/usr/lib/python3路径下修改,其他ros版本若基于python2的,需要找到对应的python2 路径进行修改。
修改的方法是在下面这些文件中https://raw.githubusercontent.com前面加上https://ghproxy.com/
(1) 修改
sudo gedit /usr/lib/python3/dist-packages/rosdep2/gbpdistro_support.py

(2) 修改在__init__.py文件中修改index-v4.yaml的位置
sudo gedit /usr/lib/python3/dist-packages/rosdistro/__init__.py

继续rosdep update,但还有出错的信息:
把下面几个文件对应的地方也改了
/usr/lib/python3/dist-packages/rosdep2/sources_list.py
/usr/lib/python3/dist-packages/rosdep2/rep3.py
/usr/lib/python3/dist-packages/rosdistro/manifest_provider/github.py此文件两个地方需要修改
继续rosdep update,还是有问题,比如:
ERROR: unable to process source [https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml]
在多执行几次rosdep update就ok了,信息如下:
kandi@ubuntu:~$ rosdep update
reading in sources list data from /etc/ros/rosdep/sources.list.d
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/osx-homebrew.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/base.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/python.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/ruby.yaml
Hit https://ghproxy.com/https://raw.githubusercontent.com/ros/rosdistro/master/releases/fuerte.yaml
Query rosdistro index https://ghproxy.com/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"
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/kandi/.ros/rosdep/sources.cache
8.1.2.2 /etc/ros/rosdep/sources.list.d目录不存在
手动创建上面所述的目录: /etc/ros/rosdep/sources.list.d ,自己创建20-default.list文件。
在终端输入
cd /etc
sudo mkdir ros
cd ros
sudo mkdir rosdep
cd rosdep
sudo mkdir sources.list.d
cd sources.list.d
Sudo gedit 20-default.list
在gedit 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
882



被折叠的 条评论
为什么被折叠?



