<arg> tag

New in C Turtle


The <arg> tag allows you to create more re-usable and configurable launch files by specifying values that are passed via the command-line, passing in via an <include>, or declared for higher-level files. Args are not global. An arg declaration is specific to a single launch file, much like a local parameter in a method. You must explicitly pass arg values to an included file, much like you would in a method call.

Usecase pattern

<arg> can be used in one of three ways:

  • <arg name="foo" />

    • Declares the existence of foo. foo must be passed in either as a command-line argument (if top-level) or via <include> passing (if included).

    <arg name="foo" default="1" />

    • Declares foo with a default value. foo can be overriden by command-line argument (if top-level) or via <include> passing (if included).

    <arg name="foo" value="bar" />

    • Declares foo with constant value. The value for foo cannot be overridden. This usage enables internal parameterization of a launch file without exposing that parameterization at higher levels.


  • name="arg_name"

    • Name of argument.

    default="default value" (optional)

    • Default value of argument. Cannot be combined with value attribute.

    value="value" (optional)

    • Argument value. Cannot be combined with default attribute.

    doc="description for this arg" (optional) New in Indigo

    • Description of the argument. You could get this through --ros-args argument to the roslaunch command.


Passing an argument to an included file

  • my_file.launch:

    <include file="included.launch">
      <!-- all vars that included.launch requires must be set -->
      <arg name="hoge" value="fuga" />


      <!-- declare arg to be passed in -->
      <arg name="hoge" /> 
      <!-- read value of arg -->
      <param name="param" value="$(arg hoge)"/>

Passing an argument via the command-line

roslaunch uses the same syntax as ROS remapping arguments to specify arg values.

  • $ roslaunch my_file.launch hoge:=my_value      (.launch file is available at the current dir)
    $ roslaunch %YOUR_ROS_PKG% my_file.launch hoge:=my_value

Wiki: roslaunch/XML/arg (last edited 2021-04-24 13:25:38 by AvneeshMishra)