Ask Your Question
2

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 launch.py file:

from ament_index_python.packages import get_package_share_directory

get_package_share_directory("package_a")

versus

from launch_ros.substitutions import FindPackageShare

FindPackageShare("package_a")

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
0

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 https://github.com/ros2/launch_ros/pu...)

edit flag offensive delete link more

Comments

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

2 followers

Stats

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

Seen: 610 times

Last updated: Jun 11 '20