Home » ROS2入门教程 » ROS2入门教程-在ubuntu22.04下apt安装ros2版本humble

ROS2入门教程-在ubuntu22.04下apt安装ros2版本humble

ROS2入门教程-在ubuntu22.04下apt安装ros2版本humble

说明:

  • 介绍如何安装ros2版本humble
  • 测试环境:nuc 系统:ubuntu22.04

步骤:

  • 支持utf字符
locale  # check for 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  # verify settings
  • 增加apt源
rm update_ros2source.sh ; wget https://gitee.com/ncnynl/ros-scripts/raw/master/update_ros2source.sh ; sudo chmod +x ./update_ros2source.sh; sudo ./update_ros2source.sh tsinghua
  • 增加key
  • 下载密钥
sudo apt update && sudo apt install curl gnupg lsb-release
sudo curl -sSL https://mirrors.tuna.tsinghua.edu.cn/rosdistro/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
  • 增加ros源到源列表
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] https://mirrors.tuna.tsinghua.edu.cn/ros2/ubuntu $(source /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
  • 安装ros包
  • 更新软件列表
sudo apt update
  • 安装humble桌面版本
sudo apt install ros-humble-desktop
  • 加载环境
source /opt/ros/humble/setup.bash
  • 安装自动补全
sudo apt install python3-argcomplete
  • 安装colcon和pip
sudo apt install python3-pip
sudo apt install python3-colcon-common-extensions

测试:

  • 新开终端,运行发布话题
source /opt/ros/humble/setup.bash
ros2 run demo_nodes_cpp talker
  • 新开终端,运行订阅话题
source /opt/ros/humble/setup.bash
ros2 run demo_nodes_py listener

删除:

  • 命令:
sudo apt remove ~nros-humble-* && sudo apt autoremove 
  • 删除配置
sudo rm /etc/apt/sources.list.d/ros2.list
sudo apt update
sudo apt autoremove

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: ros2入门教程