公司要兼容ros1還需要ros2 這個時候不得不使用ubuntu20.04 安裝 humble 但實際上在20.04上安裝humble是需要在源碼編譯的。
根據這個帖子 https://blog.csdn.net/m0_62353836/article/details/129730981 重寫一份,以應對無法下載的問題
系統配置
#檢查是否為UTF-8編碼,是則跳過!
locale #非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
增加帶有apt 的ros2 gpg秘鑰
sudo apt update && sudo apt install curl
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
這里由于無法通過githubusercontent下載,所以這么改
sudo curl -sSL https://raw.gitmirror.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
安裝開發工具和ROS工具
安裝通用軟件包
sudo apt update && sudo apt install -y \python3-flake8-docstrings \python3-pip \python3-pytest-cov \ros-dev-tools
安裝Ubuntu20.04所需軟件包
python3 -m pip install -U \flake8-blind-except \flake8-builtins \flake8-class-newline \flake8-comprehensions \flake8-deprecated \flake8-import-order \flake8-quotes \"pytest>=5.3" \pytest-repeat \pytest-rerunfailures
獲取ros2源碼
mkdir -p ~/ros2_humble/src
cd ~/ros2_humble
vcs import --input https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos src
這里還是無法下載需要手動下載https://raw.githubusercontent.com/ros2/ros2/humble/ros2.repos這個文件,我們可以通過在鏡像網站上下載此文件然后把github.com 改成bgithub.xyz。即可首先我們下載這個文件
wget https://raw.gitmirror.com/ros2/ros2/humble/ros2.repos
其內容為
repositories:ament/ament_cmake:type: giturl: https://github.com/ament/ament_cmake.gitversion: humbleament/ament_index:type: giturl: https://github.com/ament/ament_index.gitversion: humbleament/ament_lint:type: giturl: https://github.com/ament/ament_lint.gitversion: humbleament/ament_package:type: giturl: https://github.com/ament/ament_package.gitversion: humbleament/google_benchmark_vendor:type: giturl: https://github.com/ament/google_benchmark_vendor.gitversion: humbleament/googletest:type: giturl: https://github.com/ament/googletest.gitversion: humbleament/uncrustify_vendor:type: giturl: https://github.com/ament/uncrustify_vendor.gitversion: humbleeProsima/Fast-CDR:type: giturl: https://github.com/eProsima/Fast-CDR.gitversion: v1.0.24eProsima/Fast-DDS:type: giturl: https://github.com/eProsima/Fast-DDS.gitversion: 2.6.xeProsima/foonathan_memory_vendor:type: giturl: https://github.com/eProsima/foonathan_memory_vendor.gitversion: mastereclipse-cyclonedds/cyclonedds:type: giturl: https://github.com/eclipse-cyclonedds/cyclonedds.gitversion: releases/0.10.xeclipse-iceoryx/iceoryx:type: giturl: https://github.com/eclipse-iceoryx/iceoryx.gitversion: release_2.0ignition/ignition_cmake2_vendor:type: giturl: https://github.com/ignition-release/ignition_cmake2_vendor.gitversion: humbleignition/ignition_math6_vendor:type: giturl: https://github.com/ignition-release/ignition_math6_vendor.gitversion: humbleosrf/osrf_pycommon:type: giturl: https://github.com/osrf/osrf_pycommon.gitversion: masterosrf/osrf_testing_tools_cpp:type: giturl: https://github.com/osrf/osrf_testing_tools_cpp.gitversion: humbleros-perception/image_common:type: giturl: https://github.com/ros-perception/image_common.gitversion: humbleros-perception/laser_geometry:type: giturl: https://github.com/ros-perception/laser_geometry.gitversion: humbleros-planning/navigation_msgs:type: giturl: https://github.com/ros-planning/navigation_msgs.gitversion: humbleros-tooling/keyboard_handler:type: giturl: https://github.com/ros-tooling/keyboard_handler.gitversion: humbleros-tooling/libstatistics_collector:type: giturl: https://github.com/ros-tooling/libstatistics_collector.gitversion: humbleros-visualization/interactive_markers