Ask Your Question
0

How to write to a file using roslaunch (Python)

asked 2015-06-01 22:40:25 -0500

duskxii gravatar image

Hi,

I am trying to write to file with a python script using pickle. I am able to do this if I run the script directly using python (file name) but when I run the script using roslaunch it does not write to the file.

How can I make it write to the file while using roslaunch to launch the script?

Thanks!

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-06-02 04:25:56 -0500

Wolf gravatar image

roslaunch by default starts the nodes in the working directory ROS_HOME, which defaults to ~/.ros/, i. e. /home/user_name/.ros. You may specify the working directory to the directory of the exec by setting the cwd attribute of the node tag: http://wiki.ros.org/roslaunch/XML/node

Another workaround is to give your file operations a full path, as @Bill Smart suggested. You can also set the desired path to a ros parameter, read the ros parameter and operate on the thereby retrieved full path if you which to avoid hard coding the path.

edit flag offensive delete link more
1

answered 2015-06-02 00:12:23 -0500

Bill Smart gravatar image

When you run it with roslaunch, it's running in a different environment and (probably) trying to write the file somewhere else in the file system (and probably somewhere you don't have permissions). In Python, try opening the file with it's full pathname (probably starting with /home) and see if that works. If it does, then that's your problem.

edit flag offensive delete link more

Comments

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: 2015-06-01 22:40:25 -0500

Seen: 970 times

Last updated: Jun 02 '15