Ubuntu 22.04 系统中 ROS2安装
ROS2安装
bash
# 多窗口终端工具
sudo apt update
sudo apt install tilix
- 打开软件,点击右上角图标进入设置 -> General -> size120, columns:48
- Command -> 勾选第一个 Run command as login shell
- Color -> Theme Color 选择 Monokai Dark
bash
sudo apt install python3-pip
bash
# 设置地区语言:en-US
sudo apt update && sudo apt install locales
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
bash
# 添加 universe 仓库
sudo apt install software-properties-common
sudo add-apt-repository universe
bash
# 安装资源下载(curl)与密钥转换(gnupg2)依赖包
sudo apt update && sudo apt install curl gnupg2 -y
bash
# 下载公钥,可能需要手动添加到系统
sudo curl -sSL https://gitee.com/tyx6/rosdistro/raw/master/ros.key -o /etc/apt/trusted.gpg.d/ros.gpg
- 通过 Import Key File 手动添加
bash
# 添加ros2安装包源
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/trusted.gpg.d/ros.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
bash
# 如果安装出错,提示缺少python 的qt库,可以执行这一步试试
sudo apt --fix-broken install
bash
# (可选项)安装ros开发工具
sudo apt update && sudo apt install ros-dev-tools
bash
# 安装开发工具ros2软件
sudo apt update && sudo apt upgrade
# sudo apt install ros-<ros-distro>-desktop, 例如 iron
sudo apt install ros-iron-desktop
bash
# 配置环境
echo """
# Replace ".bash" with your shell if you're not using bash
# Possible values are: setup.bash, setup.sh, setup.zsh
source /opt/ros/iron/setup.bash
""" >> ~/.bashrc
测试
bash
source /opt/ros/iron/setup.bash
ros2 run demo_nodes_cpp talker
bash
source /opt/ros/iron/setup.bash
ros2 run demo_nodes_py listener
卸载
bash
# 查看环境
printenv | grep -i ROS
bash
sudo apt remove ~nros-iron-* && sudo apt autoremove
bash
sudo rm /etc/apt/sources.list.d/ros2.list
sudo apt update
sudo apt autoremove
# Consider upgrading for packages previously shadowed.
sudo apt upgrade