This is a basic example of consuming a conan library package in a ROS 2 package.
conan create hello_conan_libInstall the conan dependencies of the ros2 package(s)
conan install ros2 --output-folder=build --build=missingBuild colcon package hello_ros
colcon build --base-paths ros2 --cmake-args -DCMAKE_TOOLCHAIN_FILE=$PWD/build/conan_toolchain.cmake -DCMAKE_BUILD_TYPE=ReleaseRun the executable
./build/hello_ros/hello_roshello_conan_lib: library that can be packaged with conanros2: base of ros2 packages, note the--base-paths rosarg passed tocolconros2/conanfile.txt: conan file describing the dependencies needed by ROS 2 packages to build
We need to pass the CMAKE_TOOLCHAIN_FILE argument to colcon to enable it to find the conan packages durring the build.