【经验总结】Ubuntu 22.04 安装 ROS

版本选择


电脑配置

【经验总结】Ubuntu 22.04 安装 ROS_第1张图片

  • Ubuntu 22.04.3 LTS

ROS 版本

ROS1[https://wiki.ros.org/Distributions]

ROS2[https://docs.ros.org/en/humble/Releases.html]

Ubuntu ROS1 Release date End of Life
Ubuntu 20.04 LTS Noetic Ninjemys May 23rd, 2020 May, 2025
Ubuntu 18.04 LTS Melodic Morenia May 23rd, 2018 May, 2023
Ubuntu 17.04 LTS Lunar Loggerhead May 23rd, 2017 May, 2019
Ubuntu 16.04 LTS Kinetic Kame May 23rd, 2016 April, 2021
Ubuntu 15.04 LTS Jade Turtle May 23rd, 2015 May, 2017
Ubuntu 14.04 LTS Indigo lgloo July 22nd, 2014 April, 2019
Ubuntu ROS2 Release date End of Life
Ubuntu 22.04 LTS Iron Irwini May 23rd, 2023 November 2024
Ubuntu 22.04 LTS Humble Hawksbill May 23rd, 2022 May 2027
Ubuntu 20.04 LTS Galactic Geochelone May 23rd, 2021 December 9th, 2022
Ubuntu 20.04 LTS Foxy Fitzroy June 5th, 2020 June 20th, 2023
Ubuntu 18.04 LTS Eloquent Elusor November 22nd, 2019 November 2020
Ubuntu 18.04 LTS Dashing Diademata May 31st, 2019 May 2021
Ubuntu 18.04 LTS Crystal Clemmys December 14th, 2018 December 2019
Ubuntu 18.04 LTS
Ubuntu 16.04 LTS Bouncy Bolson July 2nd, 2018 July 2019
Ubuntu 16.04 LTS Ardent Apalone December 8th, 2017 December 2018

【经验总结】Ubuntu 22.04 安装 ROS_第2张图片

  • 最后选择安装 Humble Hawksbill on Ubuntu Linux 22.04, Windows 10

安装 ROS2 Humble Hawksbill 系统


设置语言环境编码

locale  # 检查UTF-8

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

locale  # 验证设置

【经验总结】Ubuntu 22.04 安装 ROS_第3张图片

设置源

  • 确保 Ubuntu Universe 存储库已启用
sudo apt install software-properties-common
sudo add-apt-repository universe
  • 使用 apt 添加 ROS 2 GPG 密钥
sudo apt update && sudo apt install curl -y
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
  • 将存储库添加到您的源列表中
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.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

安装 ROS2 软件包(安装时间比较久,请耐心等待)

sudo apt update
sudo apt upgrade
sudo apt install ros-humble-desktop

【经验总结】Ubuntu 22.04 安装 ROS_第4张图片

设置环境

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

测试系统


通信系统测试

  • 启动第一个终端,输入以下命令启动数据发布者节点
ros2 run demo_nodes_cpp talker
  • 启动第二个终端,输入以下命令启动数据订阅者节点
ros2 run demo_nodes_py listener
  • 发布者发出“Hello World”,而订阅者收到“Hello World”,则验证 C++ 和 Python API 正常工作

小海龟仿真器

  • 启动第一个终端,输入以下命令启动海龟仿真器
ros2 run turtlesim turtlesim_node
  • 启动第二个终端,输入以下命令启动键盘控制节点
ros2 run turtlesim turtle_teleop_key
  • 在第二个终端点击上下左右按键,可以控制小海龟运动

卸载 ROS2 Humble Hawksbill 系统


卸载 ROS 2 或切换到基于源的安装

sudo apt remove ~nros-humble-*
sudo apt autoremove

删除存储库

sudo rm /etc/apt/sources.list.d/ros2.list
sudo apt update
sudo apt autoremove
sudo apt upgrade

你可能感兴趣的:(经验总结,ubuntu,linux,运维,机器人,人工智能)