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

pass enviornment variable using launch file

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

Bhargav gravatar image

Hi!

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? http://answers.ros.org/question/64552...

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

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: http://wiki.ros.org/rospy/Overview/Pa... .

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

<launch>
  <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)" />
  </node>
</launch>

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

Question Tools

1 follower

Stats

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

Seen: 747 times

Last updated: Aug 04 '16