Skip to content

Fix(macOS): Use Mach Precedence Policy for Soft Real-Time Thread Priority and std::chrono::duration Casting Error - #5679

Merged
SteveMacenski merged 6 commits into
ros-navigation:mainfrom
idesign0:main
Nov 20, 2025
Merged

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

Conversation

@idesign0

@idesign0 idesign0 commented Nov 11, 2025 •

Copy link
Copy Markdown
Contributor

This PR introduces the necessary platform-specific implementation for thread prioritization within nav2_util::setSoftRealTimePriority() for macOS systems.

Context

macOS does not support the standard POSIX real-time scheduling policies (SCHED_FIFO or SCHED_RR) for user-level threads, which are relied upon in the existing Linux (#else) implementation. When running on macOS, This resulted in a compilation error (e.g., "undeclared identifier") on macOS, completely blocking the build process for the package.

Solution

The code is updated within the #ifdef __APPLE__ block to use the native Mach kernel API, which is the correct and most effective method for this platform:

  1. Policy: Uses the Mach kernel's THREAD_PRECEDENCE_POLICY, setting the importance to the maximum value (63). This achieves the highest available user-space priority, fulfilling the requirement for soft real-time performance on macOS.
  2. Diagnostics: The error handling is significantly improved to aid in debugging. It now includes the header <mach/error.h> and uses the function mach_error_string() to provide a human-readable description of the kern_return_t error code if the policy fails to set.

Files Changed

  • nav2_util/src/node_utils.cpp

Fix: std::chrono::duration Casting Error

This resolves a strict type conversion error specific to Clang/libc++ on macOS builds.

Problem:
The Tree::sleep() function expects a std::chrono::microseconds duration (or system_clock::duration), but the calling code provides a higher-resolution std::chrono::nanoseconds duration (time_to_sleep_ns). The macOS compiler rejects this implicit conversion due to potential data loss (truncation).

Solution:
Added an explicit std::chrono::duration_cast<std::chrono::microseconds>() wrapper to explicitly convert the nanosecond duration before passing it to tree_->sleep(), resolving the compilation error.

Files Changed:

  • nav2_behavior_tree/include/nav2_behavior_tree/utils/loop_rate.hpp

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

codecov Bot commented Nov 11, 2025 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.13858% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...clude/nav2_behavior_tree/bt_action_server_impl.hpp 60.00% 4 Missing ⚠️
...2_bt_navigator/src/navigators/navigate_to_pose.cpp 63.63% 4 Missing ⚠️
...avigator/src/navigators/navigate_through_poses.cpp 76.92% 3 Missing ⚠️
nav2_mppi_controller/src/optimizer.cpp 62.50% 3 Missing ⚠️
..._pure_pursuit_controller/src/collision_checker.cpp 0.00% 3 Missing ⚠️
...llowing/opennav_following/src/following_server.cpp 60.00% 2 Missing ⚠️
...ree/plugins/condition/are_poses_near_condition.cpp 0.00% 1 Missing ⚠️
...nclude/nav2_behaviors/plugins/drive_on_heading.hpp 0.00% 1 Missing ⚠️
...tmap_2d/plugins/costmap_filters/keepout_filter.cpp 50.00% 1 Missing ⚠️
nav2_costmap_2d/plugins/static_layer.cpp 0.00% 1 Missing ⚠️
... and 6 more
Files with missing lines Coverage Δ
nav2_amcl/src/amcl_node.cpp 86.31% <100.00%> (ø)
nav2_amcl/src/map/map_cspace.cpp 90.76% <100.00%> (+0.14%) ⬆️
...nclude/nav2_behavior_tree/behavior_tree_engine.hpp 100.00% <ø> (ø)
...ree/plugins/action/compute_path_to_pose_action.hpp 100.00% <ø> (ø)
...avior_tree/plugins/action/compute_route_action.hpp 100.00% <100.00%> (ø)
...lugins/action/remove_in_collision_goals_action.hpp 100.00% <100.00%> (ø)
...tree/plugins/action/remove_passed_goals_action.hpp 100.00% <100.00%> (ø)
...tree/plugins/condition/is_path_valid_condition.hpp 100.00% <100.00%> (ø)
...e/plugins/condition/is_pose_occupied_condition.hpp 100.00% <100.00%> (ø)
...or_tree/plugins/condition/is_stopped_condition.hpp 100.00% <100.00%> (ø)
... and 88 more

... and 10 files with indirect coverage changes

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

@idesign0 idesign0 changed the title Fix(macOS): Use Mach Precedence Policy for Soft Real-Time Thread Priority Fix(macOS): Use Mach Precedence Policy for Soft Real-Time Thread Priority and std::chrono::duration Casting Error Nov 14, 2025
Signed-off-by: Dhruv Patel <[email protected]>

@SteveMacenski SteveMacenski left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woah - this is now a 1000 line PR and its broken a few linting rules. Checkout the CI failed job. Otherwise I approve.

@idesign0

Copy link
Copy Markdown
Contributor Author

Woah - this is now a 1000 line PR and its broken a few linting rules. Checkout the CI failed job

i ran pre-commit to all the files. 😅

@SteveMacenski

SteveMacenski commented Nov 19, 2025 •

Copy link
Copy Markdown
Member

Alot of these changes look correct, I'm confused why they weren't flagged before. I've been noticing for months now that some parts of the linting profile aren't being flagged correctly. It seems like a change in the ament linting rules or something that I don't understand. If you have any ideas, I'd love to hear it. I've looked into it before and didn't come up with anything

Edit: So I'd say just fix the few things it flags as wrong and leave the rest. thanks for the service 🫡

@idesign0

Copy link
Copy Markdown
Contributor Author

Alot of these changes look correct, I'm confused why they weren't flagged before. I've been noticing for months now that some parts of the linting profile aren't being flagged correctly. It seems like a change in the ament linting rules or something that I don't understand. If you have any ideas, I'd love to hear it. I've looked into it before and didn't come up with anything

Edit: So I'd say just fix the few things it flags as wrong and leave the rest. thanks for the service 🫡

here we go! 😇

@SteveMacenski

Copy link
Copy Markdown
Member

Just waiting on CI

@mergify

mergify Bot commented Nov 19, 2025

Copy link
Copy Markdown
Contributor

@idesign0, your PR has failed to build. Please check CI outputs and resolve issues.
You may need to rebase or pull in main due to API changes (or your contribution genuinely fails).

@ros-navigation ros-navigation deleted a comment from mergify Bot Nov 20, 2025
@ros-navigation ros-navigation deleted a comment from mergify Bot Nov 20, 2025
@SteveMacenski
SteveMacenski merged commit 2f741fd into ros-navigation:main Nov 20, 2025
decwest pushed a commit to decwest/navigation2 that referenced this pull request Dec 10, 2025
…rity and std::chrono::duration Casting Error (ros-navigation#5679)

* Fix(macOS): Use Mach Precedence Policy for Soft Real-Time Thread Priority

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

* precommit checks

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

* Fix: Use explicit cast to microseconds for sleep in LoopRate

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

* Use of THREAD_TIME_CONSTRAINT_POLICY in setSoftRealTimePriority()

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

* Pre-Commit Changes

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

* Pre-commits: ament_uncrustify fixes

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
…rity and std::chrono::duration Casting Error (ros-navigation#5679)

* Fix(macOS): Use Mach Precedence Policy for Soft Real-Time Thread Priority

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

* precommit checks

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

* Fix: Use explicit cast to microseconds for sleep in LoopRate

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

* Use of THREAD_TIME_CONSTRAINT_POLICY in setSoftRealTimePriority()

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

* Pre-Commit Changes

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

* Pre-commits: ament_uncrustify fixes

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

---------

Signed-off-by: Dhruv Patel <[email protected]>
@mini-1235 mini-1235 mentioned this pull request Jan 5, 2026
8 tasks
@idesign0

Copy link
Copy Markdown
Contributor Author

Could this be backported to jazzy? Jazzy still doesn't build on macOS without it (nav2_util/src/node_utils.cpp).

@jwallace42

Copy link
Copy Markdown
Contributor

Could this be backported to jazzy? Jazzy still doesn't build on macOS without it (nav2_util/src/node_utils.cpp).

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.

3 participants