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

Python: Getting a package's absolute path

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

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
4

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

ct2034 gravatar image

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

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 image Jägermeister  ( 2019-08-07 05:11:51 -0600 )edit

Question Tools

1 follower

Stats

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

Seen: 1,767 times

Last updated: Aug 07 '19