Skip to content

fix: build on ROS 2 Lyrical - #551

Merged
wep21 merged 8 commits into
ANYbotics:rollingfrom
autowarefoundation:fix/lyrical-build
Nov 14, 2026
Merged

wep21 merged 8 commits into
ANYbotics:rollingfrom
autowarefoundation:fix/lyrical-build

Conversation

@xmfcx

@xmfcx xmfcx commented Nov 13, 2026 •

Copy link
Copy Markdown

What

This PR makes all 15 grid_map packages build on ROS 2 Lyrical (Ubuntu 26.04). Each commit fixes one problem:

  1. Use imported targets in grid_map_ros. This is the commit of PR 545, unchanged.
  2. Use target_link_libraries instead of ament_target_dependencies in the other 8 packages that call it.
  3. Build grid_map_rviz_plugin with Qt 6, and fall back to Qt 5, as rviz_common does.
  4. Call find_package(jsoncpp QUIET) before grid_map_pcl finds PCL.
  5. Replace the deprecated tf2_ros/transform_listener.h, rclcpp::spin_some and ament_index_cpp::get_package_share_directory.
  6. Do not make the <ciso646> warning from OctoMap an error in octomap_to_gridmap_demo. The warning stays visible.
  7. Declare Qt in grid_map_rviz_plugin/package.xml with the version-neutral rosdep keys that the RViz packages use.
  8. Apply the exception of item 6 only with GCC and Clang, as grid_map_package() does for -Werror.

PR 545:

With tests on, which is the default, the tests of grid_map_costmap_2d also need the test fixes. The two PRs must merge together:

Why

Without these changes, the build on Lyrical stops at these errors:

  1. Lyrical removed ament_target_dependencies, so CMake stops with Unknown CMake command "ament_target_dependencies".
  2. RViz on Lyrical uses Qt 6. With Qt 5, the moc output does not match the Qt headers.
  3. On Ubuntu 26.04, opencv_viz (through grid_map_ros) links VTK targets, and VTK::jsoncpp links JsonCpp::JsonCpp. VTK defines that target only when a caller asks for its jsoncpp component, and PCL does not. The CMake generate step fails.
  4. The packages build with -Werror, so each deprecated API stops the build.
  5. Ubuntu 26.04 ships OctoMap 1.10.0. Its OcTreeKey.h includes <ciso646>, which emits a #warning in C++20. OctoMap fixed this after 1.10.1.

The removal of ament_target_dependencies:

Known limitation: other packages that link ${grid_map_ros_LIBRARIES} and find PCL can hit the same VTK error as item 3, because grid_map_cv exports all OpenCV modules. This PR does not change that.

Jazzy and Kilted build from their own branches, so this PR does not affect them.

The upstream checks on this PR are red, because the current CI still tests Rolling on Ubuntu 24.04. The CI PR fixes that:

How it was tested

  • Lyrical on amd64, in a container, with the test fixes: colcon build built 15 packages, and colcon test gave 841 tests, 0 errors, 0 failures, 195 skipped. All skipped tests are cppcheck.
  • Lyrical on amd64, without the test fixes, with -DBUILD_TESTING=OFF: 15 packages built.
  • To find the minimal set of changes, I reverted the Qt 6 change and the tf2_ros header change one at a time. Each revert breaks the build of grid_map_rviz_plugin.
  • A downstream test package that links ${grid_map_ros_LIBRARIES}, ${grid_map_octomap_LIBRARIES}, ${grid_map_sdf_LIBRARIES} and grid_map_rviz_plugin::grid_map_rviz_plugin built and ran. ros2 run grid_map_demos tutorial_demo published /grid_map.
  • CI in our fork, with the CI PR and the test fixes:
  • Not tested: arm64, Clang, and the RViz plugin at runtime.

Replace ament_target_dependencies with explicit imported-target linking for the grid_map_ros library.

The Lyrical ament toolchain no longer accepts the legacy SYSTEM dependency expansion used here. Linking the exported ROS interface targets directly preserves transitive include paths and libraries, while retaining grid_map_cv's legacy variables until that package exports an imported target.

This change allows grid_map_ros 2.4.0 to build on ROS 2 Lyrical and removes the need for downstream CMake patches.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ROS 2 Lyrical removed ament_target_dependencies (ament/ament_cmake#614). CMake then stops with: Unknown CMake command "ament_target_dependencies".

Dependencies that export CMake targets link the targets. The grid_map packages that export only variables use <pkg>_LIBRARIES and <pkg>_INCLUDE_DIRS, which is what ament_target_dependencies did.

Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
RViz on Lyrical and Rolling uses Qt 6. With Qt 5, the moc output does not match the Qt headers. Find Qt 6 first and fall back to Qt 5, as rviz_common does, and use the versionless qt_wrap_cpp.

Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
On Ubuntu 26.04, opencv_viz (through grid_map_ros) links VTK targets, and VTK::jsoncpp links JsonCpp::JsonCpp. VTK defines that target only when a caller asks for its jsoncpp component, and PCL does not. The CMake generate step then fails. find_package(jsoncpp) defines the target.

Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
Lyrical deprecates tf2_ros/transform_listener.h, rclcpp::spin_some and ament_index_cpp::get_package_share_directory. The packages build with -Werror, so each warning stops the build. Use tf2_ros/transform_listener.hpp, a SingleThreadedExecutor and get_package_share_path.

Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
OctoMap 1.10.1 and older include <ciso646>, which emits a #warning in C++20. Ubuntu 26.04 ships OctoMap 1.10.0. Keep the warning, but do not make it an error for the one demo that includes OctoMap.

Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
rviz_common, rviz_rendering and rviz_default_plugins declare Qt with qt-base-dev, libqtcore, libqtgui and libqtwidgets. Use the same keys, so that the plugin follows the Qt version of RViz.

Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
grid_map_package() adds -Werror only for GCC and Clang, so the exception follows the same condition.

Signed-off-by: Mete Fatih Cırıt <mfc@autoware.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants