colcon build --symlink-install ros2_example_ws 出错

本文记录了在使用Colcon构建ROS2包时遇到的错误,主要原因是未找到ament_cmake配置文件,通过设置环境变量解决了问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用colcon去build packages,出现下面的错误:

sph@sph-System-Product-Name:~/Documents/ros2_example_ws$ colcon build --symlink-install
Starting >>> examples_rclcpp_minimal_action_client
Starting >>> examples_rclcpp_minimal_action_server
Starting >>> examples_rclcpp_minimal_client
Starting >>> examples_rclcpp_minimal_composition
Starting >>> examples_rclcpp_minimal_publisher
Starting >>> examples_rclcpp_minimal_service
Starting >>> examples_rclcpp_minimal_subscriber
Starting >>> examples_rclcpp_minimal_timer
Starting >>> examples_rclpy_executors
Starting >>> examples_rclpy_minimal_action_client
Starting >>> examples_rclpy_minimal_action_server
Starting >>> examples_rclpy_minimal_client
Starting >>> examples_rclpy_minimal_publisher
Starting >>> examples_rclpy_minimal_service
Starting >>> examples_rclpy_minimal_subscriber
--- stderr: examples_rclcpp_minimal_action_server                                                                                                
CMake Error at CMakeLists.txt:13 (find_package):
  By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ament_cmake", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake" with
  any of the following names:

    ament_cmakeConfig.cmake
    ament_cmake-config.cmake

  Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
  "ament_cmake_DIR" to a directory containing one of the above files.  If
  "ament_cmake" provides a separate development package or SDK, be sure it
  has been installed.


---
Failed   <<< examples_rclcpp_minimal_action_server	[ Exited with code 1 ]
--- stderr: examples_rclcpp_minimal_action_client
CMake Error at CMakeLists.txt:13 (find_package):
  By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ament_cmake", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake" with
  any of the following names:

    ament_cmakeConfig.cmake
    ament_cmake-config.cmake

  Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
  "ament_cmake_DIR" to a directory containing one of the above files.  If
  "ament_cmake" provides a separate development package or SDK, be sure it
  has been installed.


---
Failed   <<< examples_rclcpp_minimal_action_client	[ Exited with code 1 ]
--- stderr: examples_rclcpp_minimal_client
CMake Error at CMakeLists.txt:13 (find_package):
  By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ament_cmake", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake" with
  any of the following names:

    ament_cmakeConfig.cmake
    ament_cmake-config.cmake

  Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
  "ament_cmake_DIR" to a directory containing one of the above files.  If
  "ament_cmake" provides a separate development package or SDK, be sure it
  has been installed.


---
Failed   <<< examples_rclcpp_minimal_client	[ Exited with code 1 ]
--- stderr: examples_rclcpp_minimal_composition
CMake Error at CMakeLists.txt:13 (find_package):
  By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ament_cmake", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake" with
  any of the following names:

    ament_cmakeConfig.cmake
    ament_cmake-config.cmake

  Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
  "ament_cmake_DIR" to a directory containing one of the above files.  If
  "ament_cmake" provides a separate development package or SDK, be sure it
  has been installed.


---
Failed   <<< examples_rclcpp_minimal_composition	[ Exited with code 1 ]
--- stderr: examples_rclcpp_minimal_publisher
CMake Error at CMakeLists.txt:13 (find_package):
  By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ament_cmake", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake" with
  any of the following names:

    ament_cmakeConfig.cmake
    ament_cmake-config.cmake

  Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
  "ament_cmake_DIR" to a directory containing one of the above files.  If
  "ament_cmake" provides a separate development package or SDK, be sure it
  has been installed.


---
Failed   <<< examples_rclcpp_minimal_publisher	[ Exited with code 1 ]
--- stderr: examples_rclcpp_minimal_service
CMake Error at CMakeLists.txt:13 (find_package):
  By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ament_cmake", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake" with
  any of the following names:

    ament_cmakeConfig.cmake
    ament_cmake-config.cmake

  Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
  "ament_cmake_DIR" to a directory containing one of the above files.  If
  "ament_cmake" provides a separate development package or SDK, be sure it
  has been installed.


---
Failed   <<< examples_rclcpp_minimal_service	[ Exited with code 1 ]
--- stderr: examples_rclcpp_minimal_subscriber
CMake Error at CMakeLists.txt:13 (find_package):
  By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ament_cmake", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake" with
  any of the following names:

    ament_cmakeConfig.cmake
    ament_cmake-config.cmake

  Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
  "ament_cmake_DIR" to a directory containing one of the above files.  If
  "ament_cmake" provides a separate development package or SDK, be sure it
  has been installed.


---
Failed   <<< examples_rclcpp_minimal_subscriber	[ Exited with code 1 ]
--- stderr: examples_rclcpp_minimal_timer
CMake Error at CMakeLists.txt:13 (find_package):
  By not providing "Findament_cmake.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "ament_cmake", but CMake did not find one.

  Could not find a package configuration file provided by "ament_cmake" with
  any of the following names:

    ament_cmakeConfig.cmake
    ament_cmake-config.cmake

  Add the installation prefix of "ament_cmake" to CMAKE_PREFIX_PATH or set
  "ament_cmake_DIR" to a directory containing one of the above files.  If
  "ament_cmake" provides a separate development package or SDK, be sure it
  has been installed.


---
Failed   <<< examples_rclcpp_minimal_timer	[ Exited with code 1 ]
Finished <<< examples_rclpy_executors [1.65s]
Finished <<< examples_rclpy_minimal_action_client [1.64s]
Finished <<< examples_rclpy_minimal_action_server [1.64s]                                                                              
Finished <<< examples_rclpy_minimal_client [1.63s]
Finished <<< examples_rclpy_minimal_publisher [1.63s]
Aborted  <<< examples_rclpy_minimal_service
Aborted  <<< examples_rclpy_minimal_subscriber                               
                                  
Summary: 5 packages finished [2.06s]
  8 packages failed: examples_rclcpp_minimal_action_client examples_rclcpp_minimal_action_server examples_rclcpp_minimal_client examples_rclcpp_minimal_composition examples_rclcpp_minimal_publisher examples_rclcpp_minimal_service examples_rclcpp_minimal_subscriber examples_rclcpp_minimal_timer
  2 packages aborted: examples_rclpy_minimal_service examples_rclpy_minimal_subscriber
  8 packages had stderr output: examples_rclcpp_minimal_action_client examples_rclcpp_minimal_action_server examples_rclcpp_minimal_client examples_rclcpp_minimal_composition examples_rclcpp_minimal_publisher examples_rclcpp_minimal_service examples_rclcpp_minimal_subscriber examples_rclcpp_minimal_timer

一般原因都是工作环境变量没设置对,所以在build之前,最好source一下你要在ros1还是ros2的哪个版本上的进行build
解决办法:

source /opt/ros/dashing/local_setup.bash
### Carla与ROS 2桥接的集成指南 Carla 是一款用于自动驾驶研究的开源模拟器,而 ROS (Robot Operating System) 则是一个广泛应用于机器人开发的框架。为了实现两者之间的通信和数据交换,Carla 提供了一个名为 `carla_ros_bridge` 的工具包[^1]。 #### 工具包功能概述 `carla_ros_bridge` 主要负责将 CARLA 模拟环境中的传感器数据转换为标准的 ROS 2 消息类型,并允许用户通过 ROS 节点控制车辆行为。该工具支持多种常见的传感器类型,例如摄像头、激光雷达以及IMU等设备的数据传输。 #### 安装步骤说明 对于希望使用此桥梁插件的研究人员来说, 需要先安装CARLA仿真平台及其对应的Python API客户端库文件;之后按照官方文档指示下载并编译特定版本号匹配好的源码仓库来完成整个设置过程: ```bash git clone https://github.com/carla-simulator/ros-bridge.git -b ros2 foxy_ws/src/ cd foxy_ws && colcon build --symlink-install source install/setup.bash ``` 上述命令展示了如何克隆最新版代码至指定工作区目录下并通过Colcon构建系统执行增量式链接安装操作。 #### 启动配置实例 启动脚本通常会加载预定义参数集以初始化必要的节点和服务接口: ```xml <launch> <!-- Launch arguments --> <arg name="town" default="Town01"/> <!-- Include carla simulation environment launch file--> <include file="$(find carla_spawn_objects)/launch/spawn.launch"> <arg name="host" value="localhost"/> <arg name="port" value="2000"/> <arg name="timeout" value="10"/> <arg name="synchronous_mode" value="true"/> <arg name="sync_vehicle_filters" value=""/> </include> <!-- Start the bridge between CARLA and ROS nodes --> <node pkg="carla_ros_bridge" type="carla_ros_bridge_node" name="carla_ros_bridge"/> </launch> ``` 以上XML片段描述了一种典型场景下的发射流程设计模式——即通过调用子模块内的具体方法实现在不同层次间传递消息的功能需求。 #### 数据流处理机制分析 当一辆由ROS控制系统管理的小车行驶于虚拟城市街道上时,其轨迹规划算法可能依赖实时更新的地图信息作为输入条件之一。此时,“carla_ros_bridge” 将发挥重要作用:一方面接收来自外部物理世界感知层采集到的目标物体位置坐标集合;另一方面又把经过内部逻辑运算后的指令反馈给前者从而形成闭环控制回路结构图示如下所示: ![Data Flow Diagram](https://example.com/data_flow_diagram.png) 请注意实际应用过程中还需要考虑同步误差校正等问题才能达到更精确的效果表现形式。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

晚餐男孩

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值