non-Catkin build: subscriber can't find msg headers (but can find others)

asked 2019-06-03 05:49:50 -0500

Bruno Vieira gravatar image

updated 2019-06-03 09:51:42 -0500

gvdhoorn gravatar image

Dear all,

I'm quite an experienced user of ROS and am used to write ROS applications, however I'm having an issue that I haven't been able to solve yet, and it is really bothering me, I'll explain:

I'm writing a new application, and can successfully have a proper subscriber for the /clock topic working, even though that my IDE claims that #include <rosgraph_msgs/Clock.h> is an unresolved inclusion just like /ros/ros.h as instance.

When I try to include my header for a custom made .msg (tested in other applications already), my IDE claims that it is, as well, an unresolved inclusion. However, in this case it doesn't even let me successfully compile:

ROSTrafGen.h:87:31: error: ‘ros_its_msgs’ does not name a type
     void SensorCallback(const ros_its_msgs::Sensor &msg);
                               ^~~~~~~~~~~~
ROSTrafGen.h:87:52: error: expected unqualified-id before ‘&’ token
     void SensorCallback(const ros_its_msgs::Sensor &msg);
                                                    ^
ROSTrafGen.h:87:52: error: expected ‘)’ before ‘&’ token
ROSTrafGen.h:87:52: error: expected ‘;’ at end of member declaration
ROSTrafGen.h:87:53: error: ‘msg’ does not name a type
     void SensorCallback(const ros_its_msgs::Sensor &msg);

Any idea on why this is happening?

Thanks in advance. Best regards

edit retag flag offensive close merge delete

Comments

even though that my IDE

which IDE?

gvdhoorn gravatar image gvdhoorn  ( 2019-06-03 05:56:23 -0500 )edit

It is an external tool's dedicated IDE, based of on Eclipse...

Bruno Vieira gravatar image Bruno Vieira  ( 2019-06-03 07:43:15 -0500 )edit

Have you ever setup the environment for Eclipse to be able to support code completion? Something like this?

gvdhoorn gravatar image gvdhoorn  ( 2019-06-03 07:45:29 -0500 )edit

I didn't. As I said, it's a external (has no ROS dependency) tool that uses a dedicated IDE for its projects building and launching... Already did a similar integration between both frameworks, however, t relied on cmake for compiling purposes. This time, this project is done using Makefile environments. This shouldn't be an issue, since I already tested some subscriptions (i.e /clock) under this environment

Bruno Vieira gravatar image Bruno Vieira  ( 2019-06-03 08:44:42 -0500 )edit

Well the problem would seem to be one where the IDE is unaware of the include paths it would need to be able to resolve your includes and parse the headers.

I'm not sure how you would fix that with your toolset, but that is something you'd have to setup.

This would be no different from how you would have your IDE be able to code-complete and parse from other libraries. Just that ROS is typically installed into locations that are not on the default search paths, leading to the requirement of telling your IDE where it should look for these headers.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-03 08:59:07 -0500 )edit

I have my include and library paths all specified correctly during compilation, if not, i wouldn't be able to even make the /clock subscription. So, i'm not worried about what the IDE displays regarding ROS integration, what i'm worried about is on the reason why I can easily subscribe to one topic, while not being able to do it to other one with a different .msg type...

Bruno Vieira gravatar image Bruno Vieira  ( 2019-06-03 09:07:42 -0500 )edit

So just for my understanding:

  • you're using Makefiles, not Catkin
  • an Eclipse-based IDE
  • don't care about code completion
  • get errors when building an application that uses a particular message type from a package containing custom messages

Is this a correct summary?

gvdhoorn gravatar image gvdhoorn  ( 2019-06-03 09:11:00 -0500 )edit

Exactly! That's a perfect summary of this issue, while adding the strange behaviour of this working 100% for one kind of messages..

Bruno Vieira gravatar image Bruno Vieira  ( 2019-06-03 09:18:29 -0500 )edit

We're probably going to need more information on your setup. Like what your Makefiles look like, whether the message that fails is built during the same run of your build, have you checked for typos in ros_its_msgs? Do the headers exist? Are they on the include path? Are you actually including them in ROSTrafGen.h? Etc, etc.

And perhaps a minimal example of a C++ file that, when compiled with your setup, shows the same issue. It could just be a simple .cpp which #include <ros_its_msgs/Sensor.h>.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-03 09:29:46 -0500 )edit

The header is working with other subscription apps, it is in the correct format (no typos), its include path is well declared on compilation. About the makefile compilation mechanism, it is done by the external tool (OMNeT++), and is exactly like a classical makefile compilation.

Bruno Vieira gravatar image Bruno Vieira  ( 2019-06-03 11:32:02 -0500 )edit

Well without a reproducable example I'm not sure we can help you.

its include path is well declared on compilation

Did you check this by running the build in verbose mode?

Edit: have you checked the header contents?

"does not name a type" implies that either the header contains something else, something malformed or the header is not included at all.

gvdhoorn gravatar image gvdhoorn  ( 2019-06-03 11:35:00 -0500 )edit

Keep in mind that topics like /clock use message types included with ROS, while if you are using a custom message type of your own creation the include paths will be different. Without seeing your full code (or at least the relevant parts of your Makefiles) I can't see if this is your problem or not, but just being able to subscribe to topics like /clock does not mean you have all the necessary include paths for your custom message type.

Geoff gravatar image Geoff  ( 2019-06-03 18:50:34 -0500 )edit

This is really odd... I'm inserting /opt/ros/kinetic/include in the Paths where my app will search for includes, only ROS-related path where it is searching for headers, and it can easily find any ROS included message types like /clock. However, there are some other message types that I export its headers into this path (I've been working like this since my work with ROS started), that can't be reached as well...

Any tips on how to do this inclusions with another methodology?

Bruno Vieira gravatar image Bruno Vieira  ( 2019-06-04 04:06:51 -0500 )edit

However, there are some other message types that I export its headers into this path (I've been working like this since my work with ROS started)

are you saying you are install(..)ing into /opt/ros?

gvdhoorn gravatar image gvdhoorn  ( 2019-06-04 04:08:37 -0500 )edit

In this specific case I'm not. I generate the header locally and then just manually copy it into my include folder /opt/ros/kinetic/include. I know it's a bad habit, however it is the way I did it so I could have a centralized source of headers, while being able to access them locally.

Bruno Vieira gravatar image Bruno Vieira  ( 2019-06-04 04:34:28 -0500 )edit