# roslaunch env tag not functioning correctly

I'm attempting to establish an environment variable from a roslaunch .launch file that I may use in my C++ ROS node. My roslaunch file is below:

<launch>
<!--
<include file="$(find px4)/launch/mavros_posix_sitl.launch"> </include> --> <include file="$(find terp)/config/pilot.xml"/>

<env
name="MISSION_FILE_PATH"
value="$(find terp)/mission/mission_schedule.txt"/> </launch>  Edit: The rest of it I intend to use "MISSION_FILE_PATH" in my project. I call it with the following call: ifstream mission_file(getenv("MISSION_FILE_PATH"));  However, this call is unable to open the file specified by "MISSION_FILE_PATH" in my .launch file. Does the environment created in the .launch file stick around while the program is running? If so, what is incorrect about my call to getenv()? If not, are there any easy workarounds other than hard-coding a file path? edit retag close merge delete ## Comments 1 This is not a question, this is just stating what you want to do... What is the expected behaviour, what the observed one? Which OS are you using, which ROS distro? Did you check the wiki page? ( 2016-05-09 01:17:14 -0500 )edit ## 1 Answer Sort by » oldest newest most voted The wiki page on <env> states: When it is used inside of a <launch> tag, the <env> tag only applies to nodes declared after. So I guess you need to declare it before your <include ..> statement. However, I would actually use a ROS parameter. This can actually also be set from an environment variable using the $(env ...) or \$(optenv ...) flags. See also the wiki on this.

If the above does not help: you say

However, this call is unable to open the file specified by "MISSION_FILE_PATH" in my .launch file

Could this be a file permission issue? The file needs to be readable from the node...

more