non-Catkin build: subscriber can't find msg headers (but can find others)
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
which IDE?
It is an external tool's dedicated IDE, based of on Eclipse...
Have you ever setup the environment for Eclipse to be able to support code completion? Something like this?
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
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.
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...
So just for my understanding:
Makefile
s, not CatkinIs this a correct summary?
Exactly! That's a perfect summary of this issue, while adding the strange behaviour of this working 100% for one kind of messages..
We're probably going to need more information on your setup. Like what your
Makefile
s look like, whether the message that fails is built during the same run of your build, have you checked for typos inros_its_msgs
? Do the headers exist? Are they on the include path? Are you actually including them inROSTrafGen.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>
.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.
Well without a reproducable example I'm not sure we can help you.
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.
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 yourMakefile
s) 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.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?
are you saying you are
install(..)
ing into/opt/ros
?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.