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

Revision history [back]

click to hide/show revision 1
initial version

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/Parameter%20Server.

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. Then you simply have to read in the parameters using the rospy.get_param('ARG#') as seen in the link.

Hope this helps!

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/Parameter%20Server.

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!