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

how does roslaunch $(find ...) actually work?

asked 2017-01-11 05:21:28 -0500

Short version of the question: When using installspace, where does $(find pkg) look for files? rospack find pkg returns the path to the share folder, but then I realized that we are able to do for instance $(find pkg)/scripts/ although is installed in the lib folder. How can this work?

Long version of the question: I have the following case (very common in the ROS community):

Package A:

| - CMakeLists.txt
| - package.xml
| - launch
       | - test.launch
| - scripts
       | -

CMakeLists.txt content:

# Regular Catkin CMakeList.txt

install(DIRECTORY launch

test.launch content:

    <param name="my_param" command="$(find A)/scripts/"/>
</launch> content is not meaningful.

After using installspace (or cross-compiling with bitbake using meta-ros repository) the file structure will look like:

| - share
        | - A/launch/test.launch
| - lib
        | - A/

I always thought that $(find pkg) worked the same as rospack find pkg but apparently not, as the second returns $(ROS_DIR)/share but the above launchfile is able to run the script in the lib folder. Therefore, how does $(find pkg) work, how does it resolve the corresponding path to use?

edit retag flag offensive close merge delete


Are you sure it is looking at the installed file and not the one in your workspace? In your example $(ROS_DIR)/scripts/ doesn't exist but catkin_ws/A/scripts/ does. My guess would be that is what it is finding using ROS_PACKAGE_PATH or CMAKE_PREFIX_PATH.

Michael Johnson gravatar image Michael Johnson  ( 2017-01-11 06:22:39 -0500 )edit

I played about with this and I found that if you change the test.launch file to this:

    <param name="value" value="$(find A)/scripts/"/>

the param is set to /catkin_ws/install/lib/A/ Weird.

Michael Johnson gravatar image Michael Johnson  ( 2017-01-11 09:05:01 -0500 )edit

@Michael Johnson I didn't test it per se, but I am cross compiling, so that on the target machine I do not have a catkin workspace, evertyhing is on /opt/ros/indigo/... And yes, it is weird, convenient, but weird :)

Javier V. Gómez gravatar image Javier V. Gómez  ( 2017-01-11 10:06:41 -0500 )edit

As far as I could understand from rospack code, it builds a list of possible search paths. So the code support multiple locations to look for the files. Take a look:

lucascoelho gravatar image lucascoelho  ( 2019-09-02 09:18:27 -0500 )edit

2 Answers

Sort by » oldest newest most voted

answered 2019-08-08 04:56:41 -0500

ermanas gravatar image

updated 2019-09-02 06:52:44 -0500

As much as I understand, It works like roscd PackageName

So if you can find the folder with roscd, it means that you can find with

$(find PackageName) as well.

edit flag offensive delete link more

answered 2019-09-02 09:13:43 -0500

This looks a lot like another issue I asked about here in Q/A 299232. See also github xacro issue 190 for discussion/explanation.

edit flag offensive delete link more

Question Tools



Asked: 2017-01-11 05:21:28 -0500

Seen: 13,200 times

Last updated: Sep 02 '19