What is the XML syntax for args in launch files?

@staff In the below launch file to spawn URDF files into gazebo, what is the syntax for args? i understand that using args we are passing arguments into the node.

<?xml version="1.0" encoding="UTF-8"?>


    <arg name="x" default="0.0" />
    <arg name="y" default="0.0" />
    <arg name="z" default="0.0" />

    <arg name="urdf_robot_file" default="" />
    <arg name="robot_name" default="" />

    <!-- This version was created due to some errors seen in the V1 that crashed Gazebo or went too slow in spawn -->
    <!-- Load the URDF into the ROS Parameter Server -->
    <param name="robot_description" command="cat $(arg urdf_robot_file)" />

    <!-- Run a Python script to the send a service call to gazebo_ros to spawn a URDF robot -->
    <node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
    args="-urdf -x $(arg x) -y $(arg y) -z $(arg z)  -model $(arg robot_name) -param robot_description"/>

Question1: is it safe to say that the XML syntax is: -var value_of_var?

args="-urdf -x $(arg x) -y $(arg y) -z $(arg z) .......-var1 var1_value -var2 var2_value../>

Question 2: What is the connection between args and command-line terminal commands?

Feedback to @staff
It would have been great if the XML for launch file, which include the arg, args, rosparam etc were taught in the ROS Basics in 5 days course itself.

Hi @Joseph1001,

Question 1
The syntax applied in the args attribute depends on what the executable is expecting to receive. The value inside args will be added to the CLI, taking your example:

rosrun urdf_spawner gazebo_ros spawn_model -urdf -x $(arg x) -y $(arg y) -z $(arg z) -model $(arg robot_name) -param robot_description

I think this also answers the Question 2. Check some references I added below:



Thanks @marco.nc.arruda. The link you shared also helped.

1 Like

please update this in the course material since how args work is not mentioned in the ROS Basics course material and would be usefull for new users as well.

1 Like

Thank you for the suggestion @Joseph1001 , very good one!

We will check the best way to introduce this subject and add to the material.


Thanks for considering this. I also want to add that entire XML syntax for launch files is missing from teh course content,which include env, rosparam,param, group,test, arg, args etc. I learned it form ros wiki, but would be great if this was part of the syllabus, since this is the basics and used in every single program we run.

1 Like