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

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

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

说明:

  • 介绍如何安装ros2版本galactic
  • 测试环境:nuc 系统:ubuntu20.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源
  • 确认是否有 Ubuntu Universe repository
apt-cache policy | grep universe
 500 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
     release v=20.04,o=Ubuntu,a=focal,n=focal,l=Ubuntu,c=universe,b=amd64
  • 没有则添加
sudo apt install software-properties-common
sudo add-apt-repository universe
  • 增加key
  • 下载密钥
sudo apt update && sudo apt install curl gnupg lsb-release
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/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] http://packages.ros.org/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
  • 安装galactic桌面版本
sudo apt install ros-galactic-desktop
  • 加载环境
source /opt/ros/galactic/setup.bash
  • 安装自动补全
sudo apt install python3-argcomplete
  • 安装colcon和pip
sudo apt install python3-pip
sudo apt install python3-colcon-common-extensions

测试:

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

删除:

  • 命令:
sudo apt remove ros-galactic-* && sudo apt autoremove 
  • 或者命令:
sudo apt remove ros-galactic-desktop && sudo apt autoremove 

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

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


标签: ros2入门教程