Skip to content
Merged
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
2 changes: 1 addition & 1 deletion docs/source/action_clients.rst
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,4 @@ The output in each window should be something similar to
[INFO] [1761753121.199914878] [move_straight_in_2d_action_client]: Received feedback distance: 0.4442135691642761.
[INFO] [1761753121.211306087] [move_straight_in_2d_action_client]: Received feedback distance: 0.4342135488986969.
[INFO] [1761753121.223468503] [move_straight_in_2d_action_client]: Received feedback distance: 0.42421355843544006.
[INFO] [1761753121.237240878] [move_straight_in_2d_action_client]: Final position was: geometry_msgs.msg.Point(x=0.7071067811865476, y=-0.7071067811865476, z=0.0).
[INFO] [1761753121.237240878] [move_straight_in_2d_action_client]: Final position was: geometry_msgs.msg.Point(x=0.7071067811865476, y=-0.7071067811865476, z=0.0).
40 changes: 20 additions & 20 deletions docs/source/cmake/cmake_packages_without_sudo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
Install a CMake package without sudo privileges
===============================================

To install a CMake package or library without sudo privileges, we need to define a directory to which we have access. For instance,
To install a CMake package or library without sudo privileges, we need to define a directory to which we have access. For instance,
in :code:`~/`.


Create a custom folder
----------------------

In this tutorial, we are going to create a custom folder :code:`~/opt` containing
In this tutorial, we are going to create a custom folder :code:`~/opt` containing
the folders :code:`lib` and :code:`include`. This will be our directory to install all our CMake packages.

Run the following commands,
Expand All @@ -22,7 +22,7 @@ Run the following commands,
mkdir -p include
mkdir -p lib

Then, we update the LD_LIBRARY_PATH, LIBRARY_PATH, and CPATH in :code:`~/.bashrc`.
Then, we update the LD_LIBRARY_PATH, LIBRARY_PATH, and CPATH in :code:`~/.bashrc`.

Do the following just once, so that all terminal windows automatically source this new workspace for you.

Expand All @@ -38,7 +38,7 @@ Do the following just once, so that all terminal windows automatically source th
echo "export CPATH=$CPATH:~/opt/include" >> ~/.bashrc

source ~/.bashrc


Install a CMake package
-----------------------
Expand All @@ -48,27 +48,27 @@ To install a CMake package, we set the :code:`CMAKE_INSTALL_PREFIX:PATH` flag wi

.. code-block:: console

cmake -DCMAKE_INSTALL_PREFIX:PATH=~/opt ..
make
cmake -DCMAKE_INSTALL_PREFIX:PATH=~/opt ..
make
make install


Example: Installing `qpOASES <https://github.com/coin-or/qpOASES>`_
-------------------------------------------------------------------------------
-------------------------------------------------------------------

This example shows how to build and install the qpOASES to be used in your CMake project.

.. note::
Check the `official qpOASES documentation <https://github.com/coin-or/qpOASES>`_ for more details.
.. note::
Check the `official qpOASES documentation <https://github.com/coin-or/qpOASES>`_ for more details.


.. warning::
.. warning::
This example assumes you have git, CMake, Eigen, and a C++ compiler installed in your GNU/Linux distribution.


To install qpOASES as a shared library, we use the instructions provided by the DQ Robotics in \
`cpp-interface-qpoases <https://github.com/dqrobotics/cpp-interface-qpoases>`_ specifying the
installation directory.
installation directory.

.. code-block:: console

Expand All @@ -79,23 +79,23 @@ installation directory.
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX:PATH=~/opt
make
make
make install


Example: include and link the qpOASES in your project
-------------------------------------------------------
-----------------------------------------------------

.. tab-set::

.. tab-item:: CMakeLists.txt

:download:`CMakeLists.txt <../../../cmake_tutorial_workspace/src/cpp_cmake_example_qpoases_lib/CMakeLists.txt>`

.. literalinclude:: ../../../cmake_tutorial_workspace/src/cpp_cmake_example_qpoases_lib/CMakeLists.txt
:language: cmake
:linenos:
:emphasize-lines: 17
:emphasize-lines: 17

.. tab-item:: test_qpoases.cpp

Expand All @@ -104,18 +104,18 @@ Example: include and link the qpOASES in your project
.. literalinclude:: ../../../cmake_tutorial_workspace/src/cpp_cmake_example_qpoases_lib/src/test_qpoases.cpp
:language: cpp
:linenos:
:emphasize-lines: 2,3
:emphasize-lines: 2,3


.. warning::
If you have the library installed in two directories, you need to ensure you are linking the library you want.
.. warning::
If you have the library installed in two directories, you need to ensure you are linking the library you want.

For instance, let's say you have the DQ Robotics library installed globally (i.e., :code:`/usr/local/lib/`) and locally (i.e., :code:`~/opt/lib`),
For instance, let's say you have the DQ Robotics library installed globally (i.e., :code:`/usr/local/lib/`) and locally (i.e., :code:`~/opt/lib`),
and you want to use the local one. Then, you can use :code:`find_library` with the :code:`NO_DEFAULT_PATH` flag.


.. literalinclude:: ../../../cmake_tutorial_workspace/src/cpp_cmake_example_qpoases_lib/examples/CMakeLists.txt
:language: cmake
:linenos:
:emphasize-lines: 3,4,9
:emphasize-lines: 3,4,9

40 changes: 20 additions & 20 deletions docs/source/cpp/cpp_library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ Creating C++ Libraries (for :program:`ament_cmake`)
.. admonition:: The C++ library block for :program:`ament_cmake`

.. dropdown:: TL;DR

When your project exports a library, you might benefit from using the following template.
Note that there is, in general, no reason to define multiple libraries. A single shared library can hold all the
content that you want to export from a package, hence the library named ``${PROJECT_NAME}``.

Remember to

#. Add all exported headers to :file:`include/<PACKAGE_NAME>` otherwise other packages cannot see it.
#. Add all source files of the library to ``add_library``.
#. Add all ROS2 dependencies of the library to ``ament_target_dependencies``.
#. Add **ALL** dependencies for which you used ``find_package`` to ``ament_export_dependencies``, otherwise dependencies might become complex for projects that use your library.
#. Add any other (**NOT ROS2**) libraries to ``target_link_libraries``.

.. literalinclude:: ../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/CMakeLists.txt
:language: cmake
:lines: 14-63
Expand All @@ -37,7 +37,7 @@ resulting in the following output

.. code-block:: console
:emphasize-lines: 16,17,18

ros2 pkg create cpp_package_with_a_library \
--build-type ament_cmake \
--dependencies rclcpp
Expand All @@ -57,7 +57,7 @@ resulting in the following output
creating folder ./cpp_package_with_a_library/src
creating folder ./cpp_package_with_a_library/include/cpp_package_with_a_library
creating ./cpp_package_with_a_library/CMakeLists.txt

[WARNING]: Unknown license 'TODO: License declaration'. This has been set in the package.xml, but no LICENSE file has been created.
It is recommended to use one of the ament license identitifers:
Apache-2.0
Expand All @@ -75,10 +75,10 @@ Package-related sources
-----------------------

.. admonition:: In this step, we'll work on these.

.. code-block:: console
:emphasize-lines: 2,6

cpp_package_with_a_library
├── CMakeLists.txt
├── include
Expand All @@ -103,7 +103,7 @@ The files already exist, we just need to modify them as follows

.. literalinclude:: ../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/package.xml
:language: xml
:linenos:
:linenos:

.. tab-item:: CMakeLists.txt

Expand All @@ -112,7 +112,7 @@ The files already exist, we just need to modify them as follows
Note that, because the local Node depends on the library being exported by this project, it needs to explicitly link to it.

:download:`CMakeLists.txt <../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/CMakeLists.txt>`

.. literalinclude:: ../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/CMakeLists.txt
:language: cmake
:linenos:
Expand All @@ -123,10 +123,10 @@ Library sources
---------------

.. admonition:: In this step, we'll work on these.

.. code-block:: console
:emphasize-lines: 5,8

cpp_package_with_a_library
├── CMakeLists.txt
├── include
Expand All @@ -141,12 +141,12 @@ Library sources

.. tab-set::

.. tab-item:: sample_class.hpp
.. tab-item:: sample_class.hpp

A class that does a bunch of nothing, but that depends on Eigen3 and Qt, as an example.

:download:`sample_class.hpp <../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/include/cpp_package_with_a_library/sample_class.hpp>`

.. literalinclude:: ../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/include/cpp_package_with_a_library/sample_class.hpp
:language: cpp
:linenos:
Expand All @@ -155,7 +155,7 @@ Library sources
.. tab-item:: sample_class.cpp

:download:`sample_class.cpp <../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/src/sample_class.cpp>`

.. literalinclude:: ../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/src/sample_class.cpp
:language: cpp
:linenos:
Expand All @@ -166,10 +166,10 @@ Sources for a local node that uses the library
----------------------------------------------

.. admonition:: In this step, we'll work on these.

.. code-block:: console
:emphasize-lines: 9-11

cpp_package_with_a_library
├── CMakeLists.txt
├── include
Expand All @@ -189,7 +189,7 @@ Just in case you need to have a node, in the same package, that also uses the li
.. tab-item:: sample_class_local_node.cpp

:download:`sample_class.cpp <../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/src/sample_class_local_node.cpp>`

.. literalinclude:: ../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/src/sample_class_local_node.cpp
:language: cpp
:linenos:
Expand All @@ -198,7 +198,7 @@ Just in case you need to have a node, in the same package, that also uses the li
.. tab-item:: sample_class_local_node.hpp

:download:`sample_class_local_node.cpp <../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/src/sample_class_local_node.hpp>`

.. literalinclude:: ../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/src/sample_class_local_node.hpp
:language: cpp
:linenos:
Expand All @@ -207,7 +207,7 @@ Just in case you need to have a node, in the same package, that also uses the li
.. tab-item:: sample_class_local_node_main.cpp

:download:`sample_class.cpp <../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/src/sample_class_local_node_main.cpp>`

.. literalinclude:: ../../../ros2_tutorial_workspace/src/cpp_package_with_a_library/src/sample_class_local_node_main.cpp
:language: cpp
:linenos:
Expand Down
Loading
Loading