ROS2学习笔记:ROS2 Navigation2编译过程中遇到的问题

首先在github上下载源码
记得选择对应版本
ROS2学习笔记:ROS2 Navigation2编译过程中遇到的问题_第1张图片
放在工作空间的src文件下
1、解决依赖问题

rosdep install -i --from-path src --rosdistro eloquent -y

出现报错信息:

gym@gym:~/wheeltec_robot_ros2$ rosdep install -i --from-path src --rosdistro eloquen -y
WARNING: given --rosdistro eloquen but ROS_DISTRO is "eloquent". Ignoring environment.
WARNING: ROS_PYTHON_VERSION is unset. Defaulting to 2
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
nav2_behavior_tree: Cannot locate rosdep definition for [behaviortree_cpp_v3]
nav2_system_tests: Cannot locate rosdep definition for [launch_testing]
nav2_map_server: Cannot locate rosdep definition for [launch_testing]
nav2_amcl: Cannot locate rosdep definition for [launch_testing]
nav2_bringup: Cannot locate rosdep definition for [launch_testing]
nav2_core: Cannot locate rosdep definition for [launch_testing]
nav2_bt_navigator: Cannot locate rosdep definition for [behaviortree_cpp_v3]
nav2_util: Cannot locate rosdep definition for [test_msgs]
nav2_costmap_2d: Cannot locate rosdep definition for [launch_testing]

解决方法:
添加-r参数,忽略报错重新安装依赖

rosdep install -i --from-path src --rosdistro eloquent -y -r

2、编译:

colcon build

依然报错:

CMake Error at test/CMakeLists.txt:4 (find_package):
  By not providing "Findtest_msgs.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "test_msgs", but CMake did not find one.

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

    test_msgsConfig.cmake
    test_msgs-config.cmake

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

---
 

解决方法:手动安装依赖包
类似的还有几个依赖包,一起安装了

sudo apt install ros-eloquent-test-msgs
sudo apt install ros-eloquent-behaviortree-cpp-v3
sudo apt install ros-eloquent-gazebo-rospkgsr

这里安装依赖包有个技巧:如果你不知道这个依赖包在这个版本中的名称是什么,比如test-msgs,可以先打出 ros-eloquent-test 再双击Tab键,找到相对应的包就可以了。
重新编译就成功了。

你可能感兴趣的:(ROS2,ros学习)