Ubuntu20.04配置(五)安装ROS2最新版本Foxy

72 篇文章 1 订阅
8 篇文章 10 订阅

原文:在Ubuntu 20.04中安装ROS2最新版本Foxy Fitzroy_大橙员-CSDN博客_ubuntu20.04安装ros2

ROS2 是新一代机器人操作系统。2020年6月5日,ROS2 的最新版本 Foxy Fitzroy 正式发布了, 支持到2023年的3月!


ROS2 支持的平台
Linux (Ubuntu Focal(20.04))
macOS
Windows
ROS2 真正是跨平台了,ROS1 只支持 Linux。

有大神说,不要搞 ROS1 了,直接上 ROS2 ~~

安装ROS2
我们按照 官方的文档 在 Ubuntu 20.04中安装 ROS2 Foxy Fitzroy:

Setup Locale
确保系统要支持 UTF-8:

sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
1
2
3
Setup Sources
添加ROS2的源:

sudo apt update
sudo apt install curl gnupg2 lsb-release

# 下面这条语句,我的输出错误: gpg: no valid OpenPGP data found
# curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
# 解决上面的问题,可以换成下面这条语句:
$ curl http://repo.ros2.org/repos.key | sudo apt-key add - 

# 之后再添加源:
sudo sh -c 'echo "deb http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
1
2
3
4
5
6
7
8
9
10
Install ROS 2 packages
(1)更新源

# 执行更新后,出现问题了
sudo apt update
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'http://packages.ros.org/ros2/ubuntu focal InRelease' doesn't support architecture 'i386'
1
2
3
参照 ROS 2 安装后BUG,解决方法是:

$ cd /etc/apt/sources.list.d
$ sudo gedit ros2-latest.list

# 打开文本后出现:
deb http://packages.ros.org/ros2/ubuntu bionic main

# 在deb后插入[arch=amd64]变成:
deb [arch=amd64] http://packages.ros.org/ros2/ubuntu bionic main

# 保存并关闭

# 再次更新即可
sudo apt update
1
2
3
4
5
6
7
8
9
10
11
12
13
注: 如果更新出现问题了,试试更新多几次

(2)推荐安装ROS2桌面版本(包括ROS, RViz, demos, tutorials)

sudo apt install ros-foxy-desktop
1
注:如果出现问题,试试多重复几次

Environment setup
(1)使用脚本来设置
如果你的SHELL是用bash,就是:

source /opt/ros/foxy/setup.bash
1
如果你的SHELL是用zsh的,就是:

source /opt/ros/foxy/setup.zsh
1
以后每次打开终端都需要输入一次上面的语句,比较麻烦。我们以zsh为例,解决方法:

$ echo "source /opt/ros/foxy/setup.zsh" >> ~/.zshrc 
$ source ~/.zshrc
1
2
这样,以后每次新打开终端,就不需要输入这条烦人的语句了source /opt/ros/foxy/setup.zsh, 终端会自动帮你加载这条语句,设置好ROS2的环境变量。

(2)安装argcomplete(可选)

sudo apt install python3-argcomplete

(3)安装RMW implementation
```bash
sudo apt update
sudo apt install ros-foxy-rmw-connext-cpp
1
2
3
4
5
6
(4)安装ROS1 packages(可选)

sudo apt update
sudo apt install ros-foxy-ros1-bridge
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-foxy-ros1-bridge : Depends: ros-noetic-actionlib-msgs but it is not installable
                        Depends: ros-noetic-catkin but it is not installable
                        Depends: ros-noetic-common-msgs but it is not installable
                        Depends: ros-noetic-gazebo-msgs but it is not installable
                        Depends: ros-noetic-geometry-msgs but it is not installable
                        Depends: ros-noetic-nav-msgs but it is not installable
                        Depends: ros-noetic-rosbash but it is not installable
                        Depends: ros-noetic-roscpp but it is not installable
                        Depends: ros-noetic-roscpp-tutorials but it is not installable
                        Depends: ros-noetic-roslaunch but it is not installable
                        Depends: ros-noetic-rosmsg but it is not installable
                        Depends: ros-noetic-rospy-tutorials but it is not installable
                        Depends: ros-noetic-sensor-msgs but it is not installable
                        Depends: ros-noetic-std-msgs but it is not installable
                        Depends: ros-noetic-std-srvs but it is not installable
                        Depends: ros-noetic-stereo-msgs but it is not installable
                        Depends: ros-noetic-tf but it is not installable
                        Depends: ros-noetic-tf2-msgs but it is not installable
                        Depends: ros-noetic-trajectory-msgs but it is not installable
                        Depends: ros-noetic-visualization-msgs but it is not installable
E: Unable to correct problems, you have held broken packages.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
这些问题应该是我没有事先安装好 ROS1, 我也暂时不用ROS1,所以暂时也不用理会了。

试试例子
我们通过一个例子来看看ROS2有无安装成功:

(1)打开第一个终端,运行C++ talker:
(2)打开第两个终端,运行Python listener:


我们看到,终端1不断地发送[Hello World: xx], 终端2则不断地接收终端1发送的信息。

卸载ROS2
sudo apt remove ros-foxy-*
sudo apt autoremove
1
2

————————————————
版权声明:本文为CSDN博主「大橙员」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/feimeng116/article/details/106602562/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值