< >
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源
rm superupdate.sh ; wget https://gitee.com/ncnynl/linux-scripts/raw/master/superupdate.sh ; sudo chmod +x ./superupdate.sh; sudo ./superupdate.sh aliyun
  • 增加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
  • 安装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 ~nros-galactic-* && sudo apt autoremove 
  • 删除配置
sudo rm /etc/apt/sources.list.d/ros2.list
sudo apt update
sudo apt autoremove

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

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


标签: ros2入门教程