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

Hello there,

roslaunch listen listen.launch mode:=dropping

You are passing mode in the command line arguments, so you have to first catch this value into your launch file. You can do so by <arg name="mode" default="_default_text_">.

2 step you have to send this argument to python file.

<node name="node_name" pkg="node_pkg_name" type="filename.py" output="screen" clear_params="true">
       <param name="mode" value="$(arg mode)" /> 
</node>

If you are passing an argument to CLI and you want that same argument into your launch file you can access it via value="$(arg mode)"

You can access in python by using this code snippet.

#!/usr/bin/env python
import rospy
device = rospy.get_param('/node_name/mode') # node_name/argsname

So, full launch file structure should be like this:

<launch>
<arg name="mode" default="_default_text_">
<node name="node_name" pkg="node_pkg_name" type="filename.py" output="screen" clear_params="true">
                <param name="mode" value="$(arg mode)" /> 
         </node>
</launch>