0
$\begingroup$

Rosanswers logo

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!


Originally posted by duskxii on ROS Answers with karma: 3 on 2015-06-01

Post score: 0

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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.


Originally posted by Wolf with karma: 7555 on 2015-06-02

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by Bill Smart with karma: 1263 on 2015-06-02

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by gvdhoorn on 2015-06-02:
Related: roslaunch prevents node from creating/writing to file.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.