Error content:
/home/firefly/eai_ws/src/square/square_goal_service/src/service_server.cpp:3:53: fatal error: square_goal_service/square_goal_service.h: No such file or directory 没有那个文件或目录 #include <square_goal_service/square_goal_service.h>
1. First, find whether the header file exists (include)
If the header file exists, check to see if you told the compiler the path to the file!
2. Second, check whether the path is set correctly (CMakeLists.txt)
catkin_package(
LIBRARIES visionutil rosutil
INCLUDE_DIRS include)
include_directories(
include
${catkin_INCLUDE_DIRS})
3. Finally, check whether the method of calling the xxx.h file in the src source code is correct
correct:
#include <name_of_package/header_file.h>
mistake:
#include <header_file.h>
Summarize
The above three steps are also the process of creating .h header files in ROS:
-
Create a header file, the specific file path is as follows
include/ < name of package > / xxx.h
, /include and /src are at the same level, and both are at the next level of package; -
INCLUDE_DIRS include
Add path, modify CMakeLists.txt, add and respectively in catkin_package and include_directoriesinclude
; -
Reference the header file, add the header file in the application code,
#include <name_of_package/header_file.h>