ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Directory of executables of ROS nodes compiled with Catkin

asked 2015-01-04 22:45:06 -0600

Alexandre.Willame gravatar image

I have built ROS node that uses openCV and that needs to load some specific files during execution. The files need to be in the 'current directory' in usual OpenCV implementation, which I believe is the directory of the compiled ROS nodes.

  • Is that correct?
  • Where is it located?

The exact code I am talking about can be found on the link given above, where two files, "haarcascade_frontalface_alt.xml" and "haarcascade_eye_tree_eyeglasses.xml" have to be loaded by the instructions

face_cascade.load( face_cascade_name )
eyes_cascade.load( eyes_cascade_name )
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-01-05 01:12:28 -0600

Wolf gravatar image

The executables are saved in the folder <catkin_ws>/devel/lib . However, if you wish to load some other files in your code (what you intent to do) this does not matter. I you use relative pathes for the file you load they need ot be somewhere relatively to your current working directory, i. e. the folder in which your call rosrun like rosrun your_pkg your_node. rosrun automatically locates your executables and runs them in the folder where you call rosrun.

Addition: If you use roslaunch your current working directory, i. e. the folder where your nodes run, will always be <home>/.ros, regardless where it is called....

edit flag offensive delete link more

answered 2015-01-05 07:38:55 -0600

kmhallen gravatar image

You could load using a path relative to your package.

face_cascade.load( ros::package::getPath("some_package") + face_cascade_name );
edit flag offensive delete link more



The string returned by getPath() might not contain a trailing slash so watch out when concatenating it.

Dirk Thomas gravatar image Dirk Thomas  ( 2015-01-05 15:26:55 -0600 )edit

Question Tools



Asked: 2015-01-04 22:45:06 -0600

Seen: 1,496 times

Last updated: Jan 05 '15