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

roslaunch env tag not functioning correctly

asked 2016-05-08 21:54:35 -0600

errolflynn gravatar image

updated 2016-05-09 09:00:52 -0600

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:

    <include file="$(find px4)/launch/mavros_posix_sitl.launch">

<include file="$(find terp)/config/pilot.xml"/>

    value="$(find terp)/mission/mission_schedule.txt"/>


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 flag offensive close merge delete



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?

mgruhler gravatar image mgruhler  ( 2016-05-09 01:17:14 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-05-09 10:47:56 -0600

mgruhler gravatar image

updated 2016-05-09 10:49:44 -0600

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...

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-05-08 21:54:35 -0600

Seen: 970 times

Last updated: May 09 '16