Ask Your Question
0

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
2

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: http://docs.ros.org/independent/api/r...

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

Comments

Worked like a charm, thank you.

Jägermeister gravatar imageJägermeister ( 2019-08-07 05:11:51 -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

1 follower

Stats

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

Seen: 21 times

Last updated: Aug 07