ROS Galatic安装
1. 安装前准备¶
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt install software-properties-common
sudo add-apt-repository universe
2. 安装ros2¶
2.1 添加ros2仓库¶
- 授权秘钥
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
- 添加仓库到列表中
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
2.2 下载ros2包¶
- 到如下地址下载ros2包
https://github.com/ros2/ros2/releases
- 解压下载的ros2包
mkdir -p ~/ros2_galactic
cd ~/ros2_galactic
tar xf ~/Downloads/ros2-package-linux-x86_64.tar.bz2
2.3 安装和初始化rosdep¶
sudo apt update
sudo apt install -y python3-rosdep
sudo rosdep init
rosdep update
如果初始化失败,可以使用下面解决方案
2.4 安装缺失的依赖¶
rosdep install --from-paths ~/ros2_galactic/ros2-linux/share --ignore-src -y --skip-keys "cyclonedds fastcdr fastrtps rti-connext-dds-5.3.1 urdfdom_headers"
2.5 安装python3库¶
sudo apt install -y libpython3-dev python3-pip
3. 配置ros2环境¶
- 添加ros2环境变量
echo "source ~/ros2_galactic/ros2-linux/setup.bash" >> ~/.bashrc
echo "source /opt/ros/galactic/setup.bash" >> ~/.bashrc
- 使环境变量生效
source ~/.bashrc
- 检查环境是否配置成功
printenv | grep -i ROS
查看是否有变量
ROS_DISTRO
和ROS_VERSION
设置ROS_VERSION=2 ROS_PYTHON_VERSION=3 ROS_DISTRO=galactic
4. 安装colcon¶
colcon是ros的构建工具
sudo apt install python3-colcon-common-extensions