Skip to content

Commit fb47d09

Browse files
lsy3mergify[bot]
authored andcommitted
Add XML/YAML launch file equivalents to Tf2 tutorials (#6031)
Signed-off-by: Luke Sy <[email protected]> (cherry picked from commit 81786ba) # Conflicts: # source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst # source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst # source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst # source/Tutorials/Intermediate/Tf2/Learning-About-Tf2-And-Time-Cpp.rst # source/Tutorials/Intermediate/Tf2/Time-Travel-With-Tf2-Cpp.rst # source/Tutorials/Intermediate/Tf2/Using-Stamped-Datatypes-With-Tf2-Ros-MessageFilter.rst # source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Cpp.rst # source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Broadcaster-Py.rst # source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Cpp.rst # source/Tutorials/Intermediate/Tf2/Writing-A-Tf2-Listener-Py.rst
1 parent 6276577 commit fb47d09

30 files changed

+923
-56
lines changed

source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,18 +184,52 @@ Finally, add the ``install(TARGETS…)`` section so ``ros2 run`` can find your e
184184
~~~~~~~~~~~~~~~~~~~~~~~~~
185185

186186
Now let's create a launch file for this example.
187+
<<<<<<< HEAD
187188
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:
189+
=======
190+
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:
191+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
188192

189-
.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py
190-
:language: python
193+
.. tabs::
194+
195+
.. group-tab:: Python
196+
197+
.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py
198+
:language: python
199+
200+
.. group-tab:: XML
201+
202+
.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.xml
203+
:language: xml
204+
205+
.. group-tab:: YAML
206+
207+
.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.yaml
208+
:language: yaml
191209

192210
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.
193211

194212
The last part of the code will add our fixed ``carrot1`` frame to the turtlesim world using our ``fixed_frame_tf2_broadcaster`` node.
195213

196-
.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py
197-
:language: python
198-
:lines: 14-18
214+
.. tabs::
215+
216+
.. group-tab:: Python
217+
218+
.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py
219+
:language: python
220+
:lines: 14-18
221+
222+
.. group-tab:: XML
223+
224+
.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.xml
225+
:language: xml
226+
:lines: 3-4
227+
228+
.. group-tab:: YAML
229+
230+
.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.yaml
231+
:language: yaml
232+
:lines: 6-9
199233

200234
1.4 Build
201235
~~~~~~~~~
@@ -277,7 +311,11 @@ Now you can start the turtle broadcaster demo:
277311

278312
.. code-block:: console
279313
314+
<<<<<<< HEAD
280315
$ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo.launch.py
316+
=======
317+
$ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo_launch.xml # .py or .yaml are also acceptable
318+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
281319

282320
You should notice that the new ``carrot1`` frame appeared in the transformation tree.
283321

@@ -292,7 +330,11 @@ One way is to pass the ``target_frame`` argument to the launch file directly fro
292330

293331
.. code-block:: console
294332
333+
<<<<<<< HEAD
295334
$ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo.launch.py target_frame:=carrot1
335+
=======
336+
$ ros2 launch learning_tf2_cpp turtle_tf2_fixed_frame_demo_launch.xml target_frame:=carrot1 # .py or .yaml are also acceptable
337+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
296338

297339
The second way is to update the launch file.
298340
To do so, open the ``turtle_tf2_fixed_frame_demo.launch.py`` file, and add the ``'target_frame': 'carrot1'`` parameter via ``launch_arguments`` argument.
@@ -446,10 +488,28 @@ Finally, add the ``install(TARGETS…)`` section so ``ros2 run`` can find your e
446488
2.3 Write the launch file
447489
~~~~~~~~~~~~~~~~~~~~~~~~~
448490

491+
<<<<<<< HEAD
449492
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:
493+
=======
494+
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:
495+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
496+
497+
.. tabs::
498+
499+
.. group-tab:: Python
500+
501+
.. literalinclude:: launch/turtle_tf2_dynamic_frame_demo_launch.py
502+
:language: python
503+
504+
.. group-tab:: XML
505+
506+
.. literalinclude:: launch/turtle_tf2_dynamic_frame_demo_launch.xml
507+
:language: xml
508+
509+
.. group-tab:: YAML
450510

451-
.. literalinclude:: launch/turtle_tf2_dynamic_frame_demo_launch.py
452-
:language: python
511+
.. literalinclude:: launch/turtle_tf2_dynamic_frame_demo_launch.yaml
512+
:language: yaml
453513

454514

455515
2.4 Build
@@ -532,7 +592,11 @@ Now you can start the dynamic frame demo:
532592

533593
.. code-block:: console
534594
595+
<<<<<<< HEAD
535596
$ ros2 launch learning_tf2_cpp turtle_tf2_dynamic_frame_demo.launch.py
597+
=======
598+
$ ros2 launch learning_tf2_cpp turtle_tf2_dynamic_frame_demo_launch.xml # .py or .yaml are also acceptable
599+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
536600

537601
You should see that the second turtle is following the carrot's position that is constantly changing.
538602

source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst

Lines changed: 72 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,19 +160,53 @@ Add the following line between the ``'console_scripts':`` brackets:
160160
~~~~~~~~~~~~~~~~~~~~~~~~~
161161

162162
Now let's create a launch file for this example.
163+
<<<<<<< HEAD
163164
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:
165+
=======
166+
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:
167+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
164168

165-
.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py
166-
:name: turtle_tf2_fixed_frame_demo_launch.py
167-
:language: python
169+
.. tabs::
170+
171+
.. group-tab:: Python
172+
173+
.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py
174+
:name: turtle_tf2_fixed_frame_demo_launch.py
175+
:language: python
176+
177+
.. group-tab:: XML
178+
179+
.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.xml
180+
:language: xml
181+
182+
.. group-tab:: YAML
183+
184+
.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.yaml
185+
:language: yaml
168186

169187
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.
170188

171189
The last part of the code will add our fixed ``carrot1`` frame to the turtlesim world using our ``fixed_frame_tf2_broadcaster`` node.
172190

173-
.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py
174-
:language: python
175-
:lines: 14-18
191+
.. tabs::
192+
193+
.. group-tab:: Python
194+
195+
.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py
196+
:language: python
197+
:lines: 14-18
198+
199+
.. group-tab:: XML
200+
201+
.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.xml
202+
:language: xml
203+
:lines: 3-4
204+
205+
.. group-tab:: YAML
206+
207+
.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.yaml
208+
:language: yaml
209+
:lines: 6-9
176210

177211
1.4 Build
178212
~~~~~~~~~
@@ -254,7 +288,11 @@ Now you can start the turtle broadcaster demo:
254288

255289
.. code-block:: console
256290
291+
<<<<<<< HEAD
257292
$ ros2 launch learning_tf2_py turtle_tf2_fixed_frame_demo.launch.py
293+
=======
294+
$ ros2 launch learning_tf2_py turtle_tf2_fixed_frame_demo_launch.xml # .py or .yaml are also acceptable
295+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
258296

259297
You should notice that the new ``carrot1`` frame appeared in the transformation tree.
260298

@@ -269,7 +307,11 @@ One way is to pass the ``target_frame`` argument to the launch file directly fro
269307

270308
.. code-block:: console
271309
310+
<<<<<<< HEAD
272311
$ ros2 launch learning_tf2_py turtle_tf2_fixed_frame_demo.launch.py target_frame:=carrot1
312+
=======
313+
$ ros2 launch learning_tf2_py turtle_tf2_fixed_frame_demo_launch.xml target_frame:=carrot1 # .py or .yaml are also acceptable
314+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
273315

274316
The second way is to update the launch file.
275317
To do so, open the ``turtle_tf2_fixed_frame_demo.launch.py`` file, and add the ``'target_frame': 'carrot1'`` parameter via ``launch_arguments`` argument.
@@ -400,10 +442,28 @@ Add the following line between the ``'console_scripts':`` brackets:
400442
2.3 Write the launch file
401443
~~~~~~~~~~~~~~~~~~~~~~~~~
402444

445+
<<<<<<< HEAD
403446
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:
447+
=======
448+
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:
449+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
450+
451+
.. tabs::
452+
453+
.. group-tab:: Python
454+
455+
.. literalinclude:: launch/py_turtle_tf2_dynamic_frame_demo_launch.py
456+
:name: turtle_tf2_dynamic_frame_demo_launch.py
457+
458+
.. group-tab:: XML
459+
460+
.. literalinclude:: launch/py_turtle_tf2_dynamic_frame_demo_launch.xml
461+
:language: xml
462+
463+
.. group-tab:: YAML
404464

405-
.. literalinclude:: launch/py_turtle_tf2_dynamic_frame_demo_launch.py
406-
:name: turtle_tf2_dynamic_frame_demo_launch.py
465+
.. literalinclude:: launch/py_turtle_tf2_dynamic_frame_demo_launch.yaml
466+
:language: yaml
407467

408468

409469
2.4 Build
@@ -487,7 +547,11 @@ Now you can start the dynamic frame demo:
487547

488548
.. code-block:: console
489549
550+
<<<<<<< HEAD
490551
$ ros2 launch learning_tf2_py turtle_tf2_dynamic_frame_demo.launch.py
552+
=======
553+
$ ros2 launch learning_tf2_py turtle_tf2_dynamic_frame_demo_launch.xml # .py or .yaml are also acceptable
554+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
491555

492556
You should see that the second turtle is following the carrot's position that is constantly changing.
493557

source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst

Lines changed: 95 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,56 @@ to
7272
} catch (tf2::TransformException & ex) {
7373

7474
And save changes to the file.
75+
<<<<<<< HEAD
7576
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``:
77+
=======
78+
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``:
79+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
7680

77-
.. literalinclude:: launch/start_tf2_debug_demo_launch.py
78-
:language: python
81+
.. tabs::
82+
83+
.. group-tab:: Python
84+
85+
.. literalinclude:: launch/start_tf2_debug_demo_launch.py
86+
:language: python
87+
88+
.. group-tab:: XML
89+
90+
.. literalinclude:: launch/start_tf2_debug_demo_launch.xml
91+
:language: xml
92+
93+
.. group-tab:: YAML
94+
95+
.. literalinclude:: launch/start_tf2_debug_demo_launch.yaml
96+
:language: yaml
7997

8098
Don't forget to add the ``turtle_tf2_listener_debug`` executable to the ``CMakeLists.txt`` and build the package.
8199

82100
Now let's run it to see what happens:
83101

84-
.. code-block:: console
102+
.. tabs::
85103

104+
<<<<<<< HEAD
86105
$ ros2 launch learning_tf2_cpp start_tf2_debug_demo.launch.py
106+
=======
107+
.. group-tab:: XML
108+
109+
.. code-block:: console
110+
111+
$ ros2 launch learning_tf2_cpp start_tf2_debug_demo_launch.xml
112+
113+
.. group-tab:: YAML
114+
115+
.. code-block:: console
116+
117+
$ ros2 launch learning_tf2_cpp start_tf2_debug_demo_launch.yaml
118+
119+
.. group-tab:: Python
120+
121+
.. code-block:: console
122+
123+
$ ros2 launch learning_tf2_cpp start_tf2_debug_demo_launch.py
124+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
87125

88126
You will now see that the turtlesim came up.
89127
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.
@@ -156,13 +194,45 @@ To fix this bug, just replace ``turtle3`` with ``turtle2`` in line 67.
156194

157195
And now stop the running demo, build it, and run it again:
158196

159-
.. code-block:: console
197+
.. tabs::
160198

199+
<<<<<<< HEAD
161200
$ ros2 launch learning_tf2_cpp start_tf2_debug_demo.launch.py
162201
[turtle_tf2_listener_debug-4] [INFO] [1630223704.617382464] [listener_debug]: Could not
163202
transform turtle2 to turtle1: Lookup would require extrapolation into the future. Requested
164203
time 1630223704.617054 but the latest data is at time 1630223704.616726, when looking up
165204
transform from frame [turtle1] to frame [turtle2]
205+
=======
206+
.. group-tab:: XML
207+
208+
.. code-block:: console
209+
210+
$ ros2 launch learning_tf2_cpp start_tf2_debug_demo_launch.xml
211+
[turtle_tf2_listener_debug-4] [INFO] [1630223704.617382464] [listener_debug]: Could not
212+
transform turtle2 to turtle1: Lookup would require extrapolation into the future. Requested
213+
time 1630223704.617054 but the latest data is at time 1630223704.616726, when looking up
214+
transform from frame [turtle1] to frame [turtle2]
215+
216+
.. group-tab:: YAML
217+
218+
.. code-block:: console
219+
220+
$ ros2 launch learning_tf2_cpp start_tf2_debug_demo_launch.yaml
221+
[turtle_tf2_listener_debug-4] [INFO] [1630223704.617382464] [listener_debug]: Could not
222+
transform turtle2 to turtle1: Lookup would require extrapolation into the future. Requested
223+
time 1630223704.617054 but the latest data is at time 1630223704.616726, when looking up
224+
transform from frame [turtle1] to frame [turtle2]
225+
226+
.. group-tab:: Python
227+
228+
.. code-block:: console
229+
230+
$ ros2 launch learning_tf2_cpp start_tf2_debug_demo_launch.py
231+
[turtle_tf2_listener_debug-4] [INFO] [1630223704.617382464] [listener_debug]: Could not
232+
transform turtle2 to turtle1: Lookup would require extrapolation into the future. Requested
233+
time 1630223704.617054 but the latest data is at time 1630223704.616726, when looking up
234+
transform from frame [turtle1] to frame [turtle2]
235+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
166236

167237
And right away we run into the next problem.
168238

@@ -205,9 +275,29 @@ In the new code we are asking for the transform between the turtles 100 millisec
205275
It is usual to use a longer periods, just to make sure that the transform will arrive.
206276
Stop the demo, build and run:
207277

208-
.. code-block:: console
278+
.. tabs::
209279

280+
<<<<<<< HEAD
210281
$ ros2 launch learning_tf2_cpp start_tf2_debug_demo.launch.py
282+
=======
283+
.. group-tab:: XML
284+
285+
.. code-block:: console
286+
287+
$ ros2 launch turtle_tf2 start_tf2_debug_demo_launch.xml
288+
289+
.. group-tab:: YAML
290+
291+
.. code-block:: console
292+
293+
$ ros2 launch turtle_tf2 start_tf2_debug_demo_launch.yaml
294+
295+
.. group-tab:: Python
296+
297+
.. code-block:: console
298+
299+
$ ros2 launch turtle_tf2 start_tf2_debug_demo_launch.py
300+
>>>>>>> 81786ba (Add XML/YAML launch file equivalents to Tf2 tutorials (#6031))
211301

212302
And you should finally see the turtle move!
213303

0 commit comments

Comments
 (0)