序言
- ubuntu18.04(已安装ros melodic)中安装ros2 dashing版本,以支持ros2工程的编译使用
1. 安装ros melodic
- 参考我之前的文章:docker容器中安装melodic-ros-core过程总结
2. 安装ros2 dashing
-
(1)设置utf-8编码
sudo locale-gen en_US en_US.UTF-8sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8export LANG=en_US.UTF-8
-
(2)更新软件源
sudo apt update && sudo apt install curl gnupg2 lsb-releasecurl http://repo.ros2.org/repos.key | sudo apt-key add -sudo sh -c 'echo "deb [arch=amd64,arm64] http://packages.ros.org/ros2/ubuntu `lsb_release -cs` main" > /etc/apt/sources.list.d/ros2-latest.list'
-
(3)安装ros2 dashing desktop版本
sudo apt install ros-dashing-desktop
- 桌面版包含ROS, RViz, demos, tutorials等,基础版没有GUI工具
- 安装需要一点时间
-
(4)安装命令行自动补全工具
sudo apt install python3-argcomplete
-
(5)配置环境变量
- 当前终端生效
source /opt/ros/dashing/setup.bash
- 当前用户生效
echo "source /opt/ros/dashing/setup.bash" >> ~/.bashrc
-
(6)安装附加的RMW = ros middle ware实现
sudo apt update sudo apt install ros-dashing-rmw-opensplice-cpp # for OpenSplice sudo apt install ros-dashing-rmw-connext-cpp # for RTI Connext (requires license agreement)
-
(7)安装ros1_bridge桥接工具
- ros1_bridge是ros1和ros2消息转换的工具,按需安装
sudo apt update sudo apt install ros-dashing-ros1-bridge
3. 安装过程中碰到的问题记录如下
-
(1)设置utf-8编码报错:找不到安装命令locale-gen
sudo apt-get update sudo apt-get install locales 然后再执行 sudo locale-gen en_US.UTF-8
-
(2)sudo apt-get update时报错 没有公钥
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 缺少的公钥
-
(3)sudo apt-get update时报错找不到软件包 ros-dashing-desktop
- 说明软件列表没有更新,替换软件源后再执行sudo apt-get update
- 替换软件源按如下操作
-
(4)安装时报错:以下软件包未满足的依赖关系
- 按照网上的指导,使用 sudo aptitude install ros-dashing-desktop 命令安装也报错
- 后来机器卡顿了,重启之后添加了中科大软件源,重新执行 sudo apt-get update; sudo apt install ros-dashing-desktop 能正常安装;不确定为啥,关键就是重启,重启后语言系统自动切换为英文就能安装了
-
(5)设置自动切换ros1 ros2环境
- vim ~/.bashrc,然后添加如下内容,默认设置ros1环境
echo choose ROS1.0 or ROS2.0? enter 1=Melodic 2=Dashing read ROS if (($ROS==1));then source /opt/ros/melodic/setup.bash echo "Melodic" elif (($ROS==2));then source /opt/ros/dashing/setup.bash echo "Dashing" else source /opt/ros/melodic/setup.bash echo "Default-ROS-melodic" fi
- 这样新开终端,输入2就能使用ros环境
【参考文章】
docker容器中安装melodic-ros-core
Ubuntu18.04 安装ROS Melodic && Ros2 Dashing踩坑笔记
Ubuntu18.04安装安装ROS2-Dashing
created by shuaixio, 2023.04.09