【问题标题】:ROS noetic, fatal error: ros/ros.h: No such file or directoryROS 提示,致命错误:ros/ros.h: No such file or directory
【发布时间】:2021-05-18 09:32:55
【问题描述】:

我正在尝试启动一个 c++ 脚本(只是来自 ROS tutorial 的侦听器,名称为 subpub.cpp)但我收到错误“致命错误:ros/ros.h:没有这样的文件或目录”。

我尝试查看有关此的旧问题,但它们似乎对我不起作用。

我在ubuntu上使用noetic,catkin_make没有报错。

这是我的 packege.xml 文件:

<?xml version="1.0"?>
<package format="2">
  <name>infoexc</name>
  <version>0.0.0</version>
  <description>The infoexc package</description>
  <maintainer email="cnr@todo.todo">cnr</maintainer>
  <license>TODO</license>
  <buildtool_depend>catkin</buildtool_depend>
  <build_depend>roscpp</build_depend>
  <build_depend>rospy</build_depend>
  <build_depend>std_msgs</build_depend>
  <build_export_depend>roscpp</build_export_depend>
  <build_export_depend>rospy</build_export_depend>
  <build_export_depend>std_msgs</build_export_depend>
  <exec_depend>roscpp</exec_depend>
  <exec_depend>rospy</exec_depend>
  <exec_depend>std_msgs</exec_depend>
  <export>
    <!-- Other tools can request additional information be placed here -->
  </export>
</package>

这是我的 CMakeLists.txt 文件:

cmake_minimum_required(VERSION 3.0.2)
project(infoexc)

find_package(catkin REQUIRED COMPONENTS
  roscpp
  rospy
  std_msgs
)
include_directories(
  ${catkin_INCLUDE_DIRS}
)
add_executable(subpub scripts/C++/subpub.cpp)
target_link_libraries(subpub ${catkin_LIBRARIES})

c++ 中的脚本在 /catkin_ws/src/infoexc/scripts/C++ 中,在 python 中一切正常。

提前致谢!

【问题讨论】:

  • 我认为错误与'Visual Studio code'有关,我应该将库添加到我认为的路径中,但我不知道如何。

标签: c++ publish-subscribe ros


【解决方案1】:

对于 ROS,我总是从命令行构建它。

cd /path/to/your/catkin_ws && source devel/setup.bash && catkin_make

您需要获取您的项目,然后调用catkin_make,这应该会创建一个构建并能够链接ros.h

【讨论】:

    猜你喜欢
    • 2018-09-30
    • 2020-01-20
    • 1970-01-01
    • 2013-05-05
    • 2022-01-13
    • 2018-04-24
    • 2023-03-12
    • 1970-01-01
    • 2017-02-14
    相关资源
    最近更新 更多