I am experiencing an issue exactly like the one found here, but maybe I can re-explain the steps that led me to the issue. Every package in my workspace can no longer can find header files for any of my custom service messages.
I was able to compile and run my packages, I logged off and when I came back I encountered this error:
/home/user/catkin_ws/src/my_cpp_class/src/bb8_move_duration_srv_class.cpp:2:42: fatal error: my_cpp_class/durationservice.h: No such file or directory
The package that is causing error was not a package I was working on at the time. If I delete this package and try catkin make, then the next package with custom service messages raises this same error.
Now, if I do the following then everything works:
comment out the add executable lines in my makefile
compile the package
source devel/setup.bash
uncomment the add executable lines
recompile
What is puzzling to me is that all of these packages (makefiles, launch, executables, etc.) were not edited and working before encountering this error.
@rmmilner sounds like a sourcing issue. Just running source devel/setup.bash
Should fix it. When switching chapter and returning, this is done automatically. @bayodesegun Perhaps you should check that the sourcing is done when reloading a session.
Yes this exact issue has happened again. I created a new package, did catkin_make and now some old package from the first unit can’t find the header-file for my custom service message. This package I haven’t touched for a long while.
However, this time, leaving the module and returning did not fix the issue. I had to comment the executable lines, make, source, uncomment lines, and make again to have it compile correctly.
I have discovered that letting the module ‘time-out’ is what causes this. When I leave the window open for too long and it disconnects, this is when it happens. Leaving the module normally does not cause the error.
Please post the exact error you are seeing now. It might be another reason or just that your CMakeLists.txt and/or pacakage.xml is/are not properly setup.
You are trying to import a message from another package my_cpp_class. Please take note of the following:
To do this, you needed to have added my_cpp_class as a dependency when creating the package, i.e. catkin_create_pkg your_package_name roscpp my_cpp_class other_dependencies.
For the Services Quiz (and other quizzes), you should create the custom message within the quiz package itself rather than import it from another package. Yeah, we know about code reuse but just want to keep things simple for the automatic grader. Also, you get to practise creating a custom message again .
Please adjust your package and let us know how it goes.
Did you follow the guide for preparing CMakeLists.txt and package.xml? From the CMakeLists.txt you shared, I can see the following are missing:
std_msgs is missing in find_package. And do you really need geometry_msgs for building your custom message?
catkin_package is empty? Why?
Did you edit package.xml as indicated?
I suggest that you carefully review the section about creating custom service messages in the notebook (section titled How to Prepare CMakeLists.txt and package.xml for Custom Service Compilation in Unit Understanding ROS Services - Server), carefully make needed changes and then let us know if you still have problems.
PS: before compiling again, don’t forget to rm -rf build/ devel/.