From e13ec1d989be0e380d0064ad569f132230948a60 Mon Sep 17 00:00:00 2001 From: Luke Sy Date: Wed, 19 Nov 2025 09:24:50 +1100 Subject: [PATCH 1/3] Add XML/YAML launch file equivalents to Tf2 tutorials - Add XML and YAML equivalents for all Python launch files - Update tutorial RST files with tabbed multi-format code examples - Use .xml as default in console commands with inline format comments Signed-off-by: Luke Sy --- .../Intermediate/Tf2/Adding-A-Frame-Cpp.rst | 54 +++++++++++++++++-- .../Intermediate/Tf2/Adding-A-Frame-Py.rst | 54 +++++++++++++++++-- .../Tf2/Debugging-Tf2-Problems.rst | 22 ++++++-- .../Intermediate/Tf2/Introduction-To-Tf2.rst | 2 +- .../Tf2/Learning-About-Tf2-And-Time-Cpp.rst | 4 +- .../Tf2/Time-Travel-With-Tf2-Cpp.rst | 4 +- ...d-Datatypes-With-Tf2-Ros-MessageFilter.rst | 20 +++++-- .../Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst | 50 ++++++++++++++++- .../Tf2/Writing-A-Tf2-Broadcaster-Py.rst | 50 ++++++++++++++++- .../Tf2/Writing-A-Tf2-Listener-Cpp.rst | 18 ++++++- .../Tf2/Writing-A-Tf2-Listener-Py.rst | 18 ++++++- .../Tf2/launch/listener_cpp_launch.xml | 15 ++++++ .../Tf2/launch/listener_cpp_launch.yaml | 33 ++++++++++++ .../Tf2/launch/listener_py_launch.xml | 15 ++++++ .../Tf2/launch/listener_py_launch.yaml | 33 ++++++++++++ .../Tf2/launch/py_turtle_tf2_demo_launch.xml | 8 +++ .../Tf2/launch/py_turtle_tf2_demo_launch.yaml | 15 ++++++ ...y_turtle_tf2_dynamic_frame_demo_launch.xml | 8 +++ ..._turtle_tf2_dynamic_frame_demo_launch.yaml | 13 +++++ .../py_turtle_tf2_fixed_frame_demo_launch.xml | 6 +++ ...py_turtle_tf2_fixed_frame_demo_launch.yaml | 10 ++++ .../launch/start_tf2_debug_demo_launch.xml | 15 ++++++ .../launch/start_tf2_debug_demo_launch.yaml | 34 ++++++++++++ .../Tf2/launch/turtle_tf2_demo_launch.xml | 8 +++ .../Tf2/launch/turtle_tf2_demo_launch.yaml | 15 ++++++ .../turtle_tf2_dynamic_frame_demo_launch.xml | 8 +++ .../turtle_tf2_dynamic_frame_demo_launch.yaml | 13 +++++ .../turtle_tf2_fixed_frame_demo_launch.xml | 6 +++ .../turtle_tf2_fixed_frame_demo_launch.yaml | 10 ++++ .../turtle_tf2_sensor_message_launch.xml | 13 +++++ .../turtle_tf2_sensor_message_launch.yaml | 31 +++++++++++ 31 files changed, 575 insertions(+), 30 deletions(-) create mode 100644 source/Tutorials/Intermediate/Tf2/launch/listener_cpp_launch.xml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/listener_cpp_launch.yaml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/listener_py_launch.xml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/listener_py_launch.yaml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_demo_launch.xml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_demo_launch.yaml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_dynamic_frame_demo_launch.xml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_dynamic_frame_demo_launch.yaml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_fixed_frame_demo_launch.xml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_fixed_frame_demo_launch.yaml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/start_tf2_debug_demo_launch.xml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/start_tf2_debug_demo_launch.yaml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_demo_launch.xml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_demo_launch.yaml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_dynamic_frame_demo_launch.xml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_dynamic_frame_demo_launch.yaml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_fixed_frame_demo_launch.xml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_fixed_frame_demo_launch.yaml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_sensor_message_launch.xml create mode 100644 source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_sensor_message_launch.yaml diff --git a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst index 1b3c208e07f..32bce05c6ae 100644 --- a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst @@ -182,19 +182,49 @@ Finally, add the ``install(TARGETS…)`` section so ``ros2 run`` can find your e ~~~~~~~~~~~~~~~~~~~~~~~~~ Now let's create a launch file for this example. -With your text editor, create a new file called ``turtle_tf2_fixed_frame_demo_launch.py`` in the ``src/learning_tf2_cpp/launch`` directory, and add the following lines: +With your text editor, create a new file called ``turtle_tf2_fixed_frame_demo_launch`` with extension ``.py``, ``.xml``, or ``.yaml`` in the ``src/learning_tf2_cpp/launch`` directory, and add the following lines: + +.. tabs:: + + .. group-tab:: Python .. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py :language: python + .. group-tab:: XML + + .. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.yaml + :language: yaml + This launch file imports the required packages and then creates a ``demo_nodes`` variable that will store nodes that we created in the previous tutorial's launch file. The last part of the code will add our fixed ``carrot1`` frame to the turtlesim world using our ``fixed_frame_tf2_broadcaster`` node. +.. tabs:: + + .. group-tab:: Python + .. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py :language: python :lines: 14-18 + .. group-tab:: XML + + .. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.xml + :language: xml + :lines: 3-4 + + .. group-tab:: YAML + + .. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.yaml + :language: yaml + :lines: 5-6 + 1.4 Build ~~~~~~~~~ @@ -275,7 +305,7 @@ Now you can start the turtle broadcaster demo: .. code-block:: console - $ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo_launch.py + $ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo_launch.xml # .py or .yaml are also acceptable You should notice that the new ``carrot1`` frame appeared in the transformation tree. @@ -290,7 +320,7 @@ One way is to pass the ``target_frame`` argument to the launch file directly fro .. code-block:: console - $ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo_launch.py target_frame:=carrot1 + $ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo_launch.xml target_frame:=carrot1 # .py or .yaml are also acceptable The second way is to update the launch file. To do so, open the ``turtle_tf2_fixed_frame_demo_launch.py`` file, and add the ``'target_frame': 'carrot1'`` parameter via ``launch_arguments`` argument. @@ -442,11 +472,25 @@ Finally, add the ``install(TARGETS…)`` section so ``ros2 run`` can find your e 2.3 Write the launch file ~~~~~~~~~~~~~~~~~~~~~~~~~ -To test this code, create a new launch file ``turtle_tf2_dynamic_frame_demo_launch.py`` in the ``src/learning_tf2_cpp/launch`` directory and paste the following code: +To test this code, create a new launch file ``turtle_tf2_dynamic_frame_demo_launch`` with extension ``.py``, ``.xml``, or ``.yaml`` in the ``src/learning_tf2_cpp/launch`` directory and paste the following code: + +.. tabs:: + + .. group-tab:: Python .. literalinclude:: launch/turtle_tf2_dynamic_frame_demo_launch.py :language: python + .. group-tab:: XML + + .. literalinclude:: launch/turtle_tf2_dynamic_frame_demo_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/turtle_tf2_dynamic_frame_demo_launch.yaml + :language: yaml + 2.4 Build ~~~~~~~~~ @@ -528,7 +572,7 @@ Now you can start the dynamic frame demo: .. code-block:: console - $ ros2 launch learning_tf2_cpp turtle_tf2_dynamic_frame_demo_launch.py + $ ros2 launch learning_tf2_cpp turtle_tf2_dynamic_frame_demo_launch.xml # .py or .yaml are also acceptable You should see that the second turtle is following the carrot's position that is constantly changing. diff --git a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst index 6500386b432..b7fa495a72c 100644 --- a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst +++ b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst @@ -159,20 +159,50 @@ Add the following line between the ``'console_scripts':`` brackets: ~~~~~~~~~~~~~~~~~~~~~~~~~ Now let's create a launch file for this example. -With your text editor, create a new file called ``turtle_tf2_fixed_frame_demo_launch.py`` in the ``src/learning_tf2_py/launch`` directory, and add the following lines: +With your text editor, create a new file called ``turtle_tf2_fixed_frame_demo_launch`` with extension ``.py``, ``.xml``, or ``.yaml`` in the ``src/learning_tf2_py/launch`` directory, and add the following lines: + +.. tabs:: + + .. group-tab:: Python .. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py :name: turtle_tf2_fixed_frame_demo_launch.py :language: python + .. group-tab:: XML + + .. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.yaml + :language: yaml + This launch file imports the required packages and then creates a ``demo_nodes`` variable that will store nodes that we created in the previous tutorial's launch file. The last part of the code will add our fixed ``carrot1`` frame to the turtlesim world using our ``fixed_frame_tf2_broadcaster`` node. +.. tabs:: + + .. group-tab:: Python + .. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py :language: python :lines: 14-18 + .. group-tab:: XML + + .. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.xml + :language: xml + :lines: 3-4 + + .. group-tab:: YAML + + .. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.yaml + :language: yaml + :lines: 5-6 + 1.4 Build ~~~~~~~~~ @@ -253,7 +283,7 @@ Now you can start the turtle broadcaster demo: .. code-block:: console - $ ros2 launch learning_tf2_py turtle_tf2_fixed_frame_demo_launch.py + $ ros2 launch learning_tf2_py turtle_tf2_fixed_frame_demo_launch.xml # .py or .yaml are also acceptable You should notice that the new ``carrot1`` frame appeared in the transformation tree. @@ -268,7 +298,7 @@ One way is to pass the ``target_frame`` argument to the launch file directly fro .. code-block:: console - $ ros2 launch learning_tf2_py turtle_tf2_fixed_frame_demo_launch.py target_frame:=carrot1 + $ ros2 launch learning_tf2_py turtle_tf2_fixed_frame_demo_launch.xml target_frame:=carrot1 # .py or .yaml are also acceptable The second way is to update the launch file. To do so, open the ``turtle_tf2_fixed_frame_demo_launch.py`` file, and add the ``'target_frame': 'carrot1'`` parameter via ``launch_arguments`` argument. @@ -398,11 +428,25 @@ Add the following line between the ``'console_scripts':`` brackets: 2.3 Write the launch file ~~~~~~~~~~~~~~~~~~~~~~~~~ -To test this code, create a new launch file ``turtle_tf2_dynamic_frame_demo_launch.py`` in the ``src/learning_tf2_py/launch`` directory and paste the following code: +To test this code, create a new launch file ``turtle_tf2_dynamic_frame_demo_launch`` with extension ``.py``, ``.xml``, or ``.yaml`` in the ``src/learning_tf2_py/launch`` directory and paste the following code: + +.. tabs:: + + .. group-tab:: Python .. literalinclude:: launch/py_turtle_tf2_dynamic_frame_demo_launch.py :name: turtle_tf2_dynamic_frame_demo_launch.py + .. group-tab:: XML + + .. literalinclude:: launch/py_turtle_tf2_dynamic_frame_demo_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/py_turtle_tf2_dynamic_frame_demo_launch.yaml + :language: yaml + 2.4 Build ~~~~~~~~~ @@ -485,7 +529,7 @@ Now you can start the dynamic frame demo: .. code-block:: console - $ ros2 launch learning_tf2_py turtle_tf2_dynamic_frame_demo_launch.py + $ ros2 launch learning_tf2_py turtle_tf2_dynamic_frame_demo_launch.xml # .py or .yaml are also acceptable You should see that the second turtle is following the carrot's position that is constantly changing. diff --git a/source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst b/source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst index 3d249218db8..2cafff2e1f8 100644 --- a/source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst +++ b/source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst @@ -70,18 +70,32 @@ to } catch (const tf2::TransformException & ex) { And save changes to the file. -In order to run this demo, we need to create a launch file ``start_tf2_debug_demo_launch.py`` in the ``launch`` subdirectory of package ``learning_tf2_cpp``: +In order to run this demo, we need to create a launch file ``start_tf2_debug_demo_launch`` with extension ``.py``, ``.xml``, or ``.yaml`` in the ``launch`` subdirectory of package ``learning_tf2_cpp``: + +.. tabs:: + + .. group-tab:: Python .. literalinclude:: launch/start_tf2_debug_demo_launch.py :language: python + .. group-tab:: XML + + .. literalinclude:: launch/start_tf2_debug_demo_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/start_tf2_debug_demo_launch.yaml + :language: yaml + Don't forget to add the ``turtle_tf2_listener_debug`` executable to the ``CMakeLists.txt`` and build the package. Now let's run it to see what happens: .. code-block:: console - $ ros2 launch learning_tf2_cpp start_tf2_debug_demo_launch.py + $ ros2 launch learning_tf2_cpp start_tf2_debug_demo_launch.xml # .py or .yaml are also acceptable You will now see that the turtlesim came up. At the same time, if you run the ``turtle_teleop_key`` in another terminal window, you can use the arrow keys to drive the ``turtle1`` around. @@ -155,7 +169,7 @@ And now stop the running demo, build it, and run it again: .. code-block:: console - $ ros2 launch learning_tf2_cpp start_tf2_debug_demo_launch.py + $ ros2 launch learning_tf2_cpp start_tf2_debug_demo_launch.xml # .py or .yaml are also acceptable [turtle_tf2_listener_debug-4] [INFO] [1630223704.617382464] [listener_debug]: Could not transform turtle2 to turtle1: Lookup would require extrapolation into the future. Requested time 1630223704.617054 but the latest data is at time 1630223704.616726, when looking up @@ -203,7 +217,7 @@ Stop the demo, build and run: .. code-block:: console - $ ros2 launch turtle_tf2 start_tf2_debug_demo_launch.py + $ ros2 launch turtle_tf2 start_tf2_debug_demo_launch.xml # .py or .yaml are also acceptable And you should finally see the turtle move! diff --git a/source/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.rst b/source/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.rst index 542b8a3c103..ac51c36a0c5 100644 --- a/source/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.rst +++ b/source/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.rst @@ -51,7 +51,7 @@ Then run the following command: .. code-block:: console - $ ros2 launch turtle_tf2_py turtle_tf2_demo.launch.py + $ ros2 launch turtle_tf2_py turtle_tf2_demo.launch.xml # .py or .yaml are also acceptable You will see the turtlesim start with two turtles. diff --git a/source/Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.rst index f2ab0f42e66..840a1eddb50 100644 --- a/source/Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.rst @@ -70,7 +70,7 @@ Now build the package and try to run the launch file. .. code-block:: console - $ ros2 launch learning_tf2_cpp turtle_tf2_demo_launch.py + $ ros2 launch learning_tf2_cpp turtle_tf2_demo_launch.xml # .py or .yaml are also acceptable [INFO] [1629873136.345688064] [listener]: Could not transform turtle2 to turtle1: Lookup would require extrapolation into the future. Requested time 1629873136.345539 but the latest data is at time 1629873136.338804, when looking up transform from frame [turtle1] to frame [turtle2] @@ -110,7 +110,7 @@ You can now build the package and run the launch file. .. code-block:: console - $ ros2 launch learning_tf2_cpp turtle_tf2_demo_launch.py + $ ros2 launch learning_tf2_cpp turtle_tf2_demo_launch.xml # .py or .yaml are also acceptable You should notice that ``lookupTransform()`` will actually block until the transform between the two turtles becomes available (this will usually take a few milliseconds). Once the timeout has been reached (fifty milliseconds in this case), an exception will be raised only if the transform is still not available. diff --git a/source/Tutorials/Intermediate/Tf2/Time-Travel-With-Tf2-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Time-Travel-With-Tf2-Cpp.rst index c6696056426..5b6f27112d4 100644 --- a/source/Tutorials/Intermediate/Tf2/Time-Travel-With-Tf2-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Time-Travel-With-Tf2-Cpp.rst @@ -53,7 +53,7 @@ Build the package then let's just give it a try: .. code-block:: console - $ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo_launch.py + $ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo_launch.xml # .py or .yaml are also acceptable .. image:: images/turtlesim_delay1.png @@ -112,7 +112,7 @@ Build the package then let's run the simulation again, this time with the advanc .. code-block:: console - $ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo_launch.py + $ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo_launch.xml # .py or .yaml are also acceptable .. image:: images/turtlesim_delay2.png diff --git a/source/Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.rst b/source/Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.rst index 64e5e0474a9..8137f14d14f 100644 --- a/source/Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.rst +++ b/source/Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.rst @@ -233,11 +233,25 @@ Then we fill up the ``PointStamped`` messages of ``turtle3`` with incoming ``Pos 1.2 Write the launch file ~~~~~~~~~~~~~~~~~~~~~~~~~ -In order to run this demo, we need to create a launch file ``turtle_tf2_sensor_message_launch.py`` in the ``launch`` subdirectory of package ``learning_tf2_py``: +In order to run this demo, we need to create a launch file ``turtle_tf2_sensor_message_launch`` with extension ``.py``, ``.xml``, or ``.yaml`` in the ``launch`` subdirectory of package ``learning_tf2_py``: + +.. tabs:: + + .. group-tab:: Python .. literalinclude:: launch/turtle_tf2_sensor_message_launch.py :language: python + .. group-tab:: XML + + .. literalinclude:: launch/turtle_tf2_sensor_message_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/turtle_tf2_sensor_message_launch.yaml + :language: yaml + 1.3 Add an entry point ~~~~~~~~~~~~~~~~~~~~~~ @@ -669,11 +683,11 @@ Open a new terminal, navigate to the root of your workspace, and source the setu 3 Run ^^^^^ -First we need to run several nodes (including the broadcaster node of PointStamped messages) by launching the launch file ``turtle_tf2_sensor_message_launch.py``: +First we need to run several nodes (including the broadcaster node of PointStamped messages) by launching the launch file ``turtle_tf2_sensor_message_launch``: .. code-block:: console - $ ros2 launch learning_tf2_py turtle_tf2_sensor_message_launch.py + $ ros2 launch learning_tf2_py turtle_tf2_sensor_message_launch.xml # .py or .yaml are also acceptable This will bring up the ``turtlesim`` window with two turtles, where ``turtle3`` is moving along a circle, while ``turtle1`` isn't moving at first. But you can run the ``turtle_teleop_key`` node in another terminal to drive ``turtle1`` to move: diff --git a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst index a988ead3231..bffa20b8563 100644 --- a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst @@ -247,27 +247,73 @@ Finally, add the ``install(TARGETS…)`` section so ``ros2 run`` can find your e Now create a launch file for this demo. Create a ``launch`` folder in the ``src/learning_tf2_cpp`` directory. -With your text editor, create a new file called ``turtle_tf2_demo_launch.py`` in the ``launch`` folder, and add the following lines: +With your text editor, create a new file called ``turtle_tf2_demo_launch`` with extension ``.py``, ``.xml``, or ``.yaml`` in the ``launch`` folder, and add the following lines: + +.. tabs:: + + .. group-tab:: Python .. literalinclude:: launch/turtle_tf2_demo_launch.py :language: python + .. group-tab:: XML + + .. literalinclude:: launch/turtle_tf2_demo_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/turtle_tf2_demo_launch.yaml + :language: yaml + 2.1 Examine the code ~~~~~~~~~~~~~~~~~~~~ First we import required modules from the ``launch`` and ``launch_ros`` packages. It should be noted that ``launch`` is a generic launching framework (not ROS 2 specific) and ``launch_ros`` has ROS 2 specific things, like nodes that we import here. +.. tabs:: + + .. group-tab:: Python + .. literalinclude:: launch/turtle_tf2_demo_launch.py :language: python :lines: 1-2 + .. group-tab:: XML + + .. literalinclude:: launch/turtle_tf2_demo_launch.xml + :language: xml + :lines: 1-2 + + .. group-tab:: YAML + + .. literalinclude:: launch/turtle_tf2_demo_launch.yaml + :language: yaml + :lines: 1-3 + Now we run our nodes that start the turtlesim simulation and broadcast ``turtle1`` state to the tf2 using our ``turtle_tf2_broadcaster`` node. +.. tabs:: + + .. group-tab:: Python + .. literalinclude:: launch/turtle_tf2_demo_launch.py :language: python :lines: 7-19 + .. group-tab:: XML + + .. literalinclude:: launch/turtle_tf2_demo_launch.xml + :language: xml + :lines: 3-6 + + .. group-tab:: YAML + + .. literalinclude:: launch/turtle_tf2_demo_launch.yaml + :language: yaml + :lines: 4-9 + 2.2 Add dependencies ~~~~~~~~~~~~~~~~~~~~ @@ -377,7 +423,7 @@ Now run the launch file that will start the turtlesim simulation node and ``turt .. code-block:: console - $ ros2 launch learning_tf2_cpp turtle_tf2_demo_launch.py + $ ros2 launch learning_tf2_cpp turtle_tf2_demo_launch.xml # .py or .yaml are also acceptable In the second terminal window type the following command: diff --git a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst index bb89775898c..3f427d2c9c7 100644 --- a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst +++ b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst @@ -252,12 +252,26 @@ Add the following line between the ``'console_scripts':`` brackets: Now create a launch file for this demo. Create a ``launch`` folder in the ``src/learning_tf2_py`` directory. -With your text editor, create a new file called ``turtle_tf2_demo_launch.py`` in the ``launch`` folder, and add the following lines: +With your text editor, create a new file called ``turtle_tf2_demo_launch`` with extension ``.py``, ``.xml``, or ``.yaml`` in the ``launch`` folder, and add the following lines: + +.. tabs:: + + .. group-tab:: Python .. literalinclude:: launch/py_turtle_tf2_demo_launch.py :language: python :name: turtle_tf2_demo_launch.py + .. group-tab:: XML + + .. literalinclude:: launch/py_turtle_tf2_demo_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/py_turtle_tf2_demo_launch.yaml + :language: yaml + 2.1 Examine the code ~~~~~~~~~~~~~~~~~~~~ @@ -265,16 +279,48 @@ With your text editor, create a new file called ``turtle_tf2_demo_launch.py`` in First we import required modules from the ``launch`` and ``launch_ros`` packages. It should be noted that ``launch`` is a generic launching framework (not ROS 2 specific) and ``launch_ros`` has ROS 2 specific things, like nodes that we import here. +.. tabs:: + + .. group-tab:: Python + .. literalinclude:: launch/py_turtle_tf2_demo_launch.py :language: python :lines: 1-2 + .. group-tab:: XML + + .. literalinclude:: launch/py_turtle_tf2_demo_launch.xml + :language: xml + :lines: 1-2 + + .. group-tab:: YAML + + .. literalinclude:: launch/py_turtle_tf2_demo_launch.yaml + :language: yaml + :lines: 1-3 + Now we run our nodes that start the turtlesim simulation and broadcast ``turtle1`` state to the tf2 using our ``turtle_tf2_broadcaster`` node. +.. tabs:: + + .. group-tab:: Python + .. literalinclude:: launch/py_turtle_tf2_demo_launch.py :language: python :lines: 7-19 + .. group-tab:: XML + + .. literalinclude:: launch/py_turtle_tf2_demo_launch.xml + :language: xml + :lines: 3-6 + + .. group-tab:: YAML + + .. literalinclude:: launch/py_turtle_tf2_demo_launch.yaml + :language: yaml + :lines: 4-9 + 2.2 Add dependencies ~~~~~~~~~~~~~~~~~~~~ @@ -395,7 +441,7 @@ Now run the launch file that will start the turtlesim simulation node and ``turt .. code-block:: console - $ ros2 launch learning_tf2_py turtle_tf2_demo_launch.py + $ ros2 launch learning_tf2_py turtle_tf2_demo_launch.xml # .py or .yaml are also acceptable In the second terminal window type the following command: diff --git a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.rst index f1c01bb19d8..70d98179eab 100644 --- a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.rst @@ -278,12 +278,26 @@ Finally, add the ``install(TARGETS…)`` section so ``ros2 run`` can find your e 2 Update the launch file ^^^^^^^^^^^^^^^^^^^^^^^^ -Open the launch file called ``turtle_tf2_demo_launch.py`` in the ``src/learning_tf2_cpp/launch`` directory with your text editor, add two new nodes to the launch description, add a launch argument, and add the imports. +Open the launch file called ``turtle_tf2_demo_launch`` with extension ``.py``, ``.xml``, or ``.yaml`` in the ``src/learning_tf2_cpp/launch`` directory with your text editor, add two new nodes to the launch description, add a launch argument, and add the imports. The resulting file should look like: +.. tabs:: + + .. group-tab:: Python + .. literalinclude:: launch/listener_cpp_launch.py :language: python + .. group-tab:: XML + + .. literalinclude:: launch/listener_cpp_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/listener_cpp_launch.yaml + :language: yaml + This will declare a ``target_frame`` launch argument, start a broadcaster for the second turtle that we will spawn and a listener that will subscribe to those transformations. 3 Build @@ -366,7 +380,7 @@ Now you're ready to start your full turtle demo: .. code-block:: console - $ ros2 launch learning_tf2_cpp turtle_tf2_demo_launch.py + $ ros2 launch learning_tf2_cpp turtle_tf2_demo_launch.xml # .py or .yaml are also acceptable You should see the turtle sim with two turtles. In the second terminal window type the following command: diff --git a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.rst b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.rst index 72bc186cc24..f0d34be8d01 100644 --- a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.rst +++ b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.rst @@ -227,13 +227,27 @@ Add the following line between the ``'console_scripts':`` brackets: 2 Update the launch file ^^^^^^^^^^^^^^^^^^^^^^^^ -Open the launch file called ``turtle_tf2_demo_launch.py`` in the ``src/learning_tf2_py/launch`` directory with your text editor, add two new nodes to the launch description, add a launch argument, and add the imports. +Open the launch file called ``turtle_tf2_demo_launch`` with extension ``.py``, ``.xml``, or ``.yaml`` in the ``src/learning_tf2_py/launch`` directory with your text editor, add two new nodes to the launch description, add a launch argument, and add the imports. The resulting file should look like: +.. tabs:: + + .. group-tab:: Python + .. literalinclude:: launch/listener_py_launch.py :language: python :name: turtle_tf2_demo_launch.py + .. group-tab:: XML + + .. literalinclude:: launch/listener_py_launch.xml + :language: xml + + .. group-tab:: YAML + + .. literalinclude:: launch/listener_py_launch.yaml + :language: yaml + This will declare a ``target_frame`` launch argument, start a broadcaster for second turtle that we will spawn and listener that will subscribe to those transformations. 3 Build @@ -318,7 +332,7 @@ Now you're ready to start your full turtle demo: .. code-block:: console - $ ros2 launch learning_tf2_py turtle_tf2_demo_launch.py + $ ros2 launch learning_tf2_py turtle_tf2_demo_launch.xml # .py or .yaml are also acceptable You should see the turtle sim with two turtles. In the second terminal window type the following command: diff --git a/source/Tutorials/Intermediate/Tf2/launch/listener_cpp_launch.xml b/source/Tutorials/Intermediate/Tf2/launch/listener_cpp_launch.xml new file mode 100644 index 00000000000..126c361af60 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/listener_cpp_launch.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/source/Tutorials/Intermediate/Tf2/launch/listener_cpp_launch.yaml b/source/Tutorials/Intermediate/Tf2/launch/listener_cpp_launch.yaml new file mode 100644 index 00000000000..71f70ad4d78 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/listener_cpp_launch.yaml @@ -0,0 +1,33 @@ +%YAML 1.2 +--- +launch: + - node: + pkg: "turtlesim" + exec: "turtlesim_node" + name: "sim" + - node: + pkg: "learning_tf2_cpp" + exec: "turtle_tf2_broadcaster" + name: "broadcaster1" + param: + - name: "turtlename" + value: "turtle1" + - arg: + name: "target_frame" + default: "turtle1" + description: "Target frame name." + - node: + pkg: "learning_tf2_cpp" + exec: "turtle_tf2_broadcaster" + name: "broadcaster2" + param: + - name: "turtlename" + value: "turtle2" + - node: + pkg: "learning_tf2_cpp" + exec: "turtle_tf2_listener" + name: "listener" + param: + - name: "target_frame" + value: "$(var target_frame)" + diff --git a/source/Tutorials/Intermediate/Tf2/launch/listener_py_launch.xml b/source/Tutorials/Intermediate/Tf2/launch/listener_py_launch.xml new file mode 100644 index 00000000000..afe5e5b657f --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/listener_py_launch.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/source/Tutorials/Intermediate/Tf2/launch/listener_py_launch.yaml b/source/Tutorials/Intermediate/Tf2/launch/listener_py_launch.yaml new file mode 100644 index 00000000000..24d82cfd7ce --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/listener_py_launch.yaml @@ -0,0 +1,33 @@ +%YAML 1.2 +--- +launch: + - node: + pkg: "turtlesim" + exec: "turtlesim_node" + name: "sim" + - node: + pkg: "learning_tf2_py" + exec: "turtle_tf2_broadcaster" + name: "broadcaster1" + param: + - name: "turtlename" + value: "turtle1" + - arg: + name: "target_frame" + default: "turtle1" + description: "Target frame name." + - node: + pkg: "learning_tf2_py" + exec: "turtle_tf2_broadcaster" + name: "broadcaster2" + param: + - name: "turtlename" + value: "turtle2" + - node: + pkg: "learning_tf2_py" + exec: "turtle_tf2_listener" + name: "listener" + param: + - name: "target_frame" + value: "$(var target_frame)" + diff --git a/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_demo_launch.xml b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_demo_launch.xml new file mode 100644 index 00000000000..61708e5ea10 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_demo_launch.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_demo_launch.yaml b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_demo_launch.yaml new file mode 100644 index 00000000000..994412c6b6c --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_demo_launch.yaml @@ -0,0 +1,15 @@ +%YAML 1.2 +--- +launch: + - node: + pkg: "turtlesim" + exec: "turtlesim_node" + name: "sim" + - node: + pkg: "learning_tf2_py" + exec: "turtle_tf2_broadcaster" + name: "broadcaster1" + param: + - name: "turtlename" + value: "turtle1" + diff --git a/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_dynamic_frame_demo_launch.xml b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_dynamic_frame_demo_launch.xml new file mode 100644 index 00000000000..bf45551a526 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_dynamic_frame_demo_launch.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_dynamic_frame_demo_launch.yaml b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_dynamic_frame_demo_launch.yaml new file mode 100644 index 00000000000..cda623faf3e --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_dynamic_frame_demo_launch.yaml @@ -0,0 +1,13 @@ +%YAML 1.2 +--- +launch: + - include: + file: "$(find-pkg-share learning_tf2_py)/launch/turtle_tf2_demo_launch.py" + let: + - name: "target_frame" + value: "carrot1" + - node: + pkg: "learning_tf2_py" + exec: "dynamic_frame_tf2_broadcaster" + name: "dynamic_broadcaster" + diff --git a/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_fixed_frame_demo_launch.xml b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_fixed_frame_demo_launch.xml new file mode 100644 index 00000000000..26a0084fd14 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_fixed_frame_demo_launch.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_fixed_frame_demo_launch.yaml b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_fixed_frame_demo_launch.yaml new file mode 100644 index 00000000000..3f5f99257a9 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/py_turtle_tf2_fixed_frame_demo_launch.yaml @@ -0,0 +1,10 @@ +%YAML 1.2 +--- +launch: + - include: + file: "$(find-pkg-share learning_tf2_py)/launch/turtle_tf2_demo_launch.py" + - node: + pkg: "learning_tf2_py" + exec: "fixed_frame_tf2_broadcaster" + name: "fixed_broadcaster" + diff --git a/source/Tutorials/Intermediate/Tf2/launch/start_tf2_debug_demo_launch.xml b/source/Tutorials/Intermediate/Tf2/launch/start_tf2_debug_demo_launch.xml new file mode 100644 index 00000000000..bd5eee3ee96 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/start_tf2_debug_demo_launch.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/source/Tutorials/Intermediate/Tf2/launch/start_tf2_debug_demo_launch.yaml b/source/Tutorials/Intermediate/Tf2/launch/start_tf2_debug_demo_launch.yaml new file mode 100644 index 00000000000..77ead6a6d4b --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/start_tf2_debug_demo_launch.yaml @@ -0,0 +1,34 @@ +%YAML 1.2 +--- +launch: + - arg: + name: "target_frame" + default: "turtle1" + description: "Target frame name." + - node: + pkg: "turtlesim" + exec: "turtlesim_node" + name: "sim" + output: "screen" + - node: + pkg: "learning_tf2_cpp" + exec: "turtle_tf2_broadcaster" + name: "broadcaster1" + param: + - name: "turtlename" + value: "turtle1" + - node: + pkg: "learning_tf2_cpp" + exec: "turtle_tf2_broadcaster" + name: "broadcaster2" + param: + - name: "turtlename" + value: "turtle2" + - node: + pkg: "learning_tf2_cpp" + exec: "turtle_tf2_listener_debug" + name: "listener_debug" + param: + - name: "target_frame" + value: "$(var target_frame)" + diff --git a/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_demo_launch.xml b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_demo_launch.xml new file mode 100644 index 00000000000..fadafacea89 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_demo_launch.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_demo_launch.yaml b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_demo_launch.yaml new file mode 100644 index 00000000000..519f0987706 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_demo_launch.yaml @@ -0,0 +1,15 @@ +%YAML 1.2 +--- +launch: + - node: + pkg: "turtlesim" + exec: "turtlesim_node" + name: "sim" + - node: + pkg: "learning_tf2_cpp" + exec: "turtle_tf2_broadcaster" + name: "broadcaster1" + param: + - name: "turtlename" + value: "turtle1" + diff --git a/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_dynamic_frame_demo_launch.xml b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_dynamic_frame_demo_launch.xml new file mode 100644 index 00000000000..03ae056c2c0 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_dynamic_frame_demo_launch.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_dynamic_frame_demo_launch.yaml b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_dynamic_frame_demo_launch.yaml new file mode 100644 index 00000000000..a8082e31ca4 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_dynamic_frame_demo_launch.yaml @@ -0,0 +1,13 @@ +%YAML 1.2 +--- +launch: + - include: + file: "$(find-pkg-share learning_tf2_cpp)/launch/turtle_tf2_demo_launch.py" + let: + - name: "target_frame" + value: "carrot1" + - node: + pkg: "learning_tf2_cpp" + exec: "dynamic_frame_tf2_broadcaster" + name: "dynamic_broadcaster" + diff --git a/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_fixed_frame_demo_launch.xml b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_fixed_frame_demo_launch.xml new file mode 100644 index 00000000000..0bef8375a29 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_fixed_frame_demo_launch.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_fixed_frame_demo_launch.yaml b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_fixed_frame_demo_launch.yaml new file mode 100644 index 00000000000..d150f91c510 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_fixed_frame_demo_launch.yaml @@ -0,0 +1,10 @@ +%YAML 1.2 +--- +launch: + - include: + file: "$(find-pkg-share learning_tf2_cpp)/launch/turtle_tf2_demo_launch.py" + - node: + pkg: "learning_tf2_cpp" + exec: "fixed_frame_tf2_broadcaster" + name: "fixed_broadcaster" + diff --git a/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_sensor_message_launch.xml b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_sensor_message_launch.xml new file mode 100644 index 00000000000..fcb5eb62cf3 --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_sensor_message_launch.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_sensor_message_launch.yaml b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_sensor_message_launch.yaml new file mode 100644 index 00000000000..504fe499dda --- /dev/null +++ b/source/Tutorials/Intermediate/Tf2/launch/turtle_tf2_sensor_message_launch.yaml @@ -0,0 +1,31 @@ +%YAML 1.2 +--- +launch: + - arg: + name: "target_frame" + default: "turtle1" + description: "Target frame name." + - node: + pkg: "turtlesim" + exec: "turtlesim_node" + name: "sim" + output: "screen" + - node: + pkg: "turtle_tf2_py" + exec: "turtle_tf2_broadcaster" + name: "broadcaster1" + param: + - name: "turtlename" + value: "turtle1" + - node: + pkg: "turtle_tf2_py" + exec: "turtle_tf2_broadcaster" + name: "broadcaster2" + param: + - name: "turtlename" + value: "turtle3" + - node: + pkg: "turtle_tf2_py" + exec: "turtle_tf2_message_broadcaster" + name: "message_broadcaster" + From e396180897040e1c405252d8876495b535c14ddd Mon Sep 17 00:00:00 2001 From: Luke Sy Date: Wed, 19 Nov 2025 10:04:20 +1100 Subject: [PATCH 2/3] Fix RST indentation errors in Tf2 tutorial tabbed code blocks Signed-off-by: Luke Sy --- .../Intermediate/Tf2/Adding-A-Frame-Cpp.rst | 14 +++++++------- .../Intermediate/Tf2/Adding-A-Frame-Py.rst | 16 ++++++++-------- .../Tf2/Debugging-Tf2-Problems.rst | 4 ++-- ...ed-Datatypes-With-Tf2-Ros-MessageFilter.rst | 4 ++-- .../Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst | 16 ++++++++-------- .../Tf2/Writing-A-Tf2-Broadcaster-Py.rst | 18 +++++++++--------- .../Tf2/Writing-A-Tf2-Listener-Cpp.rst | 4 ++-- .../Tf2/Writing-A-Tf2-Listener-Py.rst | 6 +++--- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst index 32bce05c6ae..437e2169ab0 100644 --- a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst @@ -188,8 +188,8 @@ With your text editor, create a new file called ``turtle_tf2_fixed_frame_demo_la .. group-tab:: Python -.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py - :language: python + .. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py + :language: python .. group-tab:: XML @@ -209,9 +209,9 @@ The last part of the code will add our fixed ``carrot1`` frame to the turtlesim .. group-tab:: Python -.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py - :language: python - :lines: 14-18 + .. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py + :language: python + :lines: 14-18 .. group-tab:: XML @@ -478,8 +478,8 @@ To test this code, create a new launch file ``turtle_tf2_dynamic_frame_demo_laun .. group-tab:: Python -.. literalinclude:: launch/turtle_tf2_dynamic_frame_demo_launch.py - :language: python + .. literalinclude:: launch/turtle_tf2_dynamic_frame_demo_launch.py + :language: python .. group-tab:: XML diff --git a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst index b7fa495a72c..6a6b7728ff8 100644 --- a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst +++ b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst @@ -165,9 +165,9 @@ With your text editor, create a new file called ``turtle_tf2_fixed_frame_demo_la .. group-tab:: Python -.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py - :name: turtle_tf2_fixed_frame_demo_launch.py - :language: python + .. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py + :name: turtle_tf2_fixed_frame_demo_launch.py + :language: python .. group-tab:: XML @@ -187,9 +187,9 @@ The last part of the code will add our fixed ``carrot1`` frame to the turtlesim .. group-tab:: Python -.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py - :language: python - :lines: 14-18 + .. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py + :language: python + :lines: 14-18 .. group-tab:: XML @@ -434,8 +434,8 @@ To test this code, create a new launch file ``turtle_tf2_dynamic_frame_demo_laun .. group-tab:: Python -.. literalinclude:: launch/py_turtle_tf2_dynamic_frame_demo_launch.py - :name: turtle_tf2_dynamic_frame_demo_launch.py + .. literalinclude:: launch/py_turtle_tf2_dynamic_frame_demo_launch.py + :name: turtle_tf2_dynamic_frame_demo_launch.py .. group-tab:: XML diff --git a/source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst b/source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst index 2cafff2e1f8..841fcaa30e0 100644 --- a/source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst +++ b/source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst @@ -76,8 +76,8 @@ In order to run this demo, we need to create a launch file ``start_tf2_debug_dem .. group-tab:: Python -.. literalinclude:: launch/start_tf2_debug_demo_launch.py - :language: python + .. literalinclude:: launch/start_tf2_debug_demo_launch.py + :language: python .. group-tab:: XML diff --git a/source/Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.rst b/source/Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.rst index 8137f14d14f..7f0747e355f 100644 --- a/source/Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.rst +++ b/source/Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.rst @@ -239,8 +239,8 @@ In order to run this demo, we need to create a launch file ``turtle_tf2_sensor_m .. group-tab:: Python -.. literalinclude:: launch/turtle_tf2_sensor_message_launch.py - :language: python + .. literalinclude:: launch/turtle_tf2_sensor_message_launch.py + :language: python .. group-tab:: XML diff --git a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst index bffa20b8563..8acb45e4b65 100644 --- a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst @@ -253,8 +253,8 @@ With your text editor, create a new file called ``turtle_tf2_demo_launch`` with .. group-tab:: Python -.. literalinclude:: launch/turtle_tf2_demo_launch.py - :language: python + .. literalinclude:: launch/turtle_tf2_demo_launch.py + :language: python .. group-tab:: XML @@ -276,9 +276,9 @@ It should be noted that ``launch`` is a generic launching framework (not ROS 2 s .. group-tab:: Python -.. literalinclude:: launch/turtle_tf2_demo_launch.py - :language: python - :lines: 1-2 + .. literalinclude:: launch/turtle_tf2_demo_launch.py + :language: python + :lines: 1-2 .. group-tab:: XML @@ -298,9 +298,9 @@ Now we run our nodes that start the turtlesim simulation and broadcast ``turtle1 .. group-tab:: Python -.. literalinclude:: launch/turtle_tf2_demo_launch.py - :language: python - :lines: 7-19 + .. literalinclude:: launch/turtle_tf2_demo_launch.py + :language: python + :lines: 7-19 .. group-tab:: XML diff --git a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst index 3f427d2c9c7..10c27a9d84b 100644 --- a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst +++ b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst @@ -258,9 +258,9 @@ With your text editor, create a new file called ``turtle_tf2_demo_launch`` with .. group-tab:: Python -.. literalinclude:: launch/py_turtle_tf2_demo_launch.py - :language: python - :name: turtle_tf2_demo_launch.py + .. literalinclude:: launch/py_turtle_tf2_demo_launch.py + :language: python + :name: turtle_tf2_demo_launch.py .. group-tab:: XML @@ -283,9 +283,9 @@ It should be noted that ``launch`` is a generic launching framework (not ROS 2 s .. group-tab:: Python -.. literalinclude:: launch/py_turtle_tf2_demo_launch.py - :language: python - :lines: 1-2 + .. literalinclude:: launch/py_turtle_tf2_demo_launch.py + :language: python + :lines: 1-2 .. group-tab:: XML @@ -305,9 +305,9 @@ Now we run our nodes that start the turtlesim simulation and broadcast ``turtle1 .. group-tab:: Python -.. literalinclude:: launch/py_turtle_tf2_demo_launch.py - :language: python - :lines: 7-19 + .. literalinclude:: launch/py_turtle_tf2_demo_launch.py + :language: python + :lines: 7-19 .. group-tab:: XML diff --git a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.rst index 70d98179eab..49a5b8f18db 100644 --- a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.rst @@ -285,8 +285,8 @@ The resulting file should look like: .. group-tab:: Python -.. literalinclude:: launch/listener_cpp_launch.py - :language: python + .. literalinclude:: launch/listener_cpp_launch.py + :language: python .. group-tab:: XML diff --git a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.rst b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.rst index f0d34be8d01..d519284277b 100644 --- a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.rst +++ b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.rst @@ -234,9 +234,9 @@ The resulting file should look like: .. group-tab:: Python -.. literalinclude:: launch/listener_py_launch.py - :language: python - :name: turtle_tf2_demo_launch.py + .. literalinclude:: launch/listener_py_launch.py + :language: python + :name: turtle_tf2_demo_launch.py .. group-tab:: XML From 8314093651a62e47694652391901943629732416 Mon Sep 17 00:00:00 2001 From: Luke Sy Date: Thu, 20 Nov 2025 16:05:03 +0000 Subject: [PATCH 3/3] Fix Tf2 tutorial launch file docs and line numbers - Update launch file format references (.xml -> .py) - Make launch file sections format-agnostic with tab-specific explanations - Correct YAML literalinclude line numbers in Adding-A-Frame tutorials Signed-off-by: Luke Sy --- .../Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst | 2 +- .../Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst | 2 +- .../Intermediate/Tf2/Introduction-To-Tf2.rst | 2 +- .../Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst | 11 +++++++++-- .../Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst | 11 +++++++++-- 5 files changed, 21 insertions(+), 7 deletions(-) diff --git a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst index 437e2169ab0..2929a621ea9 100644 --- a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst @@ -223,7 +223,7 @@ The last part of the code will add our fixed ``carrot1`` frame to the turtlesim .. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.yaml :language: yaml - :lines: 5-6 + :lines: 6-9 1.4 Build ~~~~~~~~~ diff --git a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst index 6a6b7728ff8..112db8990a3 100644 --- a/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst +++ b/source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst @@ -201,7 +201,7 @@ The last part of the code will add our fixed ``carrot1`` frame to the turtlesim .. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.yaml :language: yaml - :lines: 5-6 + :lines: 6-9 1.4 Build ~~~~~~~~~ diff --git a/source/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.rst b/source/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.rst index ac51c36a0c5..542b8a3c103 100644 --- a/source/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.rst +++ b/source/Tutorials/Intermediate/Tf2/Introduction-To-Tf2.rst @@ -51,7 +51,7 @@ Then run the following command: .. code-block:: console - $ ros2 launch turtle_tf2_py turtle_tf2_demo.launch.xml # .py or .yaml are also acceptable + $ ros2 launch turtle_tf2_py turtle_tf2_demo.launch.py You will see the turtlesim start with two turtles. diff --git a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst index 8acb45e4b65..1b4c80f82f9 100644 --- a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst +++ b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst @@ -269,25 +269,32 @@ With your text editor, create a new file called ``turtle_tf2_demo_launch`` with 2.1 Examine the code ~~~~~~~~~~~~~~~~~~~~ -First we import required modules from the ``launch`` and ``launch_ros`` packages. -It should be noted that ``launch`` is a generic launching framework (not ROS 2 specific) and ``launch_ros`` has ROS 2 specific things, like nodes that we import here. +Let's examine the launch file structure. +Each format has its own way of setting up the launch file: .. tabs:: .. group-tab:: Python + In Python launch files, we first import required modules from the ``launch`` and ``launch_ros`` packages. + It should be noted that ``launch`` is a generic launching framework (not ROS 2 specific) and ``launch_ros`` has ROS 2 specific things, like nodes that we import here. + .. literalinclude:: launch/turtle_tf2_demo_launch.py :language: python :lines: 1-2 .. group-tab:: XML + XML launch files start with an XML declaration and a root ```` element. + .. literalinclude:: launch/turtle_tf2_demo_launch.xml :language: xml :lines: 1-2 .. group-tab:: YAML + YAML launch files start with a YAML version declaration and a ``launch:`` key. + .. literalinclude:: launch/turtle_tf2_demo_launch.yaml :language: yaml :lines: 1-3 diff --git a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst index 10c27a9d84b..616ac898838 100644 --- a/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst +++ b/source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst @@ -276,25 +276,32 @@ With your text editor, create a new file called ``turtle_tf2_demo_launch`` with 2.1 Examine the code ~~~~~~~~~~~~~~~~~~~~ -First we import required modules from the ``launch`` and ``launch_ros`` packages. -It should be noted that ``launch`` is a generic launching framework (not ROS 2 specific) and ``launch_ros`` has ROS 2 specific things, like nodes that we import here. +Let's examine the launch file structure. +Each format has its own way of setting up the launch file: .. tabs:: .. group-tab:: Python + In Python launch files, we first import required modules from the ``launch`` and ``launch_ros`` packages. + It should be noted that ``launch`` is a generic launching framework (not ROS 2 specific) and ``launch_ros`` has ROS 2 specific things, like nodes that we import here. + .. literalinclude:: launch/py_turtle_tf2_demo_launch.py :language: python :lines: 1-2 .. group-tab:: XML + XML launch files start with an XML declaration and a root ```` element. + .. literalinclude:: launch/py_turtle_tf2_demo_launch.xml :language: xml :lines: 1-2 .. group-tab:: YAML + YAML launch files start with a YAML version declaration and a ``launch:`` key. + .. literalinclude:: launch/py_turtle_tf2_demo_launch.yaml :language: yaml :lines: 1-3