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

How to write to a file using roslaunch (Python)

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

duskxii gravatar image


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?


edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

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:

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

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


Question Tools

1 follower


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

Seen: 1,299 times

Last updated: Jun 02 '15