Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 56 additions & 12 deletions source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Cpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,48 @@ 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:

.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py
:language: python
.. 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.

.. literalinclude:: launch/turtle_tf2_fixed_frame_demo_launch.py
:language: python
:lines: 14-18
.. 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: 6-9

1.4 Build
~~~~~~~~~
Expand Down Expand Up @@ -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.

Expand All @@ -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.
Expand Down Expand Up @@ -442,10 +472,24 @@ 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.py
:language: python
.. literalinclude:: launch/turtle_tf2_dynamic_frame_demo_launch.yaml
:language: yaml


2.4 Build
Expand Down Expand Up @@ -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.

Expand Down
70 changes: 57 additions & 13 deletions source/Tutorials/Intermediate/Tf2/Adding-A-Frame-Py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -159,19 +159,49 @@ 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:

.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py
:name: turtle_tf2_fixed_frame_demo_launch.py
:language: python
.. 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.

.. literalinclude:: launch/py_turtle_tf2_fixed_frame_demo_launch.py
:language: python
:lines: 14-18
.. 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: 6-9

1.4 Build
~~~~~~~~~
Expand Down Expand Up @@ -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.

Expand All @@ -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.
Expand Down Expand Up @@ -398,10 +428,24 @@ 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.py
:name: turtle_tf2_dynamic_frame_demo_launch.py
.. literalinclude:: launch/py_turtle_tf2_dynamic_frame_demo_launch.yaml
:language: yaml


2.4 Build
Expand Down Expand Up @@ -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.

Expand Down
26 changes: 20 additions & 6 deletions source/Tutorials/Intermediate/Tf2/Debugging-Tf2-Problems.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``:

.. literalinclude:: launch/start_tf2_debug_demo_launch.py
:language: python
.. 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.
Expand Down Expand Up @@ -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
Expand Down Expand 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!

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,24 @@ 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``:

.. literalinclude:: launch/turtle_tf2_sensor_message_launch.py
:language: python
.. 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
Expand Down Expand Up @@ -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:
Expand Down
Loading