ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

How to write to a text file in python in a ROS node?

asked 2016-06-01 10:20:23 -0500

Ros User gravatar image

updated 2022-03-26 11:25:14 -0500

lucasw gravatar image

I need to record a topic message called "message" only when a "message sent" button is pressed. I have made a separate node for GUI that has "message sent" button. I also wrote the "message" topic to a text file when "message sent" button was activated. The program works fine when this node is run separately, it also writes the message to the designated text file. But when I run this node along with other nodes by including it in a launch file, the text file does not seem to be created. Is there any specific reason for this to happen? How can this problem be solved?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-06-01 10:43:35 -0500

Thomas D gravatar image

When using roslaunch the nodes are run from $ROS_HOME which is almost always ~/.ros. So, if you are writing x.txt you should be able to find it at ~/.ros/x.txt.

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

1 follower


Asked: 2016-06-01 10:20:23 -0500

Seen: 1,892 times

Last updated: Jun 01 '16