【发布时间】: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