How can I get the src directory of a package in a ROSLaunch file.
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.
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 underdevel
.I think the solution is to change install in CMakeLists.txt so that data in
src
will be installed indevel
.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?
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?
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