为了账号安全,请及时绑定邮箱和手机立即绑定

【ROS教程】安装ROS全流程及可能遇到的问题

@TOC


1.配置Softerware & Updates

  • 如图所示配置即可

2.添加软件源

  • 如果不添加软件源,是无法定位软件包的

清华源


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'

3.设置key


sudo  apt-key  adv  --keyserver  'hkp://keyserver.ubuntu.com:80'  --recv-key  C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654

  • 如果不设置key,在sudo apt update的时候会有如下问题

E: Could not get lock /var/lib/apt/lists/lock. It is held by process 1347 (packagekitd)

N: Be aware that removing the lock file is not a solution and may break your system.

E: Unable to lock directory /var/lib/apt/lists/

4.更新并安装

4.1 更新


sudo  apt  update

4.2 安装(ros-noetic-desktop-full)

  • 如果使用apt安装,几乎百分百会出现如下问题

xu736946693@ubuntu:~$  sudo  apt  install  ros-noetic-desktop-full

Reading  package  lists...  Done

Building  dependency  tree

Reading  state  information...  Done

Some  packages  could  not  be  installed.  This  may  mean  that  you  have  requested  an  impossible  situation  or  if  you  are  using  the  unstable  distribution  that  some  required  packages  have  not  yet  been  created  or  been  moved  out  of  Incoming.

The  following  information  may  help  to  resolve  the  situation:

  

The  following  packages  have  unmet  dependencies:

ros-noetic-desktop-full  :  Depends:  ros-noetic-desktop  but  it  is  not  going  to  be  installed

Depends:  ros-noetic-perception  but  it  is  not  going  to  be  installed

Depends:  ros-noetic-simulators  but  it  is  not  going  to  be  installed

E:  Unable  to  correct  problems,  you  have  held  broken  packages.

  • 因此我们使用aptitude安装

4.2.1 安装aptitude


sudo  apt  install  aptitude

4.2.2 安装ROS软件包


sudo  aptitude  install  ros-noetic-desktop-full

  • 接下来会列出一栏未安装的:

Keep  the  following  packages  at  their  current  version:

1) libcurl4-gnutls-dev [Not Installed]

2) libgphoto2-dev [Not Installed]

3) libopencv-calib3d-dev [Not Installed]

4) libopencv-contrib-dev [Not Installed]

5) libopencv-dev [Not Installed]

6) libopencv-features2d-dev [Not Installed]

7) libopencv-highgui-dev [Not Installed]

8) libopencv-objdetect-dev [Not Installed]

9) libopencv-stitching-dev [Not Installed]

10) libopencv-superres-dev [Not Installed]

11) libopencv-videoio-dev [Not Installed]

12) libopencv-videostab-dev [Not Installed]

13) ros-noetic-camera-calibration [Not Installed]

14) ros-noetic-compressed-depth-image-transport [Not Installed]

15) ros-noetic-compressed-image-transport [Not Installed]

16) ros-noetic-cv-bridge [Not Installed]

17) ros-noetic-depth-image-proc [Not Installed]

18) ros-noetic-desktop [Not Installed]

19) ros-noetic-desktop-full [Not Installed]

20) ros-noetic-gazebo-plugins [Not Installed]

21) ros-noetic-gazebo-ros-pkgs [Not Installed]

22) ros-noetic-image-geometry [Not Installed]

23) ros-noetic-image-pipeline [Not Installed]

24) ros-noetic-image-proc [Not Installed]

25) ros-noetic-image-publisher [Not Installed]

26) ros-noetic-image-rotate [Not Installed]

27) ros-noetic-image-transport-plugins [Not Installed]

28) ros-noetic-image-view [Not Installed]

29) ros-noetic-perception [Not Installed]

30) ros-noetic-rqt-common-plugins [Not Installed]

31) ros-noetic-rqt-image-view [Not Installed]

32) ros-noetic-simulators [Not Installed]

33) ros-noetic-stereo-image-proc [Not Installed]

34) ros-noetic-theora-image-transport [Not Installed]

35) ros-noetic-vision-opencv [Not Installed]

36) ros-noetic-viz [Not Installed]

  

Accept  this  solution? [Y/n/q/?] n

  • 切记,此时一定要选no,因为有很多未安装的。

  • 然后,aptitude会给出第二个解决方案,仍然有很多未安装的,继续选no


4) libignition-fuel-tools4-dev [Not Installed]

5) libopencv-calib3d-dev [Not Installed]

6) libopencv-contrib-dev [Not Installed]

7) libopencv-dev [Not Installed]

8) libopencv-features2d-dev [Not Installed]

9) libopencv-highgui-dev [Not Installed]

10) libopencv-objdetect-dev [Not Installed]

11) libopencv-stitching-dev [Not Installed]

12) libopencv-superres-dev [Not Installed]

13) libopencv-videoio-dev [Not Installed]

14) libopencv-videostab-dev [Not Installed]

15) ros-noetic-camera-calibration [Not Installed]

16) ros-noetic-compressed-depth-image-transport [Not Installed]

17) ros-noetic-compressed-image-transport [Not Installed]

18) ros-noetic-cv-bridge [Not Installed]

19) ros-noetic-depth-image-proc [Not Installed]

20) ros-noetic-desktop [Not Installed]

21) ros-noetic-desktop-full [Not Installed]

22) ros-noetic-gazebo-dev [Not Installed]

23) ros-noetic-gazebo-plugins [Not Installed]

24) ros-noetic-gazebo-ros [Not Installed]

25) ros-noetic-gazebo-ros-control [Not Installed]

26) ros-noetic-gazebo-ros-pkgs [Not Installed]

27) ros-noetic-image-geometry [Not Installed]

28) ros-noetic-image-pipeline [Not Installed]

29) ros-noetic-image-proc [Not Installed]

30) ros-noetic-image-publisher [Not Installed]

31) ros-noetic-image-rotate [Not Installed]

32) ros-noetic-image-transport-plugins [Not Installed]

33) ros-noetic-image-view [Not Installed]

34) ros-noetic-perception [Not Installed]

35) ros-noetic-rqt-common-plugins [Not Installed]

36) ros-noetic-rqt-image-view [Not Installed]

37) ros-noetic-simulators [Not Installed]

38) ros-noetic-stereo-image-proc [Not Installed]

39) ros-noetic-theora-image-transport [Not Installed]

40) ros-noetic-urdf-sim-tutorial [Not Installed]

41) ros-noetic-vision-opencv [Not Installed]

42) ros-noetic-viz [Not Installed]

  

Accept  this  solution? [Y/n/q/?] n

  • 第三次,aptitude给出了满意的方案,只有一个未安装的,这时可以选yes了

Keep  the  following  packages  at  their  current  version:

1) libcurl4-gnutls-dev [Not Installed]

  

Downgrade  the  following  packages:

2) libgphoto2-6 [2.5.25-0ubuntu0.1 (now) -> 2.5.24-1 (focal)]

  

Accept  this  solution? [Y/n/q/?] y

5.添加环境变量


echo  "source /opt/ros/noetic/setup.bash" >> ~/.bashrc

source  ~/.bashrc

6.安装构建依赖


sudo  apt  install  python3-rosdep  python3-rosinstall  python3-rosinstall-generator  python3-wstool  build-essential

7.初始化和更新

7.1 初始化


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.

7.1.1 目前可行的解决办法:重新定位资源,github换gitee

  1. 修改/usr/lib/python3/dist-packages/rosdistro/__init__.py的第68行

  2. 修改/usr/lib/python3/dist-packages/rosdep2/sources_list.py的第64行

  3. 修改/usr/lib/python3/dist-packages/rosdep2/rep3的第36行

  • 修改方式:把raw.githubusercontent.com/ros/rosdistro/master替换成gitee.com/zhao-xuzuo/rosdistro/raw/master,如下:

64 DEFAULT_SOURCES_LIST_URL = 'https://raw.githubusercontent.com/ros/rosdistro/master/rosdep/sources.list.d/20-default.list'

修改为


64 DEFAULT_SOURCES_LIST_URL = 'https://gitee.com/zhao-xuzuo/rosdistro/raw/master/rosdep/sources.list.d/20-default.list'

7.1.2 结果


sudo  rosdep  init

  • 如果出现以下结果,则成功

Wrote  /etc/ros/rosdep/sources.list.d/20-default.list

Recommended:  please  run

  

rosdep  update

7.2 更新


rosdep  update

  • 结果

reading  in  sources  list  data  from  /etc/ros/rosdep/sources.list.d

Hit  https://gitee.com/zhao-xuzuo/rosdistro/raw/master/rosdep/osx-homebrew.yaml

Hit  https://gitee.com/zhao-xuzuo/rosdistro/raw/master/rosdep/base.yaml

Hit  https://gitee.com/zhao-xuzuo/rosdistro/raw/master/rosdep/python.yaml

Hit  https://gitee.com/zhao-xuzuo/rosdistro/raw/master/rosdep/ruby.yaml

Hit  https://gitee.com/zhao-xuzuo/rosdistro/raw/master/rosdep/releases/fuerte.yaml

Query  rosdistro  index  https://gitee.com/zhao-xuzuo/rosdistro/raw/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"

Skip  end-of-life  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/xu736946693/.ros/rosdep/sources.cache

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

举报

0/150
提交
取消