Can't include custom interface into my cpp file

Hi,

I’m having troubles importing my custom interfaces inside my cpp files using #include.
The thing is what I ask to import isn’t found by VsCode so I get errors.
I built my “services_quiz_srv” package as in the examples and I get the good prompt from “ros2 interface show services_quiz_srv/srv/Spin” but still can’t import it with :

"#include “services_quiz_srv/srv/spin.hpp”

Can somebody help ?

Thanks in advance

Hi @bilal.nouicer ,

Welcome to this Community!

What do you mean by you can’t import it with #include?

Are you trying to use autocomplete in the IDE? Because this feature mostly does not work for custom interface definitions, as far as I know.

Could you be more specific (descriptive) about your problem? Perhaps share one or two screenshots?

Regards,
Girish

Here in the include section of my cpp file :

Capture d’écran 2023-02-01 à 08.16.00

To be honest I don’t know where the compiler looks to find the files in the include section so I’m a bit lost here

Hi @bilal.nouicer ,

So, upon compilation, that is, when you do colcon build ..., the packages get compiled as executables into the ros2_ws/install directory. So during runtime, the executable file knows where to look exactly.

You do not have to worry if the autocomplete does not work for custom interface imports.

I hope this clarifies your doubts. By the way, this is how ROS2 is designed to work. So if you need more info as to why it is designed this way, then you must refer the documentation pages.
[This is my understanding so far, I may not be exactly correct.]

Regards,
Girish

Okay thanks for the answer.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.