From 9a3bcb6e39eb03a502319a20be706deb6ebb6fed Mon Sep 17 00:00:00 2001 From: Luke Sy Date: Wed, 19 Nov 2025 06:37:27 +1100 Subject: [PATCH 1/2] docs: add XML/YAML launch equivalents and update URDF tutorials Add XML and YAML versions of Python launch files in URDF tutorials. Update documentation to show all three formats using tabs and improve wording to reduce file extension repetition. Signed-off-by: Luke Sy --- ...ng-URDF-with-Robot-State-Publisher-cpp.rst | 22 +++++-- ...ing-URDF-with-Robot-State-Publisher-py.rst | 22 +++++-- .../Using-Xacro-to-Clean-Up-a-URDF-File.rst | 66 +++++++++++++++---- .../Intermediate/URDF/launch/demo_launch.xml | 13 ++++ .../Intermediate/URDF/launch/demo_launch.yaml | 27 ++++++++ .../Intermediate/URDF/launch/launch.xml | 13 ++++ .../Intermediate/URDF/launch/launch.yaml | 27 ++++++++ .../URDF/launch/urdf_display_launch.xml | 8 +++ .../URDF/launch/urdf_display_launch.yaml | 11 ++++ 9 files changed, 187 insertions(+), 22 deletions(-) create mode 100644 source/Tutorials/Intermediate/URDF/launch/demo_launch.xml create mode 100644 source/Tutorials/Intermediate/URDF/launch/demo_launch.yaml create mode 100644 source/Tutorials/Intermediate/URDF/launch/launch.xml create mode 100644 source/Tutorials/Intermediate/URDF/launch/launch.yaml create mode 100644 source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.xml create mode 100644 source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.yaml diff --git a/source/Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher-cpp.rst b/source/Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher-cpp.rst index fcd88d50079..56afbb59af4 100644 --- a/source/Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher-cpp.rst +++ b/source/Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher-cpp.rst @@ -205,10 +205,24 @@ The code file will also tell ``tf2`` how to place the whole model using the ``t ^^^^^^^^^^^^^^^^^^^^^^ Create a new ``urdf_tutorial_cpp/launch`` folder. -Open your editor and paste the following code, saving it as ``urdf_tutorial_cpp/launch/launch.py`` +Open your editor and paste the following code, saving it as ``urdf_tutorial_cpp/launch/launch`` with the extension ``.py``, ``.xml``, or ``.yaml`` -.. literalinclude:: launch/launch.py - :language: python +.. tabs:: + + .. group-tab:: Python + + .. literalinclude:: launch/launch.py + :language: python + + .. group-tab:: XML + + .. literalinclude:: launch/launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/launch.yaml + :language: yaml 5 Edit the CMakeLists.txt file @@ -298,7 +312,7 @@ Source the setup files: 7 View the results ^^^^^^^^^^^^^^^^^^ -To launch your new package run the following command: +To launch your new package run the following command (using ``launch`` with extension ``.py``, ``.xml``, or ``.yaml``): .. code-block:: console diff --git a/source/Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher-py.rst b/source/Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher-py.rst index 9860710ef63..9ed417e6650 100644 --- a/source/Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher-py.rst +++ b/source/Tutorials/Intermediate/URDF/Using-URDF-with-Robot-State-Publisher-py.rst @@ -203,10 +203,24 @@ Fire up your favorite editor and paste the following code into ``second_ros2_ws/ ^^^^^^^^^^^^^^^^^^^^^^ Create a new ``second_ros2_ws/src/urdf_tutorial_r2d2/launch`` folder. -Open your editor and paste the following code, saving it as ``second_ros2_ws/src/urdf_tutorial_r2d2/launch/demo_launch.py`` +Open your editor and paste the following code, saving it as ``second_ros2_ws/src/urdf_tutorial_r2d2/launch/demo_launch`` with the extension ``.py``, ``.xml``, or ``.yaml`` -.. literalinclude:: launch/demo_launch.py - :language: python +.. tabs:: + + .. group-tab:: Python + + .. literalinclude:: launch/demo_launch.py + :language: python + + .. group-tab:: XML + + .. literalinclude:: launch/demo_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/demo_launch.yaml + :language: yaml 5 Edit the setup.py file @@ -278,7 +292,7 @@ Source the setup files: 7 View the results ^^^^^^^^^^^^^^^^^^ -Launch the package +Launch the package (using ``demo_launch`` with extension ``.py``, ``.xml``, or ``.yaml``) .. code-block:: console diff --git a/source/Tutorials/Intermediate/URDF/Using-Xacro-to-Clean-Up-a-URDF-File.rst b/source/Tutorials/Intermediate/URDF/Using-Xacro-to-Clean-Up-a-URDF-File.rst index 8d22b025085..f4f0182b0ea 100644 --- a/source/Tutorials/Intermediate/URDF/Using-Xacro-to-Clean-Up-a-URDF-File.rst +++ b/source/Tutorials/Intermediate/URDF/Using-Xacro-to-Clean-Up-a-URDF-File.rst @@ -43,23 +43,61 @@ However, it does take time to generate, so be aware that your launch file might To run xacro within your launch file, you need to put the ``Command`` substitution as a parameter to the ``robot_state_publisher``. -.. code-block:: python - - path_to_urdf = get_package_share_path('turtlebot3_description') / 'urdf' / 'turtlebot3_burger.urdf' - robot_state_publisher_node = launch_ros.actions.Node( - package='robot_state_publisher', - executable='robot_state_publisher', - parameters=[{ - 'robot_description': ParameterValue( - Command(['xacro ', str(path_to_urdf)]), value_type=str - ) - }] - ) +.. tabs:: + + .. group-tab:: Python + + .. code-block:: python + + path_to_urdf = get_package_share_path('turtlebot3_description') / 'urdf' / 'turtlebot3_burger.urdf' + robot_state_publisher_node = launch_ros.actions.Node( + package='robot_state_publisher', + executable='robot_state_publisher', + parameters=[{ + 'robot_description': ParameterValue( + Command(['xacro ', str(path_to_urdf)]), value_type=str + ) + }] + ) + + .. group-tab:: XML + + .. code-block:: xml + + + + + + .. group-tab:: YAML + + .. code-block:: yaml + + - node: + pkg: "robot_state_publisher" + exec: "robot_state_publisher" + name: "robot_state_publisher" + param: + - name: "robot_description" + value: "$(command 'xacro $(find-pkg-share turtlebot3_description)/urdf/turtlebot3_burger.urdf')" An easier way to load the robot model is to use the `urdf_launch `_ package to automatically load the xacro/urdf. -.. literalinclude:: launch/urdf_display_launch.py - :language: python +.. tabs:: + + .. group-tab:: Python + + .. literalinclude:: launch/urdf_display_launch.py + :language: python + + .. group-tab:: XML + + .. literalinclude:: launch/urdf_display_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/urdf_display_launch.yaml + :language: yaml At the top of the URDF file, you must specify a namespace in order for the file to parse properly. For example, these are the first two lines of a valid xacro file: diff --git a/source/Tutorials/Intermediate/URDF/launch/demo_launch.xml b/source/Tutorials/Intermediate/URDF/launch/demo_launch.xml new file mode 100644 index 00000000000..5cf87dc9556 --- /dev/null +++ b/source/Tutorials/Intermediate/URDF/launch/demo_launch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/source/Tutorials/Intermediate/URDF/launch/demo_launch.yaml b/source/Tutorials/Intermediate/URDF/launch/demo_launch.yaml new file mode 100644 index 00000000000..809c07e7398 --- /dev/null +++ b/source/Tutorials/Intermediate/URDF/launch/demo_launch.yaml @@ -0,0 +1,27 @@ +%YAML 1.2 +--- +launch: + # 'use_sim_time' is used to have ros2 use /clock topic for the time source + - arg: + name: "use_sim_time" + default: "false" + description: "Use simulation (Gazebo) clock if true" + + - node: + pkg: "robot_state_publisher" + exec: "robot_state_publisher" + name: "robot_state_publisher" + output: "screen" + args: "$(file-content $(find-pkg-share urdf_tutorial_r2d2)/r2d2.urdf.xml)" + param: + - name: "use_sim_time" + value: "$(var use_sim_time)" + - name: "robot_description" + value: "$(file-content $(find-pkg-share urdf_tutorial_r2d2)/r2d2.urdf.xml)" + + - node: + pkg: "urdf_tutorial_r2d2" + exec: "state_publisher" + name: "state_publisher" + output: "screen" + diff --git a/source/Tutorials/Intermediate/URDF/launch/launch.xml b/source/Tutorials/Intermediate/URDF/launch/launch.xml new file mode 100644 index 00000000000..13ad57ca762 --- /dev/null +++ b/source/Tutorials/Intermediate/URDF/launch/launch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/source/Tutorials/Intermediate/URDF/launch/launch.yaml b/source/Tutorials/Intermediate/URDF/launch/launch.yaml new file mode 100644 index 00000000000..1f275ae760f --- /dev/null +++ b/source/Tutorials/Intermediate/URDF/launch/launch.yaml @@ -0,0 +1,27 @@ +%YAML 1.2 +--- +launch: + # 'use_sim_time' is used to have ros2 use /clock topic for the time source + - arg: + name: "use_sim_time" + default: "false" + description: "Use simulation (Gazebo) clock if true" + + - node: + pkg: "robot_state_publisher" + exec: "robot_state_publisher" + name: "robot_state_publisher" + output: "screen" + args: "$(file-content $(find-pkg-share urdf_tutorial_cpp)/urdf/r2d2.urdf.xml)" + param: + - name: "use_sim_time" + value: "$(var use_sim_time)" + - name: "robot_description" + value: "$(file-content $(find-pkg-share urdf_tutorial_cpp)/urdf/r2d2.urdf.xml)" + + - node: + pkg: "urdf_tutorial_cpp" + exec: "urdf_tutorial_cpp" + name: "urdf_tutorial_cpp" + output: "screen" + diff --git a/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.xml b/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.xml new file mode 100644 index 00000000000..ba044566069 --- /dev/null +++ b/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.yaml b/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.yaml new file mode 100644 index 00000000000..4b520b2bec6 --- /dev/null +++ b/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.yaml @@ -0,0 +1,11 @@ +%YAML 1.2 +--- +launch: + - include: + file: "$(find-pkg-share urdf_launch)/launch/display.launch.py" + let: + - name: "urdf_package" + value: "turtlebot3_description" + - name: "urdf_package_path" + value: "urdf/turtlebot3_burger.urdf" + From 75fce397f824648b4e87ed12e448b5ba03f72ab9 Mon Sep 17 00:00:00 2001 From: Luke Sy Date: Fri, 21 Nov 2025 03:50:53 +1100 Subject: [PATCH 2/2] URDF tutorial launch file include tag used arg instead of let Signed-off-by: Luke Sy --- .../Intermediate/URDF/launch/urdf_display_launch.xml | 4 ++-- .../Intermediate/URDF/launch/urdf_display_launch.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.xml b/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.xml index ba044566069..09cd662afa5 100644 --- a/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.xml +++ b/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.xml @@ -1,8 +1,8 @@ - - + + diff --git a/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.yaml b/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.yaml index 4b520b2bec6..d2c8e12e0bd 100644 --- a/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.yaml +++ b/source/Tutorials/Intermediate/URDF/launch/urdf_display_launch.yaml @@ -3,7 +3,7 @@ launch: - include: file: "$(find-pkg-share urdf_launch)/launch/display.launch.py" - let: + arg: - name: "urdf_package" value: "turtlebot3_description" - name: "urdf_package_path"