ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

ROS2 launch FindPackageShare vs get_package_share_directory

asked 2020-06-11 01:40:37 -0500

Mbuijs gravatar image

updated 2020-06-11 01:41:22 -0500

I've noticed 2 possible ways to get the share directory of a package from within a file:

from ament_index_python.packages import get_package_share_directory



from launch_ros.substitutions import FindPackageShare


The former returns a string directly, the latter will be evaluated to a string when passed into a LaunchDescription somewhere.

Which one is recommended?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-06-11 22:57:47 -0500

fergs gravatar image

Interesting - I suppose the launch_ros.substitutions is the preferred since somebody spent the time to implement it - and under the hood it actually just calls ament_index_python.packages.get_package_shared_directory (see

edit flag offensive delete link more


That's what I found already as well, but no recommendation to use one or the other...

Mbuijs gravatar image Mbuijs  ( 2020-06-12 04:04:42 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2020-06-11 01:40:37 -0500

Seen: 1,738 times

Last updated: Jun 11 '20