Ask Your Question
0

roslaunch env tag not functioning correctly

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

errolflynn gravatar image

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

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 flag offensive 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?

mgruhler gravatar imagemgruhler ( 2016-05-09 01:17:14 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

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

mgruhler gravatar image

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

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

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

Stats

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

Seen: 328 times

Last updated: May 09 '16