ROS2-IRON Ubuntu-22.0 源码下载失败解决方法 vcs import --input

ROS2

  • 一.ROS2 IRON环境搭建
        • 1.设置系统字符集为UTF-8
        • 2.将RO2 apt 库添加到系统中
        • 3.添加ROS2 GPG key
        • 4.添加ROS 2 的软件源
        • 安装开发工具
  • 二.下载ROS2sh源代码
        • 编译

一.ROS2 IRON环境搭建

虚拟机系统:Ubuntu22.04
虚拟机:VMware-player-full-16.2.5-20904516 (这个是非商用就可以免费使用的哦)
电脑系统:WIN10
以下操作都是在虚拟机下的Ubuntu22.04环境中。
详细步骤参考ROS2官网:

1.设置系统字符集为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

2.将RO2 apt 库添加到系统中

sudo apt install software-properties-common
sudo add-apt-repository universe

3.添加ROS2 GPG key

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

4.添加ROS 2 的软件源

这个命令的作用是将 ROS 2 的软件源添加到/etc/apt/sources.list.d/ros2.list 文件中。这样系统就可以从这个源中获取 ROS 2 相关的软件包。

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

安装开发工具

sudo apt update && sudo apt install -y \
  python3-flake8-docstrings \
  python3-pip \
  python3-pytest-cov \
  python3-flake8-blind-except \
  python3-flake8-builtins \
  python3-flake8-class-newline \
  python3-flake8-comprehensions \
  python3-flake8-deprecated \
  python3-flake8-import-order \
  python3-flake8-quotes \
  python3-pytest-repeat \
  python3-pytest-rerunfailures \
  ros-dev-tools

二.下载ROS2sh源代码

创建ros2_iron/src目录,并下载相关源码。

mkdir -p ~/ros2_iron/src
cd ~/ros2_iron
vcs import --input https://raw.githubusercontent.com/ros2/ros2/iron/ros2.repos src

这一步我尝试了很多方法,各种换源。但是因为电脑不能的原因,一直下失败。我的解决方法是在浏览器中访问

https://raw.githubusercontent.com/ros2/ros2/iron/ros2.repos

可以看到以下信息:

repositories:
 ament/ament_cmake:
   type: git
   url: https://github.com/ament/ament_cmake.git
   version: iron
 ament/ament_index:
   type: git
   url: https://github.com/ament/ament_index.git
   version: iron
 ament/ament_lint:
   type: git
   url: https://github.com/ament/ament_lint.git
   version: iron
 ament/ament_package:
   type: git
   url: https://github.com/ament/ament_package.git
   version: iron
 ament/google_benchmark_vendor:
   type: git
   url: https://github.com/ament/google_benchmark_vendor.git
   version: iron
 ament/googletest:
   type: git
   url: https://github.com/ament/googletest.git
   version: iron
 ament/uncrustify_vendor:
   type: git
   url: https://github.com/ament/uncrustify_vendor.git
   version: iron
 eProsima/Fast-CDR:
   type: git
   url: https://github.com/eProsima/Fast-CDR.git
   version: v1.0.27
 eProsima/Fast-DDS:
   type: git
   url: https://github.com/eProsima/Fast-DDS.git
   version: 2.10.x
 eProsima/foonathan_memory_vendor:
   type: git
   url: https://github.com/eProsima/foonathan_memory_vendor.git
   version: master
 eclipse-cyclonedds/cyclonedds:
   type: git
   url: https://github.com/eclipse-cyclonedds/cyclonedds.git
   version: releases/0.10.x
 eclipse-iceoryx/iceoryx:
   type: git
   url: https://github.com/eclipse-iceoryx/iceoryx.git
   version: release_2.0
 gazebo-release/gz_cmake2_vendor:
   type: git
   url: https://github.com/gazebo-release/gz_cmake2_vendor.git
   version: iron
 gazebo-release/gz_math6_vendor:
   type: git
   url: https://github.com/gazebo-release/gz_math6_vendor.git
   version: iron
 osrf/osrf_pycommon:
   type: git
   url: https://github.com/osrf/osrf_pycommon.git
   version: master
 osrf/osrf_testing_tools_cpp:
   type: git
   url: https://github.com/osrf/osrf_testing_tools_cpp.git
   version: iron
 ros-perception/image_common:
   type: git
   url: https://github.com/ros-perception/image_common.git
   version: iron
 ros-perception/laser_geometry:
   type: git
   url: https://github.com/ros-perception/laser_geometry.git
   version: iron
 ros-planning/navigation_msgs:
   type: git
   url: https://github.com/ros-planning/navigation_msgs.git
   version: iron
 ros-tooling/keyboard_handler:
   type: git
   url: https://github.com/ros-tooling/keyboard_handler.git
   version: iron
 ros-tooling/libstatistics_collector:
   type: git
   url: https://github.com/ros-tooling/libstatistics_collector.git
   version: iron
 ros-visualization/interactive_markers:
   type: git
   url: https://github.com/ros-visualization/interactive_markers.git
   version: iron
 ros-visualization/python_qt_binding:
   type: git
   url: https://github.com/ros-visualization/python_qt_binding.git
   version: iron
 ros-visualization/qt_gui_core:
   type: git
   url: https://github.com/ros-visualization/qt_gui_core.git
   version: iron
 ros-visualization/rqt:
   type: git
   url: https://github.com/ros-visualization/rqt.git
   version: iron
 ros-visualization/rqt_action:
   type: git
   url: https://github.com/ros-visualization/rqt_action.git
   version: iron
 ros-visualization/rqt_bag:
   type: git
   url: https://github.com/ros-visualization/rqt_bag.git
   version: iron
 ros-visualization/rqt_console:
   type: git
   url: https://github.com/ros-visualization/rqt_console.git
   version: iron
 ros-visualization/rqt_graph:
   type: git
   url: https://github.com/ros-visualization/rqt_graph.git
   version: iron
 ros-visualization/rqt_msg:
   type: git
   url: https://github.com/ros-visualization/rqt_msg.git
   version: iron
 ros-visualization/rqt_plot:
   type: git
   url: https://github.com/ros-visualization/rqt_plot.git
   version: iron
 ros-visualization/rqt_publisher:
   type: git
   url: https://github.com/ros-visualization/rqt_publisher.git
   version: iron
 ros-visualization/rqt_py_console:
   type: git
   url: https://github.com/ros-visualization/rqt_py_console.git
   version: iron
 ros-visualization/rqt_reconfigure:
   type: git
   url: https://github.com/ros-visualization/rqt_reconfigure.git
   version: iron
 ros-visualization/rqt_service_caller:
   type: git
   url: https://github.com/ros-visualization/rqt_service_caller.git
   version: iron
 ros-visualization/rqt_shell:
   type: git
   url: https://github.com/ros-visualization/rqt_shell.git
   version: iron
 ros-visualization/rqt_srv:
   type: git
   url: https://github.com/ros-visualization/rqt_srv.git
   version: iron
 ros-visualization/rqt_topic:
   type: git
   url: https://github.com/ros-visualization/rqt_topic.git
   version: iron
 ros-visualization/tango_icons_vendor:
   type: git
   url: https://github.com/ros-visualization/tango_icons_vendor.git
   version: iron
 ros/class_loader:
   type: git
   url: https://github.com/ros/class_loader.git
   version: iron
 ros/kdl_parser:
   type: git
   url: https://github.com/ros/kdl_parser.git
   version: iron
 ros/pluginlib:
   type: git
   url: https://github.com/ros/pluginlib.git
   version: iron
 ros/resource_retriever:
   type: git
   url: https://github.com/ros/resource_retriever.git
   version: iron
 ros/robot_state_publisher:
   type: git
   url: https://github.com/ros/robot_state_publisher.git
   version: iron
 ros/ros_environment:
   type: git
   url: https://github.com/ros/ros_environment.git
   version: iron
 ros/ros_tutorials:
   type: git
   url: https://github.com/ros/ros_tutorials.git
   version: iron
 ros/urdfdom:
   type: git
   url: https://github.com/ros/urdfdom.git
   version: iron
 ros/urdfdom_headers:
   type: git
   url: https://github.com/ros/urdfdom_headers.git
   version: iron
 ros2/ament_cmake_ros:
   type: git
   url: https://github.com/ros2/ament_cmake_ros.git
   version: iron
 ros2/common_interfaces:
   type: git
   url: https://github.com/ros2/common_interfaces.git
   version: iron
 ros2/console_bridge_vendor:
   type: git
   url: https://github.com/ros2/console_bridge_vendor.git
   version: iron
 ros2/demos:
   type: git
   url: https://github.com/ros2/demos.git
   version: iron
 ros2/eigen3_cmake_module:
   type: git
   url: https://github.com/ros2/eigen3_cmake_module.git
   version: iron
 ros2/example_interfaces:
   type: git
   url: https://github.com/ros2/example_interfaces.git
   version: iron
 ros2/examples:
   type: git
   url: https://github.com/ros2/examples.git
   version: iron
 ros2/geometry2:
   type: git
   url: https://github.com/ros2/geometry2.git
   version: iron
 ros2/launch:
   type: git
   url: https://github.com/ros2/launch.git
   version: iron
 ros2/launch_ros:
   type: git
   url: https://github.com/ros2/launch_ros.git
   version: iron
 ros2/libyaml_vendor:
   type: git
   url: https://github.com/ros2/libyaml_vendor.git
   version: iron
 ros2/message_filters:
   type: git
   url: https://github.com/ros2/message_filters.git
   version: iron
 ros2/mimick_vendor:
   type: git
   url: https://github.com/ros2/mimick_vendor.git
   version: iron
 ros2/orocos_kdl_vendor:
   type: git
   url: https://github.com/ros2/orocos_kdl_vendor.git
   version: iron
 ros2/performance_test_fixture:
   type: git
   url: https://github.com/ros2/performance_test_fixture.git
   version: iron
 ros2/pybind11_vendor:
   type: git
   url: https://github.com/ros2/pybind11_vendor.git
   version: iron
 ros2/python_cmake_module:
   type: git
   url: https://github.com/ros2/python_cmake_module.git
   version: iron
 ros2/rcl:
   type: git
   url: https://github.com/ros2/rcl.git
   version: iron
 ros2/rcl_interfaces:
   type: git
   url: https://github.com/ros2/rcl_interfaces.git
   version: iron
 ros2/rcl_logging:
   type: git
   url: https://github.com/ros2/rcl_logging.git
   version: iron
 ros2/rclcpp:
   type: git
   url: https://github.com/ros2/rclcpp.git
   version: iron
 ros2/rclpy:
   type: git
   url: https://github.com/ros2/rclpy.git
   version: iron
 ros2/rcpputils:
   type: git
   url: https://github.com/ros2/rcpputils.git
   version: iron
 ros2/rcutils:
   type: git
   url: https://github.com/ros2/rcutils.git
   version: iron
 ros2/realtime_support:
   type: git
   url: https://github.com/ros2/realtime_support.git
   version: iron
 ros2/rmw:
   type: git
   url: https://github.com/ros2/rmw.git
   version: iron
 ros2/rmw_connextdds:
   type: git
   url: https://github.com/ros2/rmw_connextdds.git
   version: iron
 ros2/rmw_cyclonedds:
   type: git
   url: https://github.com/ros2/rmw_cyclonedds.git
   version: iron
 ros2/rmw_dds_common:
   type: git
   url: https://github.com/ros2/rmw_dds_common.git
   version: iron
 ros2/rmw_fastrtps:
   type: git
   url: https://github.com/ros2/rmw_fastrtps.git
   version: iron
 ros2/rmw_implementation:
   type: git
   url: https://github.com/ros2/rmw_implementation.git
   version: iron
 ros2/ros2_tracing:
   type: git
   url: https://github.com/ros2/ros2_tracing.git
   version: iron
 ros2/ros2cli:
   type: git
   url: https://github.com/ros2/ros2cli.git
   version: iron
 ros2/ros2cli_common_extensions:
   type: git
   url: https://github.com/ros2/ros2cli_common_extensions.git
   version: iron
 ros2/ros_testing:
   type: git
   url: https://github.com/ros2/ros_testing.git
   version: iron
 ros2/rosbag2:
   type: git
   url: https://github.com/ros2/rosbag2.git
   version: iron
 ros2/rosidl:
   type: git
   url: https://github.com/ros2/rosidl.git
   version: iron
 ros2/rosidl_core:
   type: git
   url: https://github.com/ros2/rosidl_core.git
   version: iron
 ros2/rosidl_dds:
   type: git
   url: https://github.com/ros2/rosidl_dds.git
   version: iron
 ros2/rosidl_defaults:
   type: git
   url: https://github.com/ros2/rosidl_defaults.git
   version: iron
 ros2/rosidl_dynamic_typesupport:
   type: git
   url: https://github.com/ros2/rosidl_dynamic_typesupport
   version: iron
 ros2/rosidl_dynamic_typesupport_fastrtps:
   type: git
   url: https://github.com/ros2/rosidl_dynamic_typesupport_fastrtps
   version: iron
 ros2/rosidl_python:
   type: git
   url: https://github.com/ros2/rosidl_python.git
   version: iron
 ros2/rosidl_runtime_py:
   type: git
   url: https://github.com/ros2/rosidl_runtime_py.git
   version: iron
 ros2/rosidl_typesupport:
   type: git
   url: https://github.com/ros2/rosidl_typesupport.git
   version: iron
 ros2/rosidl_typesupport_fastrtps:
   type: git
   url: https://github.com/ros2/rosidl_typesupport_fastrtps.git
   version: iron
 ros2/rpyutils:
   type: git
   url: https://github.com/ros2/rpyutils.git
   version: iron
 ros2/rviz:
   type: git
   url: https://github.com/ros2/rviz.git
   version: iron
 ros2/spdlog_vendor:
   type: git
   url: https://github.com/ros2/spdlog_vendor.git
   version: iron
 ros2/sros2:
   type: git
   url: https://github.com/ros2/sros2.git
   version: iron
 ros2/system_tests:
   type: git
   url: https://github.com/ros2/system_tests.git
   version: iron
 ros2/test_interface_files:
   type: git
   url: https://github.com/ros2/test_interface_files.git
   version: iron
 ros2/tinyxml2_vendor:
   type: git
   url: https://github.com/ros2/tinyxml2_vendor.git
   version: iron
 ros2/tinyxml_vendor:
   type: git
   url: https://github.com/ros2/tinyxml_vendor.git
   version: iron
 ros2/tlsf:
   type: git
   url: https://github.com/ros2/tlsf.git
   version: iron
 ros2/unique_identifier_msgs:
   type: git
   url: https://github.com/ros2/unique_identifier_msgs.git
   version: iron
 ros2/urdf:
   type: git
   url: https://github.com/ros2/urdf.git
   version: iron
 ros2/yaml_cpp_vendor:
   type: git
   url: https://github.com/ros2/yaml_cpp_vendor.git
   version: iron

url对应的就是github上所在的源代码。把github上的这些源代码仓库转移到gitee上,这个gitee提供了这一部分的功能。
在ros2_iron路径下,用vim新建ros2.repos文件。

vim ros2.repos 

vim 在normal模式下,输入"+p将https://raw.githubusercontent.com/ros2/ros2/iron/ros2.repos中的内容复制到本地(前提是已经复制到系统内存中了,才能使用这个命令)。用vim查找替换url地址。

:%s/https\/\/github.com\/\(.*\)\//gitee.com:makuswork\//g

这样本地中ros2.repos中的url中的内容全部修改成我自己的gitee仓库中了。我把地址改成了ssh的通信。下载源代码时就不用一直的输入帐号和密码了。保存关闭。

在ros2_iron路径下

vcs import --input ros2.repos src

ros2sourcecodedownload
请添加图片描述

编译

sudo apt upgrade
sudo rosdep init
rosdep update
rosdep install --from-paths src --ignore-src -y --skip-keys "fastcdr rti-connext-dds-6.0.1 urdfdom_headers"
colcon build --symlink-install

如果编译报错,EasyInstallDeprecationWarning,可以参考colcon build --symlink-install ,编译失败解决方法

你可能感兴趣的:(夜深人静学ros,ubuntu,ROS2)