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

ROS2 launch FindPackageShare vs get_package_share_directory

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

Mbuijs gravatar image

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

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
3

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

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 -0600 )edit

Question Tools

2 followers

Stats

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

Seen: 4,221 times

Last updated: Jun 11 '20