How can I get the src directory of a package in a ROSLaunch file.

asked 2021-08-05 14:40:55 -0500

dbalaban gravatar image

I want my rosnode to know where the src directory for related packages are, and I'd like the launch file to automatically figure that out so the user doesn't have to give that information every time they call the node. I defined this argument to accomplish that:

arg name="prism_directory" default="$(find placard_discovery)"

I passed it into my node like so:

param name="prism_directory" type="string" value="$(arg prism_directory)"

what the node then receives is:

/home/david/prism-ws/devel/share/placard_discovery

which points to the devel directory and not the src directory, so what I would like instead is the same directory returned by rospack:

→ rospack find placard_discovery

/home/david/prism-ws/src/prism2/placard_discovery

Why would roslaunch's find not return the same directory as rospack find in this context? Thank you for your assistance.

edit retag flag offensive close merge delete

Comments

Why would you want to find src?

I think that the information needed to run the program after building is located under devel. So, when you use roslaunch to find, it will find under devel.

I think the solution is to change install in CMakeLists.txt so that data in src will be installed in devel.

miura gravatar image miura  ( 2021-08-05 18:17:55 -0500 )edit

There are config files I need to access for third party non-ros packages that are in the src directory, specifically prototxt files for caffe. I would rather not have all the ros related code installed into src, as that sounds messy, is that they only way to get this functionality?

dbalaban gravatar image dbalaban  ( 2021-08-05 18:35:54 -0500 )edit
1

Funny, on noetic and using rospy / catkin_build I cannot reproduce this. It is pointing to the src directory for me. What are you using? Oh, and, are you by any chance, using chained workspaces?

mgruhler gravatar image mgruhler  ( 2021-08-06 02:15:43 -0500 )edit
2

As @miura said you would need to install the resources your node needs to run. I do not agree with the advice of installing the src folder though. As you say the files you need are config files so should not be in the src folder to begin with. Make a folder called config in your package, move your config files in there and install that folder similarly to how the launch folder is installed in the ros docs example

Reamees gravatar image Reamees  ( 2021-08-06 06:28:57 -0500 )edit