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 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
- 安装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
更新key
- ros2下更新key
sudo curl http://repo.ros2.org/repos.key | sudo apt-key add -
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号