2023年6月21日
Ubuntu22.04安装ROS2
环境:Ubuntu22.04 amd64 桌面版
- 确保系统支持UTF-8
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
- 设置安装源
添加ROS2 apt仓库sudo apt install software-properties-common sudo add-apt-repository universe
添加ROS2 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
Desktop Install (Recommended): ROS, RViz, demos, tutorials.
sudo apt install ros-humble-desktop
ROS-Base Install (Bare Bones): Communication libraries, message packages, command line tools. No GUI tools.
sudo apt install ros-humble-ros-base
Development tools: Compilers and other tools to build ROS packages
sudo apt install ros-dev-tools
- 环境配置
添加环境变量到~/.bashrcsource /opt/ros/humble/setup.bash
- 示例
C++ talkerros2 run demo_nodes_cpp talker
Python listener
ros2 run demo_nodes_py listener