Path to resource files in C++ node
Hello fellow developers,
I have trouble determining the path to a folder containing resource files in a self written C++ catkin package. I am using the following macro in CMakeLists.txt to export the resource files (a couple of .xml files btw.):
install(DIRECTORY resources
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
This creates the following "resources" folder:
home/ros/catkin_ws/install/share/opencv_ros_node/resources/
I need to access the resource files in my source code here:
string cascade_path = "/home/ros/catkin_ws/src/opencv_ros_node/src/resources/haarcascade.xml";
haar_cascade.load( cascade_path );
Obviously, I do not want to use a hardcoded absolute path. But how can I determine the correct relative path to the resource folder during run time? (Ideally, this should also work if 'catkin_make install' has not been run explicitly)
Any help is appreciated.
Cheers, Heiko
I guess you'd be OK if it's in PKG/resources as installed and not PKG/src/resources (or anywhere generically reachable). The src/ directory might not exist for installations.