Skip to content

Fix macOS compilation issues in Navigation2 packages - #5729

Merged
SteveMacenski merged 7 commits into
ros-navigation:mainfrom
idesign0:main
Dec 4, 2025
Merged

SteveMacenski merged 7 commits into
ros-navigation:mainfrom
idesign0:main

Conversation

@idesign0

Copy link
Copy Markdown
Contributor

Fix macOS compilation issues in Navigation2 packages

Summary

  • This PR fixes compilation issues on macOS for couple of Navigation2 packages. The changes include:
  • Correct use of template keyword in dependent template calls
  • Pass-by-value instead of non-const reference for optional structs

Package-wise Changes

1. nav2_behavior_tree

File: bt_action_server_impl.hpp

before:

// Put items on the blackboard
blackboard_->set<rclcpp::Node::SharedPtr>("node", client_node_);  // NOLINT
blackboard_->set<std::chrono::milliseconds>("server_timeout", default_server_timeout_);  // NOLINT
blackboard_->set<std::chrono::milliseconds>("bt_loop_duration", bt_loop_duration_);  // NOLINT
blackboard_->set<std::chrono::milliseconds>(
  "wait_for_service_timeout",
  wait_for_service_timeout_);

after:

// Put items on the blackboard
blackboard_->template set<rclcpp::Node::SharedPtr>("node", client_node_);  // NOLINT
blackboard_->template set<std::chrono::milliseconds>("server_timeout", default_server_timeout_);  // NOLINT
blackboard_->template set<std::chrono::milliseconds>("bt_loop_duration", bt_loop_duration_);  // NOLINT
blackboard_->template set<std::chrono::milliseconds>(
  "wait_for_service_timeout",
  wait_for_service_timeout_);

Explanation: The template keyword is required in dependent template contexts on Apple Clang.

2. nav2_route

a) File: route_server.hpp

before:

ReroutingState & rerouting_info = ReroutingState());

after:

ReroutingState rerouting_info = ReroutingState());

b) File: route_server.cpp

before:

template<typename GoalT>
Route RouteServer::findRoute(
  const std::shared_ptr<const GoalT> goal,
  ReroutingState & rerouting_info)
{
  // ...
}

after:

template<typename GoalT>
Route RouteServer::findRoute(
  const std::shared_ptr<const GoalT> goal,
  ReroutingState rerouting_info)
{
  // ...
}

Explanation: Non-const lvalue references cannot bind to temporaries in C++. Changing to pass-by-value fixes the compilation error while preserving optional behavior.

Testing

  • Full Navigation2 build on macOS: ✅ success
  • Verified no compilation warnings or runtime errors during compile-time checks

@SteveMacenski

SteveMacenski commented Nov 26, 2025 •

Copy link
Copy Markdown
Member

Please fill out the PR template in the future :-)

This also doesn't appear to build. How did you test this?

@idesign0

Copy link
Copy Markdown
Contributor Author

Please fill out the PR template in the future :-)

This also doesn't appear to build. How did you test this?

Thanks for the feedback! I’ll make sure to fill out the PR template properly next time.
Regarding the build: I tested these changes on macOS 26.1 (25B78) using the kilted branch. The workspace built successfully with the following command:

colcon build \                                          
  --symlink-install \
  --base-paths src/ros-planning/navigation2  \
  --executor parallel \
  --parallel-workers $(sysctl -n hw.ncpu) \
  --cmake-args -DCMAKE_TOOLCHAIN_FILE=$MY_TOOLCHAIN_FILE

Below is the Toolchain i use for the all the ros2 package builds.

message(WARN " Toolchain.cmake is being used.")

# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type" FORCE)

# Setting all the Build Tests Off
set(BUILD_TESTING OFF CACHE BOOL "Disable building tests" FORCE)
set(BUILD_UNIT_TESTS OFF CACHE BOOL "Disable building tests" FORCE)
set(BUILD_TESTS OFF CACHE BOOL "Disable building tests" FORCE)

# Make sure all workspace-installed packages are visible
set(ROS_WORKSPACE_INSTALL "$ENV{HOME}/kilted-ros2/install")
list(APPEND CMAKE_PREFIX_PATH "${ROS_WORKSPACE_INSTALL}")

# Ceres
set(BUILD_BENCHMARKS OFF CACHE BOOL "Disable building benchmarks" FORCE) 
set(BUILD_EXAMPLES OFF CACHE BOOL "Disable building examples" FORCE)

# --- yaml-cpp from ROS 2 kilted install ---
set(YAML_CPP_INCLUDE_DIRS
    "$ENV{HOME}/kilted-ros2/install/yaml_cpp_vendor/opt/yaml_cpp_vendor/include"
    CACHE PATH "yaml-cpp include dir")

set(YAML_CPP_LIBRARIES
    "$ENV{HOME}/kilted-ros2/install/yaml_cpp_vendor/opt/yaml_cpp_vendor/lib/libyaml-cpp.dylib"
    CACHE FILEPATH "yaml-cpp library")

# Use the paths
include_directories(${YAML_CPP_INCLUDE_DIRS})

# Backward ROS
# On macOS, do NOT add Linux-only flags
set(CMAKE_EXE_LINKER_FLAGS "${backward_ros_full_path_LIBRARIES} ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Linker flags" FORCE)

# Optimization flags
if(CMAKE_BUILD_TYPE STREQUAL "Release")
  add_compile_options(-O3 -march=native)
endif()


# Suppress treating warnings as errors
string(REPLACE "-Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "-Werror" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")

# 2. Force the new, modified flags into the CMake cache
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "Modified CXX flags without -Werror" FORCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "Modified C flags without -Werror" FORCE)

# Suppress warning as errors
add_compile_options(
        -Wno-error=unused-command-line-argument
        -Wno-error=pessimizing-move
        -Wno-error=unused-variable
        -Wno-error=unused-parameter
        -Wno-error=unused-but-set-variable
        -Wno-error=shadow 
        -Wno-error=shadow-field
        -Wno-error=deprecated-dynamic-exception-spec
        -Wno-error=inconsistent-missing-override
        -Wno-error=format-security
        -Wno-error=overloaded-virtual
        -Wno-error=deprecated-builtins
        -Wno-error=deprecated-copy-with-dtor
        -Wno-error=deprecated-copy-with-user-provided-dtor
        -Wno-error=unused-lambda-capture
 )

 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    # This specifically suppresses the dynamic exception warning
    string(APPEND CMAKE_CXX_FLAGS " -Wno-deprecated-dynamic-exception-spec")
    
    # Optional: If you want to disable ALL warnings-as-errors globally,
    # ensure this is done after any package might have tried to enable it.
    string(REPLACE "-Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()

# macOS specific linker
set(CMAKE_MACOSX_RPATH ON)

# Thread config
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

# # OpenMP for Apple Clang
# set(OpenMP_INCLUDE_DIR "/opt/homebrew/opt/libomp/include")
# set(OpenMP_LIB_DIR "/opt/homebrew/opt/libomp/lib")

# include_directories(SYSTEM "${OpenMP_INCLUDE_DIR}")

# set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS} -Xclang -fopenmp")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fopenmp")

# set(CMAKE_EXE_LINKER_FLAGS    "${CMAKE_EXE_LINKER_FLAGS} -L${OpenMP_LIB_DIR} -lomp")
# set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -L${OpenMP_LIB_DIR} -lomp")
# set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -L${OpenMP_LIB_DIR} -lomp")

# # Create the imported target so downstream packages can use it
# if (NOT TARGET OpenMP::OpenMP_CXX)
#     add_library(OpenMP::OpenMP_CXX INTERFACE IMPORTED)
#     set_target_properties(OpenMP::OpenMP_CXX PROPERTIES
#         INTERFACE_INCLUDE_DIRECTORIES "${OpenMP_INCLUDE_DIR}"
#         INTERFACE_LINK_LIBRARIES "-L${OpenMP_LIB_DIR} -lomp"
#     )
# endif()

# macOS provides LAPACK and BLAS inside Accelerate framework
set(BLAS_LIBRARIES "-framework Accelerate" CACHE STRING "BLAS libraries")
set(LAPACK_LIBRARIES "-framework Accelerate" CACHE STRING "LAPACK libraries")

# Paths related to dependencies used at build time (absolute or relative)

# Boost
# Path to your custom Boost installation
set(BOOST_ROOT "$ENV{HOME}/kilted-ros2/src/ros-commondep/boost-1.89" CACHE PATH "Boost root")
set(BOOST_INCLUDEDIR "${BOOST_ROOT}/include" CACHE PATH "Boost include")
set(BOOST_LIBRARYDIR "${BOOST_ROOT}/lib" CACHE PATH "Boost lib")

# Asio from Boost
set(THIRDPARTY_Asio ON CACHE BOOL "Allow Thirdparty Asio" FORCE)

# Ensure Boost can be found without searching system paths first
set(CMAKE_PREFIX_PATH "${BOOST_ROOT};${CMAKE_PREFIX_PATH}")

# Force modern CMake Boost behavior
set(Boost_NO_SYSTEM_PATHS ON CACHE BOOL "Don't search system paths for Boost")
set(Boost_NO_BOOST_CMAKE OFF CACHE BOOL "Allow BoostConfig.cmake if present")
find_package(Boost REQUIRED)

# Make sure CMake uses your Boost include & lib paths
set(Boost_INCLUDE_DIRS "${BOOST_INCLUDEDIR}" CACHE PATH "Boost include dirs" FORCE)
set(Boost_LIBRARY_DIRS "${BOOST_LIBRARYDIR}" CACHE PATH "Boost library dir" FORCE)

# Force include + lib dirs globally
include_directories(SYSTEM ${BOOST_INCLUDEDIR})
link_directories(${BOOST_LIBRARYDIR})

# Globally enable deprecated Boost Timer API
add_definitions(-DBOOST_TIMER_ENABLE_DEPRECATED)

# Python-specific paths
set(Boost_PYTHON_LIBRARY "${BOOST_LIBRARYDIR}/libboost_python311.dylib" CACHE FILEPATH "Boost Python library")
set(Boost_PYTHON_INCLUDE_DIR "${BOOST_INCLUDEDIR}" CACHE PATH "Boost Python include dir")

# Optional: force CMake to find Boost in these directories
set(CMAKE_PREFIX_PATH "${BOOST_ROOT}/lib/cmake/Boost-1.89.0;${CMAKE_PREFIX_PATH}" CACHE PATH "Boost CMake path")

# Google Benchmark paths (Homebrew)
set(CMAKE_PREFIX_PATH "/opt/homebrew/opt/google-benchmark;${CMAKE_PREFIX_PATH}")

#CLI
set(CLI11_INCLUDE_DIRS "/opt/homebrew/include" CACHE PATH "CLI11 include path" FORCE)
include_directories(SYSTEM ${CLI11_INCLUDE_DIRS})

# CSparse paths (Homebrew)
set(CSPARSE_INCLUDE_DIR "/opt/homebrew/include/suitesparse")
set(CSPARSE_LIBRARY "/opt/homebrew/lib/libsuitesparse.dylib")

# Ceres
set(Ceres_DIR "$ENV{HOME}/kilted-ros2/install/ceres-solver/lib/cmake/Ceres" CACHE PATH "")

# ProtoBuf
set(PROTOBUF_INSTALL_PATH 
    "$ENV{HOME}/kilted-ros2/install/protobuf" 
    CACHE PATH "Installation path for source-built Protobuf" FORCE)

# Set the CMAKE_PREFIX_PATH to prioritize the source install over Homebrew
set(CMAKE_PREFIX_PATH 
    "${PROTOBUF_INSTALL_PATH};${CMAKE_PREFIX_PATH}")

# Explicitly add the include directory to the system path
include_directories(SYSTEM "${PROTOBUF_INSTALL_PATH}/include")

# Explicitly set the variables that packages like gz-msgs will search for
set(PROTOBUF_INCLUDE_DIR "${PROTOBUF_INSTALL_PATH}/include" CACHE PATH "Protobuf Include Dir" FORCE)
set(PROTOBUF_LIBRARY "${PROTOBUF_INSTALL_PATH}/lib/libprotobuf.dylib" CACHE FILEPATH "Protobuf Library" FORCE)

# 1. Set the GDAL_CONFIG variable (often found in /opt/homebrew/bin)
set(GDAL_CONFIG_BIN "/opt/homebrew/bin/gdal-config" CACHE FILEPATH "Path to Homebrew gdal-config utility." FORCE)

# 2. Add it as an environment variable (often required by CMake's FindGDAL)
set(ENV{GDAL_CONFIG} ${GDAL_CONFIG_BIN})

# 3. Add the Homebrew prefix for general finding (if not already there)
set(CMAKE_PREFIX_PATH 
    "/opt/homebrew/opt/gdal;${CMAKE_PREFIX_PATH}" CACHE STRING "Prefix paths" FORCE)
    
#livox_ros_driver2
set(PCL_ALL_IN_ONE_INSTALLER OFF CACHE BOOL "Disable bundled Boost" FORCE)
set(ROS_EDITION "ROS2" CACHE STRING "ROS edition")
set(ROS_VERSION "2" CACHE STRING "ROS Version")
set(KILTED_ROS "kilted" CACHE STRING "ROS 2 kilted")
set(ROS_DISTRO "kilted" CACHE STRING "ROS 2 Distro")

# Qt5 path (for ROS packages)
set(Qt5_DIR "/opt/homebrew/opt/qt@5/lib/cmake/Qt5" CACHE PATH "Qt5 CMake path")
set(QT5_PREFIX "/opt/homebrew/opt/qt@5" CACHE PATH "Qt5 prefix path")

# Qt6 path (for Ignition Gazebo)
set(Qt6_DIR "/opt/homebrew/opt/qt/lib/cmake/Qt6" CACHE PATH "Qt6 CMake path")
set(QT6_PREFIX "/opt/homebrew/opt/qt" CACHE PATH "Qt6 prefix path")

# Add both Qt5 and Qt6 CMake modules to CMAKE_PREFIX_PATH
set(CMAKE_PREFIX_PATH "${QT6_PREFIX}/lib/cmake;${QT5_PREFIX}/lib/cmake;${CMAKE_PREFIX_PATH}" CACHE PATH "Qt CMake paths" FORCE)

# Add Qt5 and Qt6 binaries to PATH (for moc, uic, rcc)
set(ENV{PATH} "${QT6_PREFIX}/bin:${QT5_PREFIX}/bin:$ENV{PATH}")

# Tell CMake to look for frameworks last (helps prevent conflicts)
set(CMAKE_FIND_FRAMEWORK LAST)

# OpenGL (for Qt5Gui)
set(_GL_INCDIRS "/opt/homebrew/include" CACHE STRING "")
set(_qt5gui_OPENGL_INCLUDE_DIR "/opt/homebrew/include/GL" CACHE PATH "")
set(Qt5Gui_OPENGL_IMPLEMENTATION GL CACHE STRING "")
set(Qt5Gui_OPENGL_LIBRARIES "/opt/homebrew/lib/libGL.dylib" CACHE FILEPATH "")

# moveit_ros_perception
# Toolchain for macOS Homebrew OpenGL dependencies
set(GLEW_INCLUDE_DIR "/opt/homebrew/opt/glew/include" CACHE PATH "GLEW include directory")
set(GLEW_LIBRARY "/opt/homebrew/opt/glew/lib/libGLEW.dylib" CACHE FILEPATH "GLEW library")

set(GLUT_INCLUDE_DIR "/opt/homebrew/opt/freeglut/include" CACHE PATH "GLUT/FreeGLUT include directory")
set(GLUT_LIBRARY "/opt/homebrew/lib/libglut.dylib" CACHE FILEPATH "GLUT/FreeGLUT library")

set(GLEW_INCLUDE_DIRS ${GLEW_INCLUDE_DIR} CACHE INTERNAL "")
set(GLEW_LIBRARIES ${GLEW_LIBRARY} CACHE INTERNAL "")
set(GLUT_INCLUDE_DIRS ${GLUT_INCLUDE_DIR} CACHE INTERNAL "")
set(GLUT_LIBRARIES ${GLUT_LIBRARY} CACHE INTERNAL "")

set(SYSTEM_GL_INCLUDE_DIR ${GLEW_INCLUDE_DIRS} ${GLUT_INCLUDE_DIRS} CACHE INTERNAL "")
set(SYSTEM_GL_LIBRARIES ${GLEW_LIBRARIES} ${GLUT_LIBRARIES} CACHE INTERNAL "")

# macOS: link system OpenGL framework for Ogre
set(OGRE_FRAMEWORKS "-framework OpenGL")
# Pass to global linker flags for executables & shared libs
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OGRE_FRAMEWORKS}" CACHE STRING "Link OpenGL framework for Ogre" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OGRE_FRAMEWORKS}" CACHE STRING "Link OpenGL framework for Ogre" FORCE)

# --- Force TinyXML2 targets for Gazebo vendors (Mac/Homebrew fix) ---
if (NOT TARGET tinyxml2::tinyxml2)
    add_library(tinyxml2::tinyxml2 INTERFACE IMPORTED)
    set_target_properties(tinyxml2::tinyxml2 PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "/opt/homebrew/include"
        INTERFACE_LINK_LIBRARIES "/opt/homebrew/lib/libtinyxml2.dylib"
    )
endif()

if (NOT TARGET TINYXML2::TINYXML2)
    add_library(TINYXML2::TINYXML2 INTERFACE IMPORTED)
    set_target_properties(TINYXML2::TINYXML2 PROPERTIES
        INTERFACE_INCLUDE_DIRECTORIES "/opt/homebrew/include"
        INTERFACE_LINK_LIBRARIES "/opt/homebrew/lib/libtinyxml2.dylib"
    )
endif()

# --- Eigen (Homebrew) ---
# Ensure CMake can find Eigen headers
set(EIGEN3_INCLUDE_DIR "/opt/homebrew/include/eigen3" CACHE PATH "Eigen3 include directory" FORCE)
include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR})

# Optional: add Eigen to CMAKE_PREFIX_PATH so find_package(Eigen3) works
set(CMAKE_PREFIX_PATH "/opt/homebrew/include/eigen3;${CMAKE_PREFIX_PATH}" CACHE STRING "CMake prefix path" FORCE)

# If a package uses find_package(Eigen3)
find_package(Eigen3 REQUIRED)

# --- Google glog (Homebrew) ---
set(GLOG_INCLUDE_DIR "/opt/homebrew/include" CACHE PATH "glog include path" FORCE)
set(GLOG_LIBRARY "/opt/homebrew/lib/libglog.dylib" CACHE FILEPATH "glog library" FORCE)

# Add include directory globally
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})

# Append glog library to all targets' linker flags
# This ensures Ceres symbols (used in nav2_constrained_smoother) are found
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GLOG_LIBRARY}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GLOG_LIBRARY}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${GLOG_LIBRARY}")

# --- PCL Conversions ---
set(PCL_CONVERSIONS_INCLUDE_DIR "$ENV{HOME}/kilted-ros2/src/ros-perception/perception_pcl/pcl_conversions/include")
# Export for downstream packages
set(pcl_conversions_INCLUDE_DIRS "${PCL_CONVERSIONS_INCLUDE_DIR}" CACHE PATH "PCL Conversions include dirs" FORCE)

@idesign0

Copy link
Copy Markdown
Contributor Author

Please fill out the PR template in the future :-)

This also doesn't appear to build. How did you test this?

Build failure is simply related to nav2::LifecycleNode i think. My bad 🙃. Will fix and push it soon.

@mini-1235

Copy link
Copy Markdown
Collaborator

This seems to be related to #5660, @traversaro can you take a look here?

@traversaro

Copy link
Copy Markdown
Contributor

This seems to be related to #5660, @traversaro can you take a look here?

Yes, that indeed includes a fix for that issue, but I think it introduces a subtle bug, I commented inline.

Comment thread nav2_route/src/route_server.cpp Resolved
> reverting to nav2::LifecycleNode rather using rclcpp::Node

Signed-off-by: Dhruv Patel <[email protected]>
@codecov

codecov Bot commented Nov 27, 2025 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
...clude/nav2_behavior_tree/bt_action_server_impl.hpp 88.65% <100.00%> (+88.65%) ⬆️
...lude/nav2_route/plugins/route_operation_client.hpp 95.00% <ø> (ø)
nav2_route/include/nav2_route/route_server.hpp 100.00% <ø> (ø)

... and 385 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread nav2_route/src/route_server.cpp Resolved
@SteveMacenski

Copy link
Copy Markdown
Member

@idesign0 please rebase, we just changed some stuff to get CI to turn over from the recent QT5 -> 6 migration from GZ/Rviz

@SteveMacenski

Copy link
Copy Markdown
Member

@mini-1235


--- stderr: nav2_rviz_plugins               
CMake Error at /opt/underlay_ws/install/rviz_common/share/rviz_common/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake

  but it set Qt5_FOUND to FALSE so package "Qt5" is considered to be NOT
  FOUND.  Reason given by package:

  The Qt5 package requires at least one component

Call Stack (most recent call first):
  /opt/underlay_ws/install/rviz_common/share/rviz_common/cmake/rviz_commonConfig.cmake:41 (include)
  CMakeLists.txt:17 (find_package)

@mini-1235

Copy link
Copy Markdown
Collaborator

@mini-1235


--- stderr: nav2_rviz_plugins               
CMake Error at /opt/underlay_ws/install/rviz_common/share/rviz_common/cmake/ament_cmake_export_dependencies-extras.cmake:21 (find_package):
  Found package configuration file:

    /usr/lib/x86_64-linux-gnu/cmake/Qt5/Qt5Config.cmake

  but it set Qt5_FOUND to FALSE so package "Qt5" is considered to be NOT
  FOUND.  Reason given by package:

  The Qt5 package requires at least one component

Call Stack (most recent call first):
  /opt/underlay_ws/install/rviz_common/share/rviz_common/cmake/rviz_commonConfig.cmake:41 (include)
  CMakeLists.txt:17 (find_package)

Thanks, I will take a look

@SteveMacenski

Copy link
Copy Markdown
Member

Should that be handled now after the rebuild from recent merges?

@mini-1235

Copy link
Copy Markdown
Collaborator

Should that be handled now after the rebuild from recent merges?

I'll check in my PR

@mini-1235

Copy link
Copy Markdown
Collaborator

@idesign0 please rebase again, the CI issue should be fixed :)

@idesign0

idesign0 commented Dec 4, 2025

Copy link
Copy Markdown
Contributor Author

@idesign0 please rebase again, the CI issue should be fixed :)

surely! thanks. :)

@SteveMacenski
SteveMacenski merged commit 0fc9a10 into ros-navigation:main Dec 4, 2025
@SteveMacenski

Copy link
Copy Markdown
Member

Thanks for the iteration and persistence guys :-)

decwest pushed a commit to decwest/navigation2 that referenced this pull request Dec 10, 2025
…5729)

* Fix macOS compilation issues in Navigation2 packages

Signed-off-by: Dhruv Patel <[email protected]>

* Pre-commit Fix

Signed-off-by: Dhruv Patel <[email protected]>

* Fix: adding default template findRoute function
> reverting to nav2::LifecycleNode rather using rclcpp::Node

Signed-off-by: Dhruv Patel <[email protected]>

* Fix: removing temporary default in template function argument

Signed-off-by: Dhruv Patel <[email protected]>

---------

Signed-off-by: Dhruv Patel <[email protected]>
decwest pushed a commit to decwest/navigation2 that referenced this pull request Dec 11, 2025
…5729)

* Fix macOS compilation issues in Navigation2 packages

Signed-off-by: Dhruv Patel <[email protected]>

* Pre-commit Fix

Signed-off-by: Dhruv Patel <[email protected]>

* Fix: adding default template findRoute function
> reverting to nav2::LifecycleNode rather using rclcpp::Node

Signed-off-by: Dhruv Patel <[email protected]>

* Fix: removing temporary default in template function argument

Signed-off-by: Dhruv Patel <[email protected]>

---------

Signed-off-by: Dhruv Patel <[email protected]>
Signed-off-by: Decwest <[email protected]>
pele1410 pushed a commit to Metal-Shark-Sharktech/navigation2 that referenced this pull request Dec 30, 2025
…5729)

* Fix macOS compilation issues in Navigation2 packages

Signed-off-by: Dhruv Patel <[email protected]>

* Pre-commit Fix

Signed-off-by: Dhruv Patel <[email protected]>

* Fix: adding default template findRoute function
> reverting to nav2::LifecycleNode rather using rclcpp::Node

Signed-off-by: Dhruv Patel <[email protected]>

* Fix: removing temporary default in template function argument

Signed-off-by: Dhruv Patel <[email protected]>

---------

Signed-off-by: Dhruv Patel <[email protected]>
Signed-off-by: Christopher Thompson <[email protected]>
solonovamax added a commit to solonovamax/navigation2 that referenced this pull request Mar 6, 2026
This backports the changes from ros-navigation#5729 to Jazzy, and also adds a fallback
template to preserve API compatibility.

Fixes ros-navigation#6015

Signed-off-by: solonovamax <[email protected]>
SteveMacenski pushed a commit that referenced this pull request Mar 6, 2026
* Backport #5729 to Jazzy

This backports the changes from #5729 to Jazzy, and also adds a fallback
template to preserve API compatibility.

Fixes #6015

Signed-off-by: solonovamax <[email protected]>

* Fix compilation of MPPI controller with Clang

Fixes the compilation of the MPPI controller when using
the Clang compiler on Linux or macOS.

Fixes #6014

Signed-off-by: solonovamax <[email protected]>

---------

Signed-off-by: solonovamax <[email protected]>
Rooteq pushed a commit to Rooteq/navigation2 that referenced this pull request Nov 9, 2026
* Backport ros-navigation#5729 to Jazzy

This backports the changes from ros-navigation#5729 to Jazzy, and also adds a fallback
template to preserve API compatibility.

Fixes ros-navigation#6015

Signed-off-by: solonovamax <[email protected]>

* Fix compilation of MPPI controller with Clang

Fixes the compilation of the MPPI controller when using
the Clang compiler on Linux or macOS.

Fixes ros-navigation#6014

Signed-off-by: solonovamax <[email protected]>

---------

Signed-off-by: solonovamax <[email protected]>
@idesign0

Copy link
Copy Markdown
Contributor Author

Could this be backported to jazzy? Note: on jazzy the subtree blackboard also sets cancel_timeout, which should be kept.

@jwallace42

Copy link
Copy Markdown
Contributor

Could this be backported to jazzy? Note: on jazzy the subtree blackboard also sets cancel_timeout, which should be kept.

Yes! Feel free to open a pr.

jwallace42 pushed a commit that referenced this pull request Nov 18, 2026
…ly fixes (#6815)

* Use Mach thread policy for soft real-time priority on macOS (backport #5679)

Partial backport of #5679 to jazzy: only the nav2_util node_utils change.
sched_setscheduler() and SCHED_FIFO do not exist on macOS, so nav2_util
fails to compile there. On __APPLE__, setSoftRealTimePriority() now uses
the Mach thread precedence policy; other platforms are unchanged. The
std::chrono cast part of #5679 targets main and is not needed on jazzy.

Compile-tested on macOS 27 (arm64, Apple clang 21) as an overlay on a
ROS 2 Jazzy install: nav2_util builds with nav2_package()'s -Werror.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Dhruv Patel <[email protected]>

* Add template keyword for dependent calls on macOS (backport #5729)

Backport of #5729 to jazzy. Apple clang rejects calls to member templates
of a dependent type without the `template` keyword, so nav2_behavior_tree
(bt_action_server_impl.hpp, subtree blackboard setters) and nav2_route
(route_operation_client.hpp, create_client) fail to compile there.
jazzy already has the route_server.hpp part via #6016. jazzy also sets
cancel_timeout on the subtree blackboard (#5903); it is kept, with the
same keyword.

Compile-tested on macOS 27 (arm64, Apple clang 21) as an overlay on a
ROS 2 Jazzy install: nav2_behavior_tree and nav2_bt_navigator build with
nav2_package()'s -Werror.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Dhruv Patel <[email protected]>

* Fix Apple Clang template ambiguity in MPPI (backport #6017)

Backport of #6017 (merged into humble) to jazzy, whose MPPI still uses
xtensor. On Apple clang the xt::cumsum(..., {1}) calls in optimizer.cpp
resolve through a braced scalar (-Wbraced-scalar-init, an error under
nav2_package()'s -Werror). As in #6017, these use the cumsum helpers in
tools/apple_utils.hpp on __APPLE__; the non-Apple path is unchanged in
result. The humble commit does not apply cleanly to jazzy, so this is
the same change adapted to jazzy's files.

Compile-tested on macOS 27 (arm64, Apple clang 21) as an overlay on a
ROS 2 Jazzy install, both sides with the same local CMakeLists workaround
for the separate AppleClang flag issue: upstream jazzy reports
optimizer.cpp:380/396/398 "braces around scalar initializer"; with this
change those are gone and the remaining errors (-Wpessimizing-move in
four critics, a separate issue) are identical on both sides.

Signed-off-by: Dhruv Patel <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Fix clang -Werror errors in nav2_system_tests and nav2_rviz_plugins (#6803)

Backport of #6803 to jazzy.

* nav2_system_tests: mark the UnknownErrorController overrides (cleanup,
  activate, deactivate, setPlan, computeVelocityCommands, setSpeedLimit)
  with override (-Winconsistent-missing-override).
* nav2_rviz_plugins: discard the stoi() result explicitly
  (-Wunused-result; libc++ marks std::stoi [[nodiscard]]).

Adapted to jazzy: setPlan instead of newPathReceived, and
computeVelocityCommands takes the GoalChecker.

Compile-tested on macOS 27 (arm64, Apple clang 21) as an overlay on a
ROS 2 Jazzy install, with nav2_package()'s -Werror:
nav2_system_tests fails on upstream jazzy with 6 missing-override errors
and builds with this change; nav2_rviz_plugins' nav2_panel.cpp
-Wunused-result error is gone.

(cherry picked from commit 6272fad)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Dhruv Patel <[email protected]>

* nav2_rviz_plugins: Remove slots without implementation (#4974)

Without this change, when compiled for Jazzy with Nix using gcc14 and
qt-5.15, loading the plugins to rviz fails with the following error:

    [rviz2]: PluginlibFactory: The plugin for class
    'nav2_rviz_plugins/Navigation 2' failed to load. Error: Failed to
    load library /nix/store/...-ros-env/lib/libnav2_rviz_plugins.so.
    Make sure that you are calling the PLUGINLIB_EXPORT_CLASS macro in
    the library code, and that names are consistent between this macro
    and your XML. Error string: Could not load library dlopen error:
    /nix/store/...-ros-env/lib/libnav2_rviz_plugins.so: undefined
    symbol: _ZN17nav2_rviz_plugins12DockingPanel9onStartupEv, at
    /build/rcutils-release-release-jazzy-rcutils-6.7.2-1/src/shared_library.c:99

The dynamic linker complains about undefined symbol, which corresponds
to a Qt slot, which is declared, but has no implementation. I'm not
sure what is the root cause of this behavior, but removing the slot
definitions fixes the problem and the plugins can be loaded.

Signed-off-by: Michal Sojka <[email protected]>
(cherry picked from commit e6f500e)
Signed-off-by: Dhruv Patel <[email protected]>

* nav2_rviz_plugins: Don't use non-existent slot (#5016)

The definition of the slot was removed in commit
e6f500e ("nav2_rviz_plugins: Remove slots without
implementation (#4974)", 2025-03-10), because it had no
implementation. But we forgot to remove the reference to this slot,
because the compiler cannot detect it.

We remove the reference now. Without this, rviz shows warnings like:

    QObject::connect: No such slot nav2_rviz_plugins::CostmapCostTool::updateAutoDeactivate()
    QObject::connect:  (sender name:   'Single click')

Signed-off-by: Michal Sojka <[email protected]>
(cherry picked from commit 46dbd07)
Signed-off-by: Dhruv Patel <[email protected]>

* Mark virtual overrides with override (backport of #5782)

Clang reports -Winconsistent-missing-override (an error under
nav2_package()'s -Werror) in costmap_filter.hpp, keepout_filter.hpp,
plugin_container_layer.hpp and route_tool.hpp, where some overrides are
marked and others are not. Same headers as #5782 on main; jazzy keeps
`override` instead of `final` on CostmapFilter::isClearable() so
out-of-tree filters that override it still build, and keepout_filter
uses jazzy's Pose2D signature. The map_server and planner_server parts of
#5782 are not needed on jazzy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Dhruv Patel <[email protected]>

* Circle: keep Polygon::updatePolygon overloads visible (-Woverloaded-virtual)

  circle.hpp:102:8: error: 'nav2_collision_monitor::Circle::updatePolygon' hides
  overloaded virtual function [-Werror,-Woverloaded-virtual]

Circle::updatePolygon(double) hid Polygon::updatePolygon(const Velocity &) (public,
virtual) and Polygon::updatePolygon(PolygonStamped::ConstSharedPtr) (protected).
A using-declaration in Circle's protected section brings them back into Circle's
scope. Circle overrides neither, so virtual dispatch is unchanged; the one call inside
Circle, updatePolygon(msg->data) with a float, still selects updatePolygon(double)
(Velocity is an aggregate and a shared_ptr is not constructible from a float), and
calls through Polygon pointers are unaffected.

Tested on macOS 27 (arm64), Apple clang 21, CMake 4.4.2: all 45 packages of this
branch build as an overlay on ros2-jazzy 26.11.16.7 with nav2_package()'s -Werror active
and no extra compiler flags. Every translation unit of nav2_costmap_2d,
nav2_collision_monitor, nav2_mppi_controller, nav2_route, nav2_rviz_plugins,
nav2_smac_planner and the nav2_system_tests controller plugins (138) was compiled from
the previous commit and from this series with identical flags (the originals with
-Wno-error, both with the source root mapped to one path): `otool -tV` output is
byte-identical for all 138. planner/controller/behavior/bt_navigator/smoother/
waypoint_follower/velocity_smoother/collision_monitor/route_server configure through
lifecycle with nav2_bringup's nav2_params.yaml.
Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: Dhruv Patel <[email protected]>

* mppi: only probe x86 SIMD flags on x86 (-Wunused-command-line-argument)

  clang++: error: argument unused during compilation: '-msse4.2'
  [-Werror,-Wunused-command-line-argument]

On arm64, check_cxx_compiler_flag("-msse4.2") passes (clang only warns that the flag
is unused) while -mno-avx512f, -mavx2 and -mfma are rejected, so -msse4.2 alone was
added -- with no effect on arm64 code, and fatal under -Werror. The checks and
add_compile_options now run only when CMAKE_SYSTEM_PROCESSOR is x86; on x86 they are
exactly as before.

Tested on macOS 27 (arm64), Apple clang 21, CMake 4.4.2: all 45 packages of this
branch build as an overlay on ros2-jazzy 26.11.16.7 with nav2_package()'s -Werror active
and no extra compiler flags. Every translation unit of nav2_costmap_2d,
nav2_collision_monitor, nav2_mppi_controller, nav2_route, nav2_rviz_plugins,
nav2_smac_planner and the nav2_system_tests controller plugins (138) was compiled from
the previous commit and from this series with identical flags (the originals with
-Wno-error, both with the source root mapped to one path): `otool -tV` output is
byte-identical for all 138. planner/controller/behavior/bt_navigator/smoother/
waypoint_follower/velocity_smoother/collision_monitor/route_server configure through
lifecycle with nav2_bringup's nav2_params.yaml.
Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: Dhruv Patel <[email protected]>

* mppi: guard GCC-only diagnostic pragmas from clang (-Wunknown-warning-option)

  tools/utils.hpp: error: unknown warning group '-Wstringop-overflow', ignored
  [-Werror,-Wunknown-warning-option]
  (and '-Wmaybe-uninitialized'; same in critic_data.hpp, critic_manager.hpp,
  models/*.hpp, motion_models.hpp, optimizer.hpp, tools/noise_generator.hpp,
  tools/trajectory_visualizer.hpp)

-Wstringop-overflow and -Wmaybe-uninitialized exist only in GCC; clang ignores the
pragma and warns. Each such pragma line is wrapped in
#if defined(__GNUC__) && !defined(__clang__). GCC sees the same pragmas as before;
clang never acted on them. -Warray-bounds (known to both) is left as is.
(test/utils_test.cpp carries the same pragma and gets the same guard; tests were not
built here.)

Tested on macOS 27 (arm64), Apple clang 21, CMake 4.4.2: all 45 packages of this
branch build as an overlay on ros2-jazzy 26.11.16.7 with nav2_package()'s -Werror active
and no extra compiler flags. Every translation unit of nav2_costmap_2d,
nav2_collision_monitor, nav2_mppi_controller, nav2_route, nav2_rviz_plugins,
nav2_smac_planner and the nav2_system_tests controller plugins (138) was compiled from
the previous commit and from this series with identical flags (the originals with
-Wno-error, both with the source root mapped to one path): `otool -tV` output is
byte-identical for all 138. planner/controller/behavior/bt_navigator/smoother/
waypoint_follower/velocity_smoother/collision_monitor/route_server configure through
lifecycle with nav2_bringup's nav2_params.yaml.
Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: Dhruv Patel <[email protected]>

* mppi: drop std::move on xtensor expression temporaries (-Wpessimizing-move)

  constraint_critic.cpp: error: moving a temporary object prevents copy elision
  [-Werror,-Wpessimizing-move]   (6x; velocity_deadband_critic.cpp 4x,
  prefer_forward_critic.cpp 2x, path_follow_critic.cpp 2x)

std::move(expr) on a prvalue only adds a move. Each std::move(X) becomes (X) --
parentheses kept, so grouping is unchanged: e.g. std::move(a + b + c) * dt stays
(a + b + c) * dt, not a + b + c * dt -- and where the call was already wrapped,
(std::move(X)) becomes (X). Machine code of all four critics is byte-identical to before
(see below).

Tested on macOS 27 (arm64), Apple clang 21, CMake 4.4.2: all 45 packages of this
branch build as an overlay on ros2-jazzy 26.11.16.7 with nav2_package()'s -Werror active
and no extra compiler flags. Every translation unit of nav2_costmap_2d,
nav2_collision_monitor, nav2_mppi_controller, nav2_route, nav2_rviz_plugins,
nav2_smac_planner and the nav2_system_tests controller plugins (138) was compiled from
the previous commit and from this series with identical flags (the originals with
-Wno-error, both with the source root mapped to one path): `otool -tV` output is
byte-identical for all 138. planner/controller/behavior/bt_navigator/smoother/
waypoint_follower/velocity_smoother/collision_monitor/route_server configure through
lifecycle with nav2_bringup's nav2_params.yaml.
Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: Dhruv Patel <[email protected]>

* route, smac_planner: use the nlohmann_json / nanoflann targets for their headers

  nav2_route/include/nav2_route/graph_loader.hpp:22:10: fatal error:
  'nlohmann/json.hpp' file not found
  nav2_route/include/nav2_route/node_spatial_tree.hpp:21:10: fatal error:
  'nanoflann.hpp' file not found
  nav2_smac_planner/include/nav2_smac_planner/node_lattice.hpp:30:10: fatal error:
  'nlohmann/json.hpp' file not found

nav2_route names nlohmann_json in ament_target_dependencies(), which only forwards
<pkg>_INCLUDE_DIRS/<pkg>_TARGETS -- nlohmann_json's config defines neither -- and it
find_package()s nanoflann without using it; nav2_smac_planner includes json.hpp
without finding the package. Both only build where the headers sit in a default
include dir (/usr/include on Ubuntu). Link nlohmann_json::nlohmann_json (and
nanoflann::nanoflann for nav2_route), header-only INTERFACE targets that add their
include dir, and export the dependencies their installed headers need so consumers
(nav2_rviz_plugins) can resolve those targets. Both are already <depend>s in
package.xml. No generated code changes (nav2_route and nav2_smac_planner objects are
byte-identical, below).

Tested on macOS 27 (arm64), Apple clang 21, CMake 4.4.2: all 45 packages of this
branch build as an overlay on ros2-jazzy 26.11.16.7 with nav2_package()'s -Werror active
and no extra compiler flags. Every translation unit of nav2_costmap_2d,
nav2_collision_monitor, nav2_mppi_controller, nav2_route, nav2_rviz_plugins,
nav2_smac_planner and the nav2_system_tests controller plugins (138) was compiled from
the previous commit and from this series with identical flags (the originals with
-Wno-error, both with the source root mapped to one path): `otool -tV` output is
byte-identical for all 138. planner/controller/behavior/bt_navigator/smoother/
waypoint_follower/velocity_smoother/collision_monitor/route_server configure through
lifecycle with nav2_bringup's nav2_params.yaml.
Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: Dhruv Patel <[email protected]>

* smac_planner: drop unused #include <omp.h>

  nav2_smac_planner/src/a_star.cpp:16:10: fatal error: 'omp.h' file not found

a_star.cpp uses no OpenMP (no #pragma omp, no omp_* call) and the package neither
finds nor links OpenMP, so the include is unused; it only compiles where omp.h is a
default header (GCC). Removed; a_star.cpp's object code is byte-identical.

Tested on macOS 27 (arm64), Apple clang 21, CMake 4.4.2: all 45 packages of this
branch build as an overlay on ros2-jazzy 26.11.16.7 with nav2_package()'s -Werror active
and no extra compiler flags. Every translation unit of nav2_costmap_2d,
nav2_collision_monitor, nav2_mppi_controller, nav2_route, nav2_rviz_plugins,
nav2_smac_planner and the nav2_system_tests controller plugins (138) was compiled from
the previous commit and from this series with identical flags (the originals with
-Wno-error, both with the source root mapped to one path): `otool -tV` output is
byte-identical for all 138. planner/controller/behavior/bt_navigator/smoother/
waypoint_follower/velocity_smoother/collision_monitor/route_server configure through
lifecycle with nav2_bringup's nav2_params.yaml.
Co-Authored-By: Claude Opus 5.5 <[email protected]>

Signed-off-by: Dhruv Patel <[email protected]>

* nav2_mppi_controller: GCC-only flags only for GCC, match AppleClang

Two compiler checks in the CMakeLists break Apple clang:
* -finline-limit is passed to every compiler; clang rejects it
  (-Wignored-optimization-argument, an error under -Werror). It is now
  added only for GCC; the other optimization flags are unchanged for all.
* The C++20 branch checks CMAKE_CXX_COMPILER_ID STREQUAL "Clang", but
  Apple's compiler reports "AppleClang", so it gets -fconcepts
  (clang++: error: unknown argument: '-fconcepts'). Use MATCHES "Clang",
  as in #6816 on main.

GCC gets exactly the same flags as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Dhruv Patel <[email protected]>

---------

Signed-off-by: Dhruv Patel <[email protected]>
Signed-off-by: Michal Sojka <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Michal Sojka <[email protected]>
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.

5 participants