# Should I write a bash script in my package for setting Environment Variable $ROS_HOME? I have a node that takes images with OpenCV, saves files under the /home/user0/Images/. When I run this node via rosrun, it saves succesfully. And also tried with roslaunch:  <node name="my_node" pkg="my_pkg" type="my_node" output="screen" cwd="ROS_HOME"/>  But it needs running ~$ export ROS_HOME=$HOME  command before calling that launch file. Should I write a bash script in my package for setting $ROS_HOME and put that script into my launch file? Or; setting $ROS_HOME in my .bashrc file option is good? edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted If you change ROS_HOME you will change where things like log files produced by roslaunch go (see http://wiki.ros.org/ROS/EnvironmentVa... ). Use a parameter to specify a location for files written by a node. There is a good tutorial available here. This will let you pass the destination for directories to the node using the parameter server. The parameter can be given a good default value, and you can set a customised value in the launch file using the param tag. You can go further and add an argument to the launch file using the arg tag, which you can then pass to the parameter for the node in the launch file (the example on that page shows you how). That will let you set the value of the parameter on the command line when you call roslaunch. So in your node, you would have something like this: std::string dest_dir; nh.param("~destination_dir", dest_dir, "images");  And in your launch file, something like this: <arg name="image_output_dir" value="other_images"/> <node name="my_node" pkg="my_pkg" type="my_node" output="screen"> <param name="destination_dir" value="$(arg image_output_dir)"/>
</node>


And if you want to get really fancy, you can use dynamic_reconfigure to let you change the destination directory for images at runtime, without restarting the node.

more