Ask Your Question
0

Loading a file from a python ros node

asked 2011-06-17 09:59:02 -0500

andrew-unit gravatar image

Hello, I'm writing a python node and I need to load an XML file. I want to try to keep the XML file in my package so that way it travels with the ROS package. However, since I typically launch nodes from my home directory, and the node is in my ROS development area, it seems I have to specify a full path in order to load the XML file. Is there a way to ask python to give me the relative path to the current package?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2011-06-17 10:23:32 -0500

Mac gravatar image

updated 2011-06-17 10:54:11 -0500

tfoote gravatar image

The Best Way To Do This (tm) is probably to use a rosparam to set the path to the file, and then load it that way.

If you really just want the path to the file, a proper call to roslib.rospack modulefind the directory for you.

edit flag offensive delete link more
1

answered 2011-06-17 10:51:40 -0500

Straszheim gravatar image

you also could use roslaunch and the $(find) mechanism:

http://www.ros.org/wiki/roslaunch/XML

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-06-17 09:59:02 -0500

Seen: 1,666 times

Last updated: Jun 17 '11