Ask Your Question
0

Namspace (.h) between packages

asked 2016-09-01 13:13:35 -0600

Pototo gravatar image

Folks,

I created a my_gr_namespace.(h/cpp) in Package_1. The namespace works well for every single node running under Package_1. Now, I am trying to use it in another package (Package_2), but it won't work. I have constants in that name space, and when I print them in Package_2 I get an empty printing. I included the name space this way:

 /// Package_2 file: my_package_2.h
#include <Package_1/my_gr_namespace.h>     // written in this format even inside Package_1 nodes

/// prints an empty output, like "My Constant: (empty space)"
std::cout << "My Constant: " << gr::CONSTANT << "\n\n";

And the output is empty.

In my Package_1 CMakeList I made sure to include the following items to export the name space across ROS:

catkin_package()  # where I put Package_2 include folder, and libraries created
# I tried making the namespace files into a library, and then putting them in catkin_package()
add_library()
install(DIRECTORY )  # to mark the namspace cpp and headers for installation

And, of course, I copied the files directly into Package_2 and did:

/// copying files inside Package_2 did not work either!!!!!!! What the deuce!?
#include <Package_2/my_gr_namespace.h>

I'm not sure what is happening

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-09-01 16:02:54 -0600

Pototo gravatar image

Seems to be more of a C++ problem than a cmake/ROS problem. The reason why I can't see output is because the variable has to be casted to (int). I've never seen that before, though. I'm not what I changed to make behave that way.

Most of my variables are of type "int8_t," and so forth. So if I wanna see output, I gotta do:

std::cout << "My Constant: " << (int) gr::CONSTANT << "\n\n";

I checked, and the rest of the functions in my packages work well, so I don't have to cast before passing into functions or to publish my variables in a topic.

Dang...glorious C++.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-09-01 13:13:35 -0600

Seen: 29 times

Last updated: Sep 01 '16