服务器安装 ros2时遇到底层库依赖冲突的问题
近期工作需要用到ros2, 所以在一台服务器上准备安装ros2, 先按照官网走安装流程
参考: Ubuntu (deb packages) — ROS 2 Documentation: Humble documentation
设置utf-8
locale # check for UTF-8sudo 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-8locale # verify settings
添加ros2 apt软件源并下载ros2-apt-source、解压缩
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo apt update && sudo apt install curl -y
export ROS_APT_SOURCE_VERSION=$(curl -s https://api.github.com/repos/ros-infrastructure/ros-apt-source/releases/latest | grep -F "tag_name" | awk -F\" '{print $4}')
curl -L -o /tmp/ros2-apt-source.deb "https://github.com/ros-infrastructure/ros-apt-source/releases/download/${ROS_APT_SOURCE_VERSION}/ros2-apt-source_${ROS_APT_SOURCE_VERSION}.$(. /etc/os-release && echo $VERSION_CODENAME)_all.deb" # If using Ubuntu derivates use $UBUNTU_CODENAME
sudo dpkg -i /tmp/ros2-apt-source.deb
更新软件源:
sudo apt update
sudo apt upgrade
安装ros:
sudo apt install ros-humble-desktop
遇到报错:
在更新软件源后修复:
1. 备份当前源
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
2. 修改/etc/apt/sources.list 文件为:
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
3. 更新并重新安装:
sudo apt update
sudo apt install ros-humble-desktop
即可完成ros2在linux下的环境配置, 测试: