|Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.|
Using Third-Party LibrariesDescription: This tutorial shows best practices for using third-party libraries in ROS.
Keywords: external libraries, rosdep
Tutorial Level: INTERMEDIATE
Best practices for using third-party libraries
There are two ways of using third-party libraries in ROS:
First you have to decide which way to use. If possible the preferred method is to use system libraries.
Using System Libraries with rosdep
rosdep is ROS's method to define which system libraries a package needs installed. The library can then be used in the package by adding standard CMake commands. The advantages are:
- Quite simple setup in comparison to creating a wrapper package
- By using system libraries, the library will be maintained by the system maintainer and thus it is automatically updated
- The library is already built and possibly patched to work in each specific system
For a description see the rosdep documentation.
Wrapping third-party libraries
The idea of wrapping third-party libraries is to create a ROS package that compiles the third-party library code and makes it available using rosbuild's dependency system. The wrapper package is then used as a dependency by other packages. The advantages are:
- No need for a system package: If there is no system package for the external library wrapping the library in a package is the only possible way.
- Independent of system packages: If the same library is not available on all target systems or only in different version, wrapping provides the needed implementation
- Possibility to including custom patches in the library
For a description see the tutorial on Wrapping External Libraries.