ROS2:fatal error: std_msgs/std_msgs/msg/string.hpp: 没有那个文件或目录

原因是在CMakeLists.txt中没有添加依赖:

ament_target_dependencies(wang2_pop_node rclcpp std_msgs)

如果问题还没有解决,则配置VSCode中的包含头文件

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/opt/ros/humble/include/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "gnu17",
            "cppStandard": "gnu++17",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

你可能感兴趣的:(c++,开发语言)