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

pass enviornment variable using launch file

asked 2016-08-03 10:23:02 -0500

Bhargav gravatar image


I am passing the arguments using sys module as described in this link. I have my node running but now I want to pass this same argument using a launch file. Is it possible to it?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-08-04 15:28:44 -0500

emielke gravatar image

updated 2016-08-04 15:30:03 -0500

I'm not entirely sure what your question is, but you can use parameters in the launch file then read them into the python script. There's a whole page on it here: .

It sounds like you have two arguments you want to pass into the python script, which are then used in a function, correct?

You can create a launch file like this

  <arg name="arg1" doc="Argument 1" default="value1" />
  <arg name="arg2" doc="Argument 2" default="value2" />
  <node name="node_name" pkg="pkg" type="type">
    <param name="ARG1" value="$(arg arg1)" />
    <param name="ARG2" value="$(arg arg2)" />

You can then easily run the launch file and include the two arguments on the command line, or they have default values coded into the launch file that it can use.

To run them on the command line you would do roslaunch pkg file.launch arg1:=value1 arg2:=value2

Then you simply have to read in the parameters using the rospy.get_param('ARG#') as seen in the link.

Hope this helps!

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-08-03 10:23:02 -0500

Seen: 666 times

Last updated: Aug 04 '16