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

Python: Getting a package's absolute path

asked 2019-08-07 04:02:53 -0500

Jägermeister gravatar image

I'm trying to navigate in the code having paths that are not hardcoded. I would like to know if there is a ROS/Python way of referring to a package's path. Something like navigateToPackage("package_name") is what I am after. Is this a supported feature? Does it exist?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-08-07 04:41:09 -0500

ct2034 gravatar image

updated 2019-08-07 04:45:45 -0500

You can get the path of packages with the rospkgpython library:

import rospkg
rp = rospkg.RosPack()
package_path = rp.get_path('package_name')
edit flag offensive delete link more


Worked like a charm, thank you.

Jägermeister gravatar image Jägermeister  ( 2019-08-07 05:11:51 -0500 )edit

Question Tools

1 follower


Asked: 2019-08-07 04:02:53 -0500

Seen: 1,546 times

Last updated: Aug 07 '19