ROS2 colcon build 遇到问题

        当使用小鱼的教程时 colon build 遇到错误: 

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.

        问题源于无法用普通权限 colon build(可能由于某些文件是由root权限创建),只能用root权限运行colon build命令,但由于小鱼自动安装时可能没将ros2 的文件source进入 root文件的~/.bashrc中,因此以root权限运行时找不到相应的 ament_cmake 路径,因此报错。

        所以解决办法为:

        一、直接将source “你的ros2路径(我的为/opt/ros/foxy/setup.bash中入root 权限下的 ~/.bashrc中,如图:

         二、在root权限下输入一下命令:

//路径因人而异
source /opt/ros/foxy/setup.bash

你可能感兴趣的:(linux)