Skip to content

OMPL and Qt API update, bump cmake minimum version requirement - #6136

Merged
SteveMacenski merged 29 commits into
ros-navigation:mainfrom
mini-1235:lyrical/sync
Jul 15, 2026
Merged

SteveMacenski merged 29 commits into
ros-navigation:mainfrom
mini-1235:lyrical/sync

Conversation

@mini-1235

Copy link
Copy Markdown
Collaborator

Basic Info

Info Please fill out this column
Ticket(s) this addresses Lyrical Sync
Primary OS tested on (Ubuntu, MacOS, Windows)
Robotic platform tested on (Steve's Robot, gazebo simulation of Tally, hardware turtlebot)
Does this PR contain AI generated software? (No; Yes and it is marked inline in the code)
Was this PR description generated by AI software? Out of respect for maintainers, AI for human-to-human communications are banned

Description of contribution in a few bullet points

Description of documentation updates required from your changes

Description of how this change was tested


Future work that may be required in bullet points

For Maintainers:

  • Check that any new parameters added are updated in docs.nav2.org
  • Check that any significant change is added to the migration guide
  • Check that any new features OR changes to existing behaviors are reflected in the tuning guide
  • Check that any new functions have Doxygen added
  • Check that any new features have test coverage
  • Check that any new plugins is added to the plugins page
  • If BT Node, Additionally: add to BT's XML index of nodes for groot, BT package's readme table, and BT library lists
  • Should this be backported to current distributions? If so, tag with backport-*.

Signed-off-by: Maurice Alexander Purnawan <[email protected]>
Signed-off-by: Maurice Alexander Purnawan <[email protected]>
Temporarily comment this out

Signed-off-by: Maurice Alexander Purnawan <[email protected]>
Signed-off-by: Maurice Alexander Purnawan <[email protected]>
Pin ros2/rviz to version 2cbba6bbeb32 to avoid Qt5 and Qt6 mismatch.

Signed-off-by: Maurice Alexander Purnawan <[email protected]>
Signed-off-by: mini-1235 <[email protected]>
@mini-1235

mini-1235 commented May 9, 2026 •

Copy link
Copy Markdown
Collaborator Author

I figured out that the EventsExecutor wasn't included in the last rolling sync, but we do have it in Lyrical, so it seems easier for me to test it in Lyrical :)

This PR fixes all the compile errors but is not ready to review/merge, I am opening as draft to check the backward compatibility for Jazzy/Kilted. It also depends on ros2/message_filters#292, ros/rosdistro#51321, BehaviorTree/BehaviorTree.CPP#1139, and an upstream OMPL sync, we should probably merge this after we migrate to Ubuntu 26.04 (most fixes here are related to 26.04 using g++15)

@mini-1235
mini-1235 marked this pull request as draft May 9, 2026 19:41
Comment thread nav2_rviz_plugins/src/docking_panel.cpp Resolved
Comment thread nav2_rviz_plugins/src/nav2_panel.cpp Resolved
Comment thread nav2_amcl/CMakeLists.txt Resolved
@mergify

mergify Bot commented May 24, 2026

Copy link
Copy Markdown
Contributor

This pull request is in conflict. Could you fix it @mini-1235?

Comment thread nav2_simple_commander/setup.py Resolved
Comment thread nav2_collision_monitor/src/polygon.cpp Resolved
mini-1235 added 2 commits May 24, 2026 12:41
Signed-off-by: mini-1235 <[email protected]>
Signed-off-by: mini-1235 <[email protected]>
@codecov

codecov Bot commented May 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.35714% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
nav2_waypoint_follower/src/waypoint_follower.cpp 16.66% 5 Missing ⚠️
nav2_behaviors/plugins/spin.cpp 25.00% 3 Missing ⚠️
...nclude/nav2_behaviors/plugins/drive_on_heading.hpp 66.66% 2 Missing ⚠️
nav2_behaviors/plugins/back_up.cpp 50.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
...ehavior_tree/plugins/action/follow_path_action.cpp 94.11% <100.00%> (ø)
...ehaviors/include/nav2_behaviors/timed_behavior.hpp 92.47% <100.00%> (ø)
nav2_collision_monitor/src/circle.cpp 95.00% <100.00%> (ø)
nav2_collision_monitor/src/polygon.cpp 96.98% <100.00%> (ø)
...d/include/nav2_costmap_2d/footprint_subscriber.hpp 100.00% <ø> (ø)
...map_2d/include/nav2_costmap_2d/layered_costmap.hpp 100.00% <100.00%> (ø)
nav2_costmap_2d/plugins/obstacle_layer.cpp 81.62% <100.00%> (-0.55%) ⬇️
nav2_costmap_2d/src/footprint_subscriber.cpp 100.00% <100.00%> (ø)
nav2_costmap_2d/src/layered_costmap.cpp 96.61% <ø> (ø)
...av2_docking/opennav_docking/src/docking_server.cpp 89.48% <100.00%> (ø)
... and 9 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.

@mini-1235

Copy link
Copy Markdown
Collaborator Author

Executor Performance Report.docx
Diff
diff_executor
Event
eventexecutor
Singlethreaded
singlethreaded

I finally found some time to generate those flamegraphs today. To speed things up, I had AI put together a quick summary report. I did a scan through it, and for the most part, the findings look pretty reasonable to me.

The report also digs into the lifecycle_manager. We definitely see some performance gains there, but if you look closely at the flamegraph, it is still eating up a massive chunk of the CPU (compared to other components like the controller_server or planner_server).

Also, like we discussed on slack earlier, if you download the EventsCBGExecutor flamegraph and search for "singlethreaded", you will still see it popping up all over the place. I suspect we are going to see another massive performance once absolutely everything is switched over to the event executor, but waiting for the ros2 core repos to merge those updates first

@mini-1235 mini-1235 mentioned this pull request Jun 2, 2026
3 tasks done
@SteveMacenski

SteveMacenski commented Jun 3, 2026 •

Copy link
Copy Markdown
Member

My apologies for the delay. Saying I've simply been overwhelmed would be a misuse of the word.

Can you summarize for me the actions or what you think should happen from the flamegraph? I'm reading from your phrasing you think some things still need to change so I'm not clear if this is ready or not (seems like there's some places the wrong executor is being used still?).

Wrt the report: I see that it reduces CPU cycles, but what's the actual % improvement in terms of stable-runtime performance? As your report mentions, CPU cycles doesn't mean the % changes and the % is important to understand.

lifecycle_manager does not need fast failure detection for most deployments

I disagree with this, we need fast detection failure for all deployments. Rather than simply reducing the rate, I think we should fix it (which AI may well help with) in code changes or in how its run (i.e. executor, in another process, etc).

Running it as a standalone node eliminates cross-node lock contention

Have you shown this is actually true? I would be open to moving that to another process if that's the case. I question though if AI is properly diagnosing this though. If this solves it, that seems easy enough.

@mini-1235

Copy link
Copy Markdown
Collaborator Author

No worries, I marked this as draft because of the blocking issues I mentioned in the lyrical release ticket. I am also very busy at the moment, feel free to review now or wait until everything is ready :)

I'm reading from your phrasing you think some things still need to change so I'm not clear if this is ready or not (seems like there's some places the wrong executor is being used still?).

I thought your preference was to use SingleThreadedExecutor in the code until the ros2 team tests and agrees to switch everything to EventsExecutor by default. I also have a branch here mini-1235@d779849. Did you change your mind? For context we discussed this on Slack:

Stress testing and finding things like this is important so we could in the future do that, but I agree we shouldn't make it default yet. I'm also not sure if its worth making the default anytime soon either if the improvement in performance isn't > 1%. I had expected like 10% or more back from this change (since a non-trivial amount of our overhead in Nav2 is actually ROS 2 by itself)

Can you summarize for me the actions or what you think should happen from the flamegraph?

Could you take a quick look at the lifecycle manager flamegraph/report and let me know if you are satisfied with the improvement (and the potential improvement once everything switches to EventsExecutor)? If you are not satisfied with the current results, then my proposal in #6061 is probably in the wrong direction, and we will need to think of some alternative approaches

but what's the actual % improvement in terms of stable-runtime performance?

When you ask about % improvement, do you mean total CPU usage? I have been measuring with btop before and after, and it's around 1% as I mentioned on Slack(my CPU is much faster than typical onboard computers, so I would still consider the improvement meaningful)

I disagree with this, we need fast detection failure for all deployments. Rather than simply reducing the rate, I think we should fix it (which AI may well help with) in code changes or in how its run (i.e. executor, in another process, etc).

Have you shown this is actually true? I would be open to moving that to another process if that's the case. I question though if AI is properly diagnosing this though. If this solves it, that seems easy enough.

I would ignore the AI-generated solutions in there, I didn't have time to polish the report. I generated the data by hand and had AI summarize it just to give you a rough before vs after picture.

@GYKrauss

GYKrauss commented Jun 4, 2026 •

Copy link
Copy Markdown

It is not building for me...

Base docker image - "osrf/ros:lyrical-desktop-full" - June 1st 2026

FROM osrf/ros@sha256:e2850b225534d1c9b9f511a1d19ce45bbd632a4711a7f74ef4c466c808fdb909 AS base

Relevant dockerfile snippet

WORKDIR /opt/nav2_ws
ARG nav2_setup_bash=/opt/nav2_ws/install/setup.bash
RUN mkdir -p /opt/nav2_ws/src &&
git clone -b lyrical/sync https://github.com/mini-1235/navigation2.git ./src/navigation2 &&
apt-get update -y &&
apt-get install -y libompl-dev &&
rosdep update &&
rosdep install -r -y --from-paths ./src/navigation2 --ignore-src --skip-keys="ompl" &&
source /opt/ros/${ros_distro}/setup.bash &&
colcon build --symlink-instal

Error:
11:48:27 --- stderr: nav2_behavior_tree
11:48:27 In file included from /opt/nav2_ws/src/navigation2/nav2_behavior_tree/src/behavior_tree_engine.cpp:27:
11:48:27 /opt/nav2_ws/src/navigation2/nav2_behavior_tree/include/nav2_behavior_tree/utils/loop_rate.hpp: In member function ‘bool nav2_behavior_tree::LoopRate::sleep()’:
11:48:27 /opt/nav2_ws/src/navigation2/nav2_behavior_tree/include/nav2_behavior_tree/utils/loop_rate.hpp:64:27: error: ‘class BT::Tree’ has no member named ‘wakeUpSignal’; did you mean ‘emitWakeUpSignal’?
11:48:27 64 | auto wake_up = tree_->wakeUpSignal();
11:48:27 | ^~~~~~~~~~~~
11:48:27 | emitWakeUpSignal
11:48:27 gmake[2]: *** [CMakeFiles/nav2_behavior_tree.dir/build.make:79: CMakeFiles/nav2_behavior_tree.dir/src/behavior_tree_engine.cpp.o] Error 1
11:48:27 gmake[1]: *** [CMakeFiles/Makefile2:722: CMakeFiles/nav2_behavior_tree.dir/all] Error 2
11:48:27 gmake[1]: *** Waiting for unfinished jobs....
11:48:27 gmake: *** [Makefile:146: all] Error 2
11:48:27 ---
11:48:27 Failed <<< nav2_behavior_tree [18.0s, exited with code 2]

@mini-1235

Copy link
Copy Markdown
Collaborator Author

Check the blockers I listed earlier, you might need to build some packages from source before a lyrical sync happens

@GYKrauss

GYKrauss commented Jun 4, 2026 •

Copy link
Copy Markdown

OK... just needed one more line - building BT from source and it all built on the lyrical image.
WORKDIR /opt/nav2_ws
ARG nav2_setup_bash=/opt/nav2_ws/install/setup.bash
RUN mkdir -p /opt/nav2_ws/src && \
git clone -b lyrical/sync https://github.com/mini-1235/navigation2.git ./src/navigation2 && \
git clone -b master https://github.com/BehaviorTree/BehaviorTree.CPP.git ./src/BehaviorTree.CPP && \
apt-get update -y && \
apt-get install -y libompl-dev && \
rosdep update && \
rosdep install -r -y --from-paths ./src --ignore-src --skip-keys="ompl" && \
source /opt/ros/${ros_distro}/setup.bash && \
colcon build --symlink-install

@SteveMacenski

SteveMacenski commented Jun 4, 2026 •

Copy link
Copy Markdown
Member

I thought your preference was to use SingleThreadedExecutor in the code until the ros2 team tests and agrees to switch everything to EventsExecutor by default. I also have a branch here mini-1235@d779849. Did you change your mind? For context we discussed this on Slack:

I don't think we need to wait for the ROS team to make it default, but I would want to see testing that this works reliably and has a measurable performance improvement. Once we change it though, we can/should change it everywhere else too including the BT nodes and others you've mentioned in that branch. I think its an all-at-once thing so we can have consistent behavior across the board.

When you ask about % improvement, do you mean total CPU usage? I have been measuring with btop before and after, and it's around 1% as I mentioned on Slack(my CPU is much faster than typical onboard computers, so I would still consider the improvement meaningful)

Yes, this is what I mean. And OK - its just not listed here anywhere and I've forgotten the context in Slack after this long :-)


Could you take a quick look at the lifecycle manager flamegraph/report and let me know if you are satisfied with the improvement (and the potential improvement once everything switches to EventsExecutor)? If you are not satisfied with the current results, then my proposal in #6061 is probably in the wrong direction, and we will need to think of some alternative approaches

This is what I'm not understanding. There's some potential plans, ideas, and options, but I'm not seeing a recommendation or what works and the analysis to show the impact. As you pointed out in the report, just having a large reduction in CPU cycles is not eq. to having a change in resource utilization. Not to say reducing cycles is bad, but if you're saying that the lifecycle manager is taking a ridiculous amount of compute %, then we should also be measuring CPU % of changes to know if they make an impact on the actual problem.

I suspect you actually did a bunch of testing off those ideas and options and have a conclusion that perhaps I'm just missing or maybe you didn't communicate it yet. I might just be tired and missing something obvious between all of these sources. I am starting tomorrow able to get back into normal hours so my thought process will be alot less clouded, but I'm feeling like I'm missing some key details to make decisions or help answer your concerns.

Can you be specific and let me know what you changed, tested, and measured -- or concisely what you are trying to get from me that I'm not giving & the context for that in one post? 😆 It seems like we're talking about the new executor for use in Nav2 as well as fixes for the lifecycle manager taking too much compute for what it rightfully does.

I don't see a proposal in #6061 that you're referring to 🙃 There's just a flamegraph without context or comparison, so I'm not sure what to make of it honestly in isolation, i.e.:

I wonder if the CPU usage can be largely reduced here after switching to the new EventExecutor in Lyrical

Did you get to testing and that made the difference to fix the lifecycle manager high compute problem with the current bond rate?

@mini-1235

Copy link
Copy Markdown
Collaborator Author

I don't think we need to wait for the ROS team to make it default, but I would want to see testing that this works reliably and has a measurable performance improvement. Once we change it though, we can/should change it everywhere else too including the BT nodes and others you've mentioned in that branch. I think its an all-at-once thing so we can have consistent behavior across the board.

My previous testing shows it is pretty much stable (the rviz bug I mentioned is hard to reproduce and I am not even sure it is related to the new executor). I think real robot testing would be more reliable here, and that is probably not something I can lead, do you know anyone who might be interested? And should I cherry-pick the commit here?

I don't see a proposal in #6061 that you're referring to 🙃 There's just a flamegraph without context or comparison, so I'm not sure what to make of it honestly in isolation, i.e.:

Yeah that is more of an idea than a proposal. My initial assumption was that "switching to EventExecutor could bring a big reduction in lifecycle manager CPU usage", but from my preliminary testing that doesn't seem to be the case. Based on the flamegraphs, there is some improvement, but it is not that obvious. Right now we are also in a mixed state where SingleThreadedExecutor and EventExecutor are both used in lifecycle manager, I suspect even if we unified everything under EventExecutor (by modifying rclcpp/bond code), it wouldn't bring much more improvement based on what the flamegraphs are showing(but worth testing).

Another thing I want to note: from the flamegraph, lifecycle manager is taking roughly 3-6x more CPU than the other individual components. If the goal is to get it closer to the same level as other components, that feels like it might need more fundamental changes beyond just switching the executor

So my current take on #6061: there is some benefit, but probably not enough to be obvious. I would love to hear your thoughts as well before I do more testing, like, what kind of reduction would you want to see to consider this worthwhile?

Next steps on my end would be to switch bond/rclcpp to EventExecutor as well and remeasure, then see if there is room to optimize further on the hottest paths. But realistically that can only happen around August/September when I am back home

@mini-1235

Copy link
Copy Markdown
Collaborator Author

f5f77ad is related to recent updates in ament/ament_index#120

@mini-1235
mini-1235 marked this pull request as ready for review July 15, 2026 10:09
@mergify

mergify Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@SteveMacenski

Copy link
Copy Markdown
Member

Merge as you see fit

@mini-1235

Copy link
Copy Markdown
Collaborator Author

CI fails to compile, but I have never seen that error and I am not able to reproduce it locally. I will investigate tomorrow

@SteveMacenski

SteveMacenski commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

@mini-1235 change

to push_back(0);. I can't seem to push to your branch directly to do it. Its not a real bug but a known bug in the compiler

@mini-1235

Copy link
Copy Markdown
Collaborator Author

@mini-1235 change

to push_back(0);. I can't seem to push to your branch directly to do it. Its not a real bug but a known bug in the compiler

Maybe because we are pushing at the same time?😄 I am going to sleep now, will fix again tomorrow if it is not green

Added a check for num_of_nearest_nodes_ before performing nearest node search.

Signed-off-by: Steve Macenski <[email protected]>
@SteveMacenski

Copy link
Copy Markdown
Member

I had to fix another case, but building now. WIll merge once tests run and retrigger the docker build

@SteveMacenski
SteveMacenski merged commit 7e382cb into ros-navigation:main Jul 15, 2026
12 checks passed
@mini-1235

Copy link
Copy Markdown
Collaborator Author

It seems like this PR and #6118 introduce some failures in the test, I try to fix it here: #6271

aki1770-del added a commit to aki1770-del/navigation2 that referenced this pull request Aug 8, 2026
Two small drifts this branch had picked up against main:

- Link std_msgs::std_msgs directly. After ros-navigation#6136 replaced the rest,
  ${std_msgs_TARGETS} here was the only remaining use in the repo, and
  binary_filter_test seven lines above already links the target
  directly. Linkage is unchanged.

- Build the test's transform buffer with nav2::create_transform_buffer
  rather than constructing tf2_ros::Buffer by hand, matching the speed,
  keepout and binary filter tests after ros-navigation#6281. This also gives the test
  the timer interface the factory installs. Two includes left unused by
  the change are dropped.

Signed-off-by: Akihiko Komada <[email protected]>
SteveMacenski added a commit that referenced this pull request Aug 10, 2026
…rameter overrides (#6104)

* WIP: ZoneParameterFilter — plugin scaffold + test scaffold (slice 1, ~80%)

Slice 1 of nav2#6080 implementation per the source-read milestone-1
artifact at outputs/sprint_131/nav2_6080_source_read.md.

Architecture per Steve Macenski's 2026-04-13 design guidance:
- Mask values 0..255; value 0 = reset to nominal defaults
- Each non-zero state mapped via YAML config to a list of ROS
  parameters (any reachable nav2 parameter on any node)
- No custom enums; raw int + config-driven semantics
- Async parameter setting via per-target-node AsyncParametersClient
  (Steve's preferred pattern from PR #3796 first review)
- Optional state-transition event publication
- Configurable warn|throw policies for unknown-state and
  param-set-failure

PR #3796 burn-pattern guards baked in:
- No wait_for_service in hot path (issue 2): service_is_ready()
  predicate; skip-with-throttled-warn on not-ready
- No empty-string sentinels (issue 4): std::map presence checks
- Future lifetime managed (issue 5): pending_futures_ vector
  drained at top of every process() call; never destruct mid-flight
- Per-node async client (Steve's first review point): one
  AsyncParametersClient per target node, batched parameter sets

Files added:
- nav2_costmap_2d/include/nav2_costmap_2d/costmap_filters/
    zone_parameter_filter.hpp
- nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp
- nav2_costmap_2d/test/unit/zone_parameter_filter_test.cpp

Files edited:
- filter_values.hpp: added ZONE_PARAMETER_FILTER = 4 constant
- costmap_plugins.xml: registered new plugin in filters library
- CMakeLists.txt: added zone_parameter_filter.cpp to filters target
- test/unit/CMakeLists.txt: added zone_parameter_filter_test target

Confidence assessment for slice 1 target (80% today):
- Architectural skeleton complete and follows nav2 conventions
- Source-read evidence cited for every #3796 fix
- All cross-file wiring (XML, CMake, header, impl) in place
- Test scaffold exercises the type-constant and construction paths
- 5/11 test cases from §5 implementation plan present (or as
  documented placeholders); remaining 6 deferred to slice 2 (95%)
- Build verification deferred: no ROS 2 env on this machine; CI
  build is the next gate

Slice 2 (95% target tomorrow) needs:
- colcon build green on humble + jazzy
- Remaining 6 unit tests with full ROS 2 mock harness
- AsyncParametersClient mock for param-mutation assertions
- Coverage measurement (lcov ≥90% per #3796 retrospective)
- File-level review of PR #3796 diff (read summary, not the diff
  itself yet)

Not for PR open — feature branch only. Per D-VGC148, all PR
prose is Komada-authored at PR-open time. Per the commit-or-close
clause to Steve, PR open is committed by 2026-05-16.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): uncrustify lint nits (Path C build verification round 1)

Three style fixes per ament_uncrustify on rolling:

1. plugins/costmap_filters/zone_parameter_filter.cpp:60-61 — split a
   140-char declare_or_get_parameter call across two lines.
2. plugins/costmap_filters/zone_parameter_filter.cpp:138-140 — same
   for an RCLCPP_ERROR call.
3. test/unit/zone_parameter_filter_test.cpp:72,89 — convert
   single-line destructors to multi-line bodies (matches binary_filter_test
   pattern).

Verification context: Path C source-build in ros:rolling docker
container compiled the package cleanly and ran 4/4 of our new
gtest cases. The 3 failures in the 399-test suite were all
uncrustify diffs on these lines — zero correctness regressions.
This commit closes the lint gates.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* test(zone_parameter_filter): add TestZpf lifecycle fixture + first real test (slice 2a)

Adds a gtest fixture mirroring binary_filter_test.cpp's TestNode pattern,
adapted for ZoneParameterFilter's parameter-mutation semantics:

- TargetNode helper — minimal rclcpp::Node with declared parameters that
  ZPF will mutate via AsyncParametersClient
- TestZpf fixture — LifecycleNode host + separate executors + helpers for
  filter creation, process() invocation, and predicate-based wait
- State1AppliesParameterToTargetNode — first real lifecycle test:
  state_ids=[1] + state_1.zpf_target_node.speed=0.5 fed via
  parameter_overrides; mask filled with 1; pose at center cell;
  process() triggers state 0→1 transition; async set_parameters
  propagates to target node within 1.5s timeout; asserts speed=0.5,
  inflation untouched

Verified on rolling (docker nav2:dev): 5/5 tests pass in 150ms total
(4 scaffold + 1 new lifecycle), zero build warnings, zero test failures.

Slice 2a complete; remaining slice-2b items per scaffold TODO list:
state_zero_resets, unknown_state_warn/throw, state_event_published,
service_not_ready_in_hot_path_does_not_block, etc.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* test(zone_parameter_filter): add 3 lifecycle cases + #3796 regression test (slice 2b)

Extends TestZpf fixture with StateEventSubscriber + rePublishMask helper,
plus three live cases covering distinct ZPF code paths:

- UnknownStateWarnLogsAndKeepsPrevious — exercises on_unknown_state="warn"
  policy: a mask value not in the configured state map must log a
  throttled warn and leave all target parameters unchanged.

- StateEventPublishedOnTransition — exercises optional state_event_pub_:
  when state_event_topic is configured, every transition publishes a
  UInt8 carrying the new state value. Verified via a separate
  StateEventSubscriber on the same in-process executor.

- ServiceNotReadyInHotPathDoesNotBlock — REGRESSION TEST FOR PR #3796
  review item 2 (Steve Macenski + Alexey Merzlyakov, 2023-09 to
  2023-12). When a target node's parameter service is not ready, ZPF
  must NOT call wait_for_service in process(); it must log a throttled
  warn via service_is_ready() and return promptly. Test routes a
  state-1 override at a nonexistent_node and asserts process() returns
  in <500ms (a wait_for_service regression would hang for seconds).

Plus one documented-failure case kept under DISABLED_ prefix:

- DISABLED_State0ResetsToNominalDefaults — surfaces a v0.1 limitation
  in zone_parameter_filter.cpp:383 where nominal_defaults_ stores an
  empty ParameterValue instead of the target's pre-override value.
  resetToNominal() therefore pushes NOT_SET and silently no-ops.
  Proper fix (slice 2c) is to synchronously fetch nominal values at
  initializeFilter() time via spin_until_future_complete with short
  timeout — permitted blocking outside the hot path.

Cosmetic: InfoPublisher now passes multiplier=1.0 (was 0.0) to silence
the "base/multiplier are unused; expected defaults (0.0, 1.0)" warning
emitted by ZPF on filter-info receipt.

Verified on rolling (nav2:dev container, incremental build 22s):
8/8 enabled tests pass in 611ms total. 1 disabled documented as design
intent pending slice 2c fix.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): YAML-declared nominal_defaults for state-0 reset (slice 2c)

Slice 2b's State0ResetsToNominalDefaults test surfaced a real v0.1 bug:
applyState() inserted an empty `ParameterValue` (NOT_SET type) as a
nominal-default sentinel, then resetToNominal() pushed that empty value
back to the target on state-0 transition — silent no-op, override never
restored. Steve Macenski's #6080 design pointer specifically called out
state-0 reset semantics, so leaving this broken was not an option.

Initial fix candidate was async get-before-set: fire get_parameters then
set_parameters on the same AsyncParametersClient, relying on FIFO to
capture the pre-override value in the get response. Discarded after
inspection: get_parameters and set_parameters use SEPARATE underlying
services::Client instances, so server-side processing order between them
is not guaranteed. A late get response would capture the OVERRIDDEN
value, not the nominal — a worse failure mode than the silent no-op.

Adopted: declarative YAML nominal_defaults. Schema:

  <plugin>.nominal_defaults.<target_node>.<param_path>: <value>

Parsed at loadStateConfig() time (configure phase, blocking permitted).
Race-free, deterministic, zero runtime cost. Matches Steve's "config-
driven" preference verbatim.

Quality-of-life: warn at config-load time for any state-N parameter that
has no matching nominal_defaults entry — such params will not be
restored by state-0 reset, and a v1 user almost certainly wants symmetric
coverage.

Test re-enabled (DISABLED_State0ResetsToNominalDefaults → enabled),
extended to provide the explicit nominal_defaults override. All 9
TestZpf cases pass on rolling (nav2:dev, incremental build 58s):

  State1AppliesParameterToTargetNode      ✅ 162ms
  State0ResetsToNominalDefaults           ✅ 268ms (slice 2c verified)
  UnknownStateWarnLogsAndKeepsPrevious    ✅ 327ms
  StateEventPublishedOnTransition         ✅ 149ms
  ServiceNotReadyInHotPathDoesNotBlock    ✅ 130ms

  Total: 9/9 in 1038ms, 0 disabled, 0 failures.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): apply CI lint feedback (codespell + uncrustify)

PR #6104 lint workflow surfaced two issues:

- codespell (in pre-commit): flagged "lets" in a comment on
  loadStateConfig (the colon-separator routing comment) as
  potentially "let's". The original word was correct ("permits"
  meaning), but rewording to "routes" preserves the same intent
  while avoiding the false-positive trigger.

- ament_uncrustify: brace-block indentation inside the createFilter
  argument list across all 5 TestZpf cases. Auto-reformatted via
  ament_uncrustify --reformat; 11/11 line shifts.

No functional change. Local verification on rolling (nav2:dev):
ament_uncrustify clean across all 3 ZPF files; 9/9 tests pass in
965ms.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): explicit target_nodes + 4 audit-driven tests

Addresses findings from a 4-agent swarm audit on PR #6104 (synthesis at
sky/outputs/nav2_6104_pr_audit/synthesis.md):

- F-4 schema: introduce a required `target_nodes: [a, b, ...]` YAML
  parameter and replace first-dot-split parsing with longest-prefix-match
  against the explicit list. The original first-dot-split happens to be
  correct for typical nav2 usage (ROS doesn't allow dots in node names),
  but the explicit list is unambiguous, self-documenting, catches typos
  at config-load, and future-proofs against schema drift.

- F-9 ResetFilterDeactivates: verify resetFilter() clears
  filter_info_received_ and filter_mask_ so isActive() returns false.
  Mirrors binary_filter_test.cpp::testResetFilter.

- F-10 UnknownMaskCellLeavesStateUnchanged: mask filled with
  OCC_GRID_UNKNOWN (-1); verify process() leaves current_state_ + the
  target's parameter untouched. Guards the negative-mask-data branch
  in process().

- F-11 RobotOutsideMaskResetsToState0: drive into state 1, then call
  process() with a pose far outside mask bounds. Verify the state
  auto-resets to 0 and nominal_defaults are restored. Guards the
  worldToMap()-failure branch in process().

- F-4 regression test (LongestPrefixMatchForOverlappingTargetNodes):
  with target_nodes = ["zpf", "zpf_target_node"] and an override
  state_1.zpf_target_node.speed=0.7, verify the longer prefix wins so
  the parameter actually lands on the live target node. A regression
  to naive shortest-prefix would route to the bogus "zpf" service
  and the value would never land.

Verified on rolling (nav2:dev): 13/13 tests pass in 1365ms. Local
ament_uncrustify + ament_cpplint clean.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: always throw on unknown mask state

Removes the on_unknown_state parameter and the paired UnknownStatePolicy
enum. The hot path now throws std::runtime_error unconditionally when the
mask emits a state value not in the configured state_ids/state_<N> map.

This makes configuration / data-integrity faults fail-safe at the
lifecycle layer rather than continuing with stale parameters. ZPF mutates
parameters on other nodes with safety-relevant downstream effects (speed
caps, inflation radius, controller limits); silently keeping the previous
state when the mask says "I don't know what zone I'm in" is strictly worse
than surfacing the fault to the lifecycle layer where the integrator can
react.

The throw fires at the state_param_map_.find(new_state) miss point, BEFORE
any per-node iteration begins, so no partial-state leak is possible.
Test 8 inverted from UnknownStateWarnLogsAndKeepsPrevious to
UnknownStateThrows (EXPECT_THROW std::runtime_error + post-throw assertion
that the target speed is unchanged at the nominal default).

Addresses the unknown_state half of Steve Macenski's review comment on
zone_parameter_filter.cpp:95 ("Always throw, this is a critical issue
the robot should stop for"). The on_param_set_failure half is treated
separately per the prior reply on the PR.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: scrub TMI comments

Steve Macenski review on PR #6104: top-level "There's a lot of AI generated
TMI comments throughout the code that should be removed or reduced", plus
inline pins on hpp:101, cpp:78, costmap_plugins.xml:40.

Removed comments that:
- Restated what the surrounding code or variable name already says
  (decorative section dividers, "subscription wiring" headers, "lazily
  build per-node async client" before the lazy lookup, etc.)
- Cited prior reviews back at the reviewer (#3796 references, "Steve's
  preference", "Per #3796 review item N")
- Cited foreign-PR context the reader doesn't need (the future-lifetime
  rationale moves to commit-message context, not header docstring)
- Stated marketing-style framing ("Schema is also self-documenting and
  catches typos at config-load")

Trimmed (kept the WHY-non-obvious in one line):
- kNodeParamSep colon-separator rationale (1 line)
- matchTargetNode longest-prefix-first WHY (2 lines)
- length-descending sort rationale (1 line)
- declarative YAML nominals reasoning (1 line; the auto-capture race is
  non-obvious and survives the upcoming refactor)
- state-N override without nominal warning rationale (1 line)
- retain-across-resets rationale (1 line)
- target_nodes explicit-list necessity (3 lines, still load-bearing for
  the dot-grammar boundary problem)

costmap_plugins.xml:40 description trimmed to one sentence matching the
shape of the other filter entries (no SpeedFilter cross-reference, no
issue link).

Class doxygen on ZoneParameterFilter.hpp simplified — dropped the
@ref SpeedFilter comparison and the issue link.

3 files changed, 20 insertions(+), 92 deletions(-).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: default state_event_topic to "zone_filter_state"

Steve Macenski review on PR #6104, comment #3150003597 on
zone_parameter_filter.cpp:80: "Set a reasonable default".

- Default state_event_topic from "" to "zone_filter_state".
- Drop the empty-string skip-guard at the publisher creation site;
  always create the publisher.

Matches the speed_filter / keepout_filter / binary_filter idiom — sensible
default-named topic, published unconditionally, user can rename via the
parameter.

Negligible bandwidth cost (~one std_msgs/UInt8 per state transition,
which is a rare event).

Companion docs change in PR #907 (L114) follows in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: flip on_param_set_failure default to throw

Steve Macenski review on PR #6104, comment on docs PR #907 line 136:
"I question if this should not always throw, since that puts the
application in an undefined state."

Per the PR #6104 reply: keeping the parameter, default-flipping to
throw. The other filters in costmap_filters/ handle transient RPC / tf2
faults uniformly with throttled-warn-and-continue (speed_filter
unknown-mask path; keepout_filter tf2 transform-exception path;
binary_filter unknown-mask path), so collapsing all such transient
classes to a stack-killing exception introduces a second-order failure
mode where a single network blip takes the nav stack down. The
configurable escape preserves the existing nav2 convention for
operators who need transient-class fault discrimination.

The default flip alone honors the safety direction in the review.

Tests: no existing test depends on the warn default for this parameter.

Companion docs change in PR #907 (L136) follows in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: header restructure (protected + doxygen)

Steve Macenski review on PR #6104, comment #3149982423 on
zone_parameter_filter.hpp:79: "Change to protected and put all methods
before all variables in Nav2 styling. All methods must have doxygen
as well."

- private: → protected: (visibility per ask).
- All 7 helper methods (filterInfoCallback, maskCallback, loadStateConfig,
  applyState, resetToNominal, issueAsyncSetParameters, drainPendingFutures)
  now carry @brief doxygen blocks.
- Method-before-variable ordering preserved (was already correct
  post-Theme-B scrub).

Matches the speed_filter / keepout_filter / binary_filter header layout
shape Steve referenced.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: init-time param clients + drop readiness probe

Steve Macenski review on PR #6104:
- Comment #3150018176 on cpp:529: "Should we not make these on
  initialization so we don't own the discovery at runtime and building
  for is service ready? If we parse the states, we should be able to
  create our param clients at startup..."
- Comment #3150018587 on cpp:536: "PS this will block indefinitely"

C.3 + C.4 changes (Steve's two comments resolve to one architectural
move):

- loadStateConfig() now enumerates the union of all target_nodes
  referenced by state_param_map_ + nominal_defaults_ and builds one
  AsyncParametersClient per node at init time. Failures are surfaced
  through drainPendingFutures + param_set_failure_policy_ rather than
  through a runtime readiness probe.
- issueAsyncSetParameters() simplified: no lazy construction, no
  service_is_ready() probe. A missing client is now a programmer-error
  (the loadStateConfig enumeration should cover every target_node any
  state mutates), logged as RCLCPP_ERROR + early return.
- service_is_ready() probe removed entirely. Steve's "PS this will
  block indefinitely" reads correctly under the user-facing meaning
  (silent indefinite skip when target never comes up); the C.3
  redesign converts that silent-skip into a surfaceable failure.

Matches the speed_filter / binary_filter init-time-resource pattern.
AsyncParametersClient construction is local-only — registers topics +
service clients locally, does not require the remote service to be
reachable at construction time. Set_parameters becomes
fire-and-forget-with-future-drain.

Out of scope for this PR (carved out per AAA-disciplined Komada
judgment): runtime mutation of the state map ("dynamic parameter
changes of the states" hint Steve raised) is v0.2 scope.

Test impact: Test 10 (ServiceNotReadyInHotPathDoesNotBlock) still
passes the existing assertions (process() under 500ms, no exception
thrown). Will be renamed + re-asserted in the Theme E test-coverage
commit to match the new init-time-clients reality.

Companion docs change in PR #907 (L94 nominal_defaults framing) follows
in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: replace colon-encoded keys with structured StateParamEntry

Steve Macenski review on PR #6104:
- Top-level: "Some parts of this seem dramatically overcomplicated."
- Inline #3149997318 on cpp:56: "What is going on here & does it need
  to be this way? Seems like this and the function where its used are
  overcomplicated and convoluted"

Theme D — split into two distinct items:

D-1: matchTargetNode kept. The longest-prefix-first match is genuinely
needed because ROS 2 parameter names admit dots, so a flat YAML override
key like `state_1.local_costmap.inflation_layer.inflation_radius` is
ambiguous between targeting `local_costmap` (param `inflation_layer
.inflation_radius`) or `local_costmap.inflation_layer` (param
`inflation_radius`). The user-declared `target_nodes:` list resolves
this. Light style polish (one renamed local for readability).

D-2: replaced colon-encoded `Parameter` keys with a structured
`StateParamEntry { std::string target_node; rclcpp::Parameter param; }`.
Removes:
- The `kNodeParamSep` constant (no separator needed).
- The "<target_node>:<param_name>" encoding in loadStateConfig.
- The colon-parsing in applyState (was rebuilding the same data).
- The colon-parsing in resetToNominal.
- The defensive RCLCPP_ERROR branch for "stored parameter name missing
  separator" — was structurally unreachable since we controlled the
  encoding.

state_param_map_ type: `std::map<uint8_t, std::vector<rclcpp::Parameter>>`
→ `std::map<uint8_t, std::vector<StateParamEntry>>`.

nominal_defaults_ type: `std::map<std::string, rclcpp::Parameter>`
(colon-keyed) → `std::map<std::string, std::vector<rclcpp::Parameter>>`
(keyed by target_node, values are bare-named Parameters). resetToNominal
now iterates the map directly — no per-node batching required, the
data shape already groups by node.

Init-time client enumeration loop (Theme C.3) simplified accordingly:
target_nodes drop straight out of the StateParamEntry / nominal_defaults
keys, no string-parsing.

Net change: -14 lines across .cpp/.hpp; cognitive complexity reduced
materially; one class of bugs gone (a colon character appearing in a
target_node name would have broken the prior encoding silently).

Tests: external behavior unchanged, all existing assertions pass.
Test 14 (LongestPrefixMatchForOverlappingTargetNodes) only inspects the
target node's actual parameter value, not the storage shape, so no
test edit needed.

Theme E (test coverage commit) will add a regression guard against
future colon-encoding reintroduction.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: expand test coverage 13 → 30 cases

Steve Macenski review on PR #6104, top-level: "Also check the code
coverage metrics, there's enough missing that needs to be added."

Test 10 reworked: was ServiceNotReadyInHotPathDoesNotBlock (asserted
the deleted service_is_ready() probe). Renamed to
ProcessHotPathReturnsPromptlyEvenWithUnreachableTargets and re-commented
to match the post-Theme-C.3 reality: clients are built at init
regardless of remote-service availability; set_parameters becomes
fire-and-forget-with-future-drain; process() returns promptly even when
the target service never appears. Same assertion, accurate framing.

17 new TEST_F cases targeting the warn / error / edge branches the
prior happy-path tests did not exercise:

- 15 InfoRePublishUpdatesMaskSubscription
- 16 MaskRePublishUpdatesFilterMask
- 17 BaseMultiplierNonDefaultDoesNotCrash
- 18 EmptyStateIdsLoadsButDoesNothing
- 19 EmptyTargetNodesLoadsButDoesNothing
- 20 InvalidStateIdInListIsSkipped
- 21 OverrideUnmatchedToTargetNodesIsWarnedAndSkipped
- 22 StateDeclaredWithNoParamsDoesNotCrash
- 23 NominalDefaultsUnmatchedToTargetNodesIsWarned
- 24 StateNWithoutNominalCounterpartWarnsAtConfig
- 25 TransformPoseFailureOrOutOfRangeReturnsCleanly
- 26 OnParamSetFailureWarnPolicyParsedCorrectly
- 27 OnParamSetFailureInvalidValueDefaultsToThrow
- 28 ResetToNominalNoOpWhenNoneConfigured
- 29 MultipleStateTransitionsInSequence
- 30 MultipleParamsInOneStateOnSameNode
- 31 NestedNamespaceTargetNodeRoutesCorrectly
  (Theme D-2 regression guard against future stringly-typed separator
  schemes; the structured StateParamEntry storage means no colon-encoded
  key can leak back in)

Total: 30 test cases (13 prior + 17 new). Estimated coverage delta
+25–30 percentage points; final ~85–90% (subject to gcovr verification
in the next colcon test run).

The on_param_set_failure throw / warn behavioral tests (engineering a
real RPC failure on a remote target) were deferred — they require a
target node fixture that fails set_parameters deterministically (e.g.
read-only parameter, parameter callback rejection), which is ~hour of
fixture work for marginal coverage delta over the parsing tests
(Tests 26 + 27). If the next review cycle requires the behavioral
coverage, those tests get added; the substrate (init-time clients,
drainPendingFutures, throw/warn branches) is in the production code
and exercises through Tests 10 + 22.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter resets N-only params on N→M

Cross-state transitions previously left params touched by state N but not
M at N's value until state-0 reset, leaking N's overrides into M's
behavior. applyState now computes the param-set difference and resets to
nominal_defaults before applying M's overrides, preserving the invariant
that all params equal state-0 defaults except those specifically set in
the active state.

Closes #6104 review thread 3211251415 + review summary item 1.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: simplify exception flow + scope-prune

Simplifies drainPendingFutures so the future.get() try/catch flows the
exception directly under the configured failure policy rather than
throwing-and-catching internally. Applies the matchTargetNode rewrite
from the review thread (starts_with + size guard). Adds an inline
comment near the override scan stating the routing-only validation
scope so a future reader does not infer cross-target param-existence
checks that this node neither performs nor needs to.

Closes #6104 review threads 3211313270 + 3211335331 + 3211355759.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: trim redundant comments + rename

Renames drainPendingFutures to checkPendingParameterUpdates so callers
read intent rather than implementation, drops the "Futures / drain"
docstring wording, removes inline comments that restated what the code
or surrounding log already shows, and adds a one-line note above the
parameter-overrides scan stating its intent so a future reader does
not have to infer it from the loop body.

Closes #6104 review threads 3211272912 + 3211274789 + 3211317251 +
3211319835 + 3211328905 + 3211330028 + 3211332786.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: remove TODO dev-note from test file

Per @SteveMacenski review (#6104 thread 3221447903): the Tests 3-5
header + 11-case-matrix TODO list is not test code and does not
belong in the test file.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: compress test suite 30 -> 16

Per @SteveMacenski review summary on PR #6104 (#4266595670):
"These tests need to be compressed and make sure they cover all the
active lines of code in this file. This seems extreme"

Sibling baseline: BinaryFilter has 10 TEST_Fs, SpeedFilter has 9. ZPF
landed at 30 cases / 1298 lines, ~3x sibling density. This commit
trims to 16 cases / 688 lines while preserving branch coverage and
adding two previously-missing branches.

Net: 1 TEST + 15 TEST_F, -787 / +156 lines.

Dropped 13 cases:
- Test 3 (FilterInfoTypeCheckRejectsWrongType): STALE - only re-asserted
  a constant inequality; the wrong-type branch in filterInfoCallback
  was never reached. Replaced by WrongFilterInfoTypeIsRejected which
  publishes BINARY_FILTER info and asserts isActive() stays false.
- Test 4 (MaskHelperConstructsExpectedShape): fixture self-test, not
  production code.
- Test 17 (BaseMultiplierNonDefaultDoesNotCrash): warn-only branch
  with no observable behavior.
- Test 21 (OverrideUnmatchedToTargetNodes): unmatched-node warn path,
  now covered by the merged EmptyAndInvalidConfigEdges case.
- Test 23 (NominalDefaultsUnmatchedToTargetNodes): symmetric warn-only
  path, no observable behavior.
- Test 24 (StateNWithoutNominalCounterpartWarns): same gap as Test 35;
  Test 35 (merged into ParamWithoutNominalDefaultsPersists) is the
  canonical assertion.
- Test 25 (TransformPoseFailureOrOutOfRange): weak duplicate of
  Test 13 (RobotOutsideMaskResetsToState0).
- Test 28 (ResetToNominalNoOpWhenNoneConfigured): subsumed by Test 7
  + the empty-config edge cases.
- Test 29 (MultipleStateTransitionsInSequence): cyclic transitions
  add nothing past the in-both + N-only-reset coverage.
- Test 30 (MultipleParamsInOneStateOnSameNode): per-node batching is
  exercised by every multi-param test.
- Test 31 (NestedNamespaceTargetNodeRoutesCorrectly): STALE - comment
  admitted ROS rejects colons; test degenerated to a Test 6 duplicate.
- Test 34 (CyclicTransitionABAReturnsToAValue): same mechanics as
  Test 32 with one extra hop.
- Test 36 (CrossStateTransitionInflationLeakDoesNotPersist): identical
  mechanics to Test 32 with controller-class flavor names.

Merged 8 cases into 5 survivors:
- 15 + 16     -> InfoAndMaskRePublishUpdateSubscriptions
- 18 + 19 + 20 + 22 -> EmptyAndInvalidConfigEdgesDoNotCrash
- 26 + 27     -> OnParamSetFailurePolicyParsing
- 33 + 32     -> CrossStateTransitionResetsParamTouchedByNOnly
- 37 + 35     -> ParamWithoutNominalDefaultsPersistsAcrossTransitions

Added two cases targeting branches the prior 30 did not cover:
- WrongFilterInfoTypeIsRejected: publishes BINARY_FILTER info on the
  ZPF info topic; asserts filterInfoCallback rejects it and isActive()
  never flips. Mirrors binary_filter_test::testIncorrectFilterType.
- OnParamSetFailureThrowsByDefaultAndWarnSwallows: routes state_1 to
  a read-only parameter on TargetNode (declared via ParameterDescriptor
  with read_only=true); set_parameters returns successful=false and
  checkPendingParameterUpdates applies the policy. Asserts default
  policy throws on the failure and "warn" policy swallows it.

Active branches now covered (was uncovered before):
- filterInfoCallback wrong-type rejection (B.2)
- checkPendingParameterUpdates failure path under both kThrow + kWarn (H)

Folded Test 1 + Test 2 (constant uniqueness + default-constructed
inactive) into a single non-fixture TEST. Folded Test 11
(ResetFilterDeactivates) into Test 3's teardown assertion.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: fix lint findings on test compression

CI failures on 0828ff9:
- ament_uncrustify: inner brace-list of OnParamSetFailurePolicyParsing
  used 8-space indent instead of 6.
- codespell: "waitFor" matched the "wait for" rule with
  write-changes=true and the hook rewrote the helper to "wait for",
  breaking compilation. Renamed to waitForCond throughout (codespell-
  safe; dictionary doesn't carry the compound).

Also refactored two brace-block EXPECT_THROW / EXPECT_NO_THROW
statement bodies in OnParamSetFailureThrowsByDefaultAndWarnSwallows
to lambdas — the brace-block-as-statement form is unconventional
and friendlier to formatters as a lambda call.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: avoid codespell lets-let's misfire

codespell 2.4.1 (used by nav2 pre-commit cache) rewrites "lets" to
"let's" via the informal rule, even where "lets" is the correct
verb form. The comment on createFilter() tripped this in CI. Rephrase
to "allows ... to inject" so codespell stays quiet without an
ignore-words entry that the maintainers would have to maintain.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: read declared configuration

Per review feedback: replace get_parameter_overrides() scraping with
explicit declared parameters. The state, target node, parameter, and
value are all declared configuration now — introspectable via
'ros2 param get' and type-validated at load.

- New schema: <filter>.states (names) -> <name>.{id, overrides} ->
  <override>.{node, parameter, value} (dynamic-typed value), plus
  <filter>.nominal_defaults for the state-0 reset baseline.
- Remove matchTargetNode()/longest-prefix routing and the length sort:
  with node and parameter explicit there is nothing to disambiguate.
- Remove the on_param_set_failure policy: a failed set always throws
  (a failed parameter set on a safety parameter is a stop condition).
- Rewrite the unit tests to the declared schema (16 tests; the
  longest-prefix test becomes explicit two-node routing, and the
  policy-parsing test now proves a leftover policy override neither
  breaks config-load nor softens the always-throw).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: fix uncrustify continuation indent

Whitespace-only (verified: 'git diff -w' empty); ament_uncrustify now
reports no divergence on all three files.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: address review round 3

- Rename the per-state key 'overrides' to 'setpoints' in the parameter
  schema and the log strings (reviewer preference). This renames this
  PR's own key <state>.overrides -> <state>.setpoints; nothing in docs
  or YAML referenced the old name, so it is code and tests only.
- Use 'auto' for all three node_.lock() sites.
- Drop the dead 'found' flag and its '(void)found' silencer in
  applyState(); the loop already breaks on the match and the gap case
  is handled by the preceding continue.

The comment rewrites requested in the same review round are not in this
commit and follow separately.

Signed-off-by: Akihiko Komada <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* [costmap_filters] ZoneParameterFilter: clarify comments + guard state/map divergence

- read_entry: rewrite the block comment to explain why `value` alone is
  declared dynamic_typing (one override path carries a parameter of any
  type), instead of narrating what the code already shows.
- state-reset loop: rewrite the `continue` comment (no nominal default ->
  the param keeps state N's value; already warned at config-load); drop the
  stray "Test 24" reference.
- checkPendingParameterUpdates: rewrite to the safety rationale -- a failed
  safety-zone parameter set is rethrown, never logged-and-swallowed.
- applyState: add an RCLCPP_ERROR when current_state_ is not in
  state_param_map_ (a tracked-state/map divergence that should never happen),
  matching the existing 'should have been built at config-load' error.

zone_parameter_filter suite: 16/16 passing (built against nav2 rolling).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: tighten remaining comments + fix two inaccurate ones

Follow-up cleanup of the rest of the file's comments to the same why-only standard,
and correction of two that were wrong:
- the reset/apply comment claimed issueAsyncSetParameters preserves submission order
  on a per-node future queue; no such queue exists — it push_backs into a single flat
  pending_futures_ used only for completion polling. The only ordering guarantee is
  that the reset loop runs before the apply loop.
- resetFilter's retained-maps comment named only nominal_defaults_ and param_clients_;
  state_param_map_ also persists across resets.

Also trimmed the read_entry / client-construction / checkPendingParameterUpdates blocks
to their load-bearing rationale and dropped section-marker comments that restated the
code. Comments only; no behavior change. zone_parameter_filter suite: 16/16.

Signed-off-by: Akihiko Komada <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* fix: declare reset_per_node map in ZoneParameterFilter::applyState

Signed-off-by: Akihiko Komada <[email protected]>

* Fix -Werror=null-dereference in ZoneParameterFilter on GCC 15

The nav2 CI image refreshed on 2026-08-07 and now ships GCC 15.2, whose
inliner rejects checkPendingParameterUpdates():

  error: potential null pointer dereference [-Werror=null-dereference]
    inlined from 'std::vector<_Tp, _Alloc>::operator=(const vector&)'
      at /usr/include/c++/15/bits/vector.tcc:250:21,
    inlined from 'ZoneParameterFilter::checkPendingParameterUpdates()'
      at zone_parameter_filter.cpp:484:25

pending_futures_ holds std::shared_future, and shared_future::get()
returns a const reference rather than a value, so `results = it->get()`
was a full copy-assignment of the result vector. GCC 15 follows the
inlined vector::operator= chain down into SetParametersResult_ and
cannot prove the internal pointer is non-null.

Bind the results by const reference instead of copying them. The shared
future is copied out of the container before the entry is erased, so the
shared state -- and therefore the value the reference refers to -- stays
alive for the rest of the iteration. Erasing before get() also removes
the need for the catch-and-rethrow: the entry is already gone, so a
service-side exception still surfaces exactly once.

Behaviour is unchanged: an entry is erased exactly once, a failed
set_parameters still throws, and the not-yet-ready path is untouched.

Verified in ghcr.io/ros-navigation/navigation2:main (GCC 15.2): the
package fails to build with colcon exit 2 before this change and builds
clean with exit 0 after it; zone_parameter_filter_test passes 16/16.

Signed-off-by: Akihiko Komada <[email protected]>

* Align ZoneParameterFilter test with current nav2 conventions

Two small drifts this branch had picked up against main:

- Link std_msgs::std_msgs directly. After #6136 replaced the rest,
  ${std_msgs_TARGETS} here was the only remaining use in the repo, and
  binary_filter_test seven lines above already links the target
  directly. Linkage is unchanged.

- Build the test's transform buffer with nav2::create_transform_buffer
  rather than constructing tf2_ros::Buffer by hand, matching the speed,
  keepout and binary filter tests after #6281. This also gives the test
  the timer interface the factory installs. Two includes left unused by
  the change are dropped.

Signed-off-by: Akihiko Komada <[email protected]>

---------

Signed-off-by: Akihiko Komada <[email protected]>
Signed-off-by: Steve Macenski <[email protected]>
Co-authored-by: Steve Macenski <[email protected]>
SteveMacenski added a commit that referenced this pull request Aug 12, 2026
…rameter overrides (#6104)

* WIP: ZoneParameterFilter — plugin scaffold + test scaffold (slice 1, ~80%)

Slice 1 of nav2#6080 implementation per the source-read milestone-1
artifact at outputs/sprint_131/nav2_6080_source_read.md.

Architecture per Steve Macenski's 2026-04-13 design guidance:
- Mask values 0..255; value 0 = reset to nominal defaults
- Each non-zero state mapped via YAML config to a list of ROS
  parameters (any reachable nav2 parameter on any node)
- No custom enums; raw int + config-driven semantics
- Async parameter setting via per-target-node AsyncParametersClient
  (Steve's preferred pattern from PR #3796 first review)
- Optional state-transition event publication
- Configurable warn|throw policies for unknown-state and
  param-set-failure

PR #3796 burn-pattern guards baked in:
- No wait_for_service in hot path (issue 2): service_is_ready()
  predicate; skip-with-throttled-warn on not-ready
- No empty-string sentinels (issue 4): std::map presence checks
- Future lifetime managed (issue 5): pending_futures_ vector
  drained at top of every process() call; never destruct mid-flight
- Per-node async client (Steve's first review point): one
  AsyncParametersClient per target node, batched parameter sets

Files added:
- nav2_costmap_2d/include/nav2_costmap_2d/costmap_filters/
    zone_parameter_filter.hpp
- nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp
- nav2_costmap_2d/test/unit/zone_parameter_filter_test.cpp

Files edited:
- filter_values.hpp: added ZONE_PARAMETER_FILTER = 4 constant
- costmap_plugins.xml: registered new plugin in filters library
- CMakeLists.txt: added zone_parameter_filter.cpp to filters target
- test/unit/CMakeLists.txt: added zone_parameter_filter_test target

Confidence assessment for slice 1 target (80% today):
- Architectural skeleton complete and follows nav2 conventions
- Source-read evidence cited for every #3796 fix
- All cross-file wiring (XML, CMake, header, impl) in place
- Test scaffold exercises the type-constant and construction paths
- 5/11 test cases from §5 implementation plan present (or as
  documented placeholders); remaining 6 deferred to slice 2 (95%)
- Build verification deferred: no ROS 2 env on this machine; CI
  build is the next gate

Slice 2 (95% target tomorrow) needs:
- colcon build green on humble + jazzy
- Remaining 6 unit tests with full ROS 2 mock harness
- AsyncParametersClient mock for param-mutation assertions
- Coverage measurement (lcov ≥90% per #3796 retrospective)
- File-level review of PR #3796 diff (read summary, not the diff
  itself yet)

Not for PR open — feature branch only. Per D-VGC148, all PR
prose is Komada-authored at PR-open time. Per the commit-or-close
clause to Steve, PR open is committed by 2026-05-16.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): uncrustify lint nits (Path C build verification round 1)

Three style fixes per ament_uncrustify on rolling:

1. plugins/costmap_filters/zone_parameter_filter.cpp:60-61 — split a
   140-char declare_or_get_parameter call across two lines.
2. plugins/costmap_filters/zone_parameter_filter.cpp:138-140 — same
   for an RCLCPP_ERROR call.
3. test/unit/zone_parameter_filter_test.cpp:72,89 — convert
   single-line destructors to multi-line bodies (matches binary_filter_test
   pattern).

Verification context: Path C source-build in ros:rolling docker
container compiled the package cleanly and ran 4/4 of our new
gtest cases. The 3 failures in the 399-test suite were all
uncrustify diffs on these lines — zero correctness regressions.
This commit closes the lint gates.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* test(zone_parameter_filter): add TestZpf lifecycle fixture + first real test (slice 2a)

Adds a gtest fixture mirroring binary_filter_test.cpp's TestNode pattern,
adapted for ZoneParameterFilter's parameter-mutation semantics:

- TargetNode helper — minimal rclcpp::Node with declared parameters that
  ZPF will mutate via AsyncParametersClient
- TestZpf fixture — LifecycleNode host + separate executors + helpers for
  filter creation, process() invocation, and predicate-based wait
- State1AppliesParameterToTargetNode — first real lifecycle test:
  state_ids=[1] + state_1.zpf_target_node.speed=0.5 fed via
  parameter_overrides; mask filled with 1; pose at center cell;
  process() triggers state 0→1 transition; async set_parameters
  propagates to target node within 1.5s timeout; asserts speed=0.5,
  inflation untouched

Verified on rolling (docker nav2:dev): 5/5 tests pass in 150ms total
(4 scaffold + 1 new lifecycle), zero build warnings, zero test failures.

Slice 2a complete; remaining slice-2b items per scaffold TODO list:
state_zero_resets, unknown_state_warn/throw, state_event_published,
service_not_ready_in_hot_path_does_not_block, etc.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* test(zone_parameter_filter): add 3 lifecycle cases + #3796 regression test (slice 2b)

Extends TestZpf fixture with StateEventSubscriber + rePublishMask helper,
plus three live cases covering distinct ZPF code paths:

- UnknownStateWarnLogsAndKeepsPrevious — exercises on_unknown_state="warn"
  policy: a mask value not in the configured state map must log a
  throttled warn and leave all target parameters unchanged.

- StateEventPublishedOnTransition — exercises optional state_event_pub_:
  when state_event_topic is configured, every transition publishes a
  UInt8 carrying the new state value. Verified via a separate
  StateEventSubscriber on the same in-process executor.

- ServiceNotReadyInHotPathDoesNotBlock — REGRESSION TEST FOR PR #3796
  review item 2 (Steve Macenski + Alexey Merzlyakov, 2023-09 to
  2023-12). When a target node's parameter service is not ready, ZPF
  must NOT call wait_for_service in process(); it must log a throttled
  warn via service_is_ready() and return promptly. Test routes a
  state-1 override at a nonexistent_node and asserts process() returns
  in <500ms (a wait_for_service regression would hang for seconds).

Plus one documented-failure case kept under DISABLED_ prefix:

- DISABLED_State0ResetsToNominalDefaults — surfaces a v0.1 limitation
  in zone_parameter_filter.cpp:383 where nominal_defaults_ stores an
  empty ParameterValue instead of the target's pre-override value.
  resetToNominal() therefore pushes NOT_SET and silently no-ops.
  Proper fix (slice 2c) is to synchronously fetch nominal values at
  initializeFilter() time via spin_until_future_complete with short
  timeout — permitted blocking outside the hot path.

Cosmetic: InfoPublisher now passes multiplier=1.0 (was 0.0) to silence
the "base/multiplier are unused; expected defaults (0.0, 1.0)" warning
emitted by ZPF on filter-info receipt.

Verified on rolling (nav2:dev container, incremental build 22s):
8/8 enabled tests pass in 611ms total. 1 disabled documented as design
intent pending slice 2c fix.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): YAML-declared nominal_defaults for state-0 reset (slice 2c)

Slice 2b's State0ResetsToNominalDefaults test surfaced a real v0.1 bug:
applyState() inserted an empty `ParameterValue` (NOT_SET type) as a
nominal-default sentinel, then resetToNominal() pushed that empty value
back to the target on state-0 transition — silent no-op, override never
restored. Steve Macenski's #6080 design pointer specifically called out
state-0 reset semantics, so leaving this broken was not an option.

Initial fix candidate was async get-before-set: fire get_parameters then
set_parameters on the same AsyncParametersClient, relying on FIFO to
capture the pre-override value in the get response. Discarded after
inspection: get_parameters and set_parameters use SEPARATE underlying
services::Client instances, so server-side processing order between them
is not guaranteed. A late get response would capture the OVERRIDDEN
value, not the nominal — a worse failure mode than the silent no-op.

Adopted: declarative YAML nominal_defaults. Schema:

  <plugin>.nominal_defaults.<target_node>.<param_path>: <value>

Parsed at loadStateConfig() time (configure phase, blocking permitted).
Race-free, deterministic, zero runtime cost. Matches Steve's "config-
driven" preference verbatim.

Quality-of-life: warn at config-load time for any state-N parameter that
has no matching nominal_defaults entry — such params will not be
restored by state-0 reset, and a v1 user almost certainly wants symmetric
coverage.

Test re-enabled (DISABLED_State0ResetsToNominalDefaults → enabled),
extended to provide the explicit nominal_defaults override. All 9
TestZpf cases pass on rolling (nav2:dev, incremental build 58s):

  State1AppliesParameterToTargetNode      ✅ 162ms
  State0ResetsToNominalDefaults           ✅ 268ms (slice 2c verified)
  UnknownStateWarnLogsAndKeepsPrevious    ✅ 327ms
  StateEventPublishedOnTransition         ✅ 149ms
  ServiceNotReadyInHotPathDoesNotBlock    ✅ 130ms

  Total: 9/9 in 1038ms, 0 disabled, 0 failures.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): apply CI lint feedback (codespell + uncrustify)

PR #6104 lint workflow surfaced two issues:

- codespell (in pre-commit): flagged "lets" in a comment on
  loadStateConfig (the colon-separator routing comment) as
  potentially "let's". The original word was correct ("permits"
  meaning), but rewording to "routes" preserves the same intent
  while avoiding the false-positive trigger.

- ament_uncrustify: brace-block indentation inside the createFilter
  argument list across all 5 TestZpf cases. Auto-reformatted via
  ament_uncrustify --reformat; 11/11 line shifts.

No functional change. Local verification on rolling (nav2:dev):
ament_uncrustify clean across all 3 ZPF files; 9/9 tests pass in
965ms.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): explicit target_nodes + 4 audit-driven tests

Addresses findings from a 4-agent swarm audit on PR #6104 (synthesis at
sky/outputs/nav2_6104_pr_audit/synthesis.md):

- F-4 schema: introduce a required `target_nodes: [a, b, ...]` YAML
  parameter and replace first-dot-split parsing with longest-prefix-match
  against the explicit list. The original first-dot-split happens to be
  correct for typical nav2 usage (ROS doesn't allow dots in node names),
  but the explicit list is unambiguous, self-documenting, catches typos
  at config-load, and future-proofs against schema drift.

- F-9 ResetFilterDeactivates: verify resetFilter() clears
  filter_info_received_ and filter_mask_ so isActive() returns false.
  Mirrors binary_filter_test.cpp::testResetFilter.

- F-10 UnknownMaskCellLeavesStateUnchanged: mask filled with
  OCC_GRID_UNKNOWN (-1); verify process() leaves current_state_ + the
  target's parameter untouched. Guards the negative-mask-data branch
  in process().

- F-11 RobotOutsideMaskResetsToState0: drive into state 1, then call
  process() with a pose far outside mask bounds. Verify the state
  auto-resets to 0 and nominal_defaults are restored. Guards the
  worldToMap()-failure branch in process().

- F-4 regression test (LongestPrefixMatchForOverlappingTargetNodes):
  with target_nodes = ["zpf", "zpf_target_node"] and an override
  state_1.zpf_target_node.speed=0.7, verify the longer prefix wins so
  the parameter actually lands on the live target node. A regression
  to naive shortest-prefix would route to the bogus "zpf" service
  and the value would never land.

Verified on rolling (nav2:dev): 13/13 tests pass in 1365ms. Local
ament_uncrustify + ament_cpplint clean.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: always throw on unknown mask state

Removes the on_unknown_state parameter and the paired UnknownStatePolicy
enum. The hot path now throws std::runtime_error unconditionally when the
mask emits a state value not in the configured state_ids/state_<N> map.

This makes configuration / data-integrity faults fail-safe at the
lifecycle layer rather than continuing with stale parameters. ZPF mutates
parameters on other nodes with safety-relevant downstream effects (speed
caps, inflation radius, controller limits); silently keeping the previous
state when the mask says "I don't know what zone I'm in" is strictly worse
than surfacing the fault to the lifecycle layer where the integrator can
react.

The throw fires at the state_param_map_.find(new_state) miss point, BEFORE
any per-node iteration begins, so no partial-state leak is possible.
Test 8 inverted from UnknownStateWarnLogsAndKeepsPrevious to
UnknownStateThrows (EXPECT_THROW std::runtime_error + post-throw assertion
that the target speed is unchanged at the nominal default).

Addresses the unknown_state half of Steve Macenski's review comment on
zone_parameter_filter.cpp:95 ("Always throw, this is a critical issue
the robot should stop for"). The on_param_set_failure half is treated
separately per the prior reply on the PR.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: scrub TMI comments

Steve Macenski review on PR #6104: top-level "There's a lot of AI generated
TMI comments throughout the code that should be removed or reduced", plus
inline pins on hpp:101, cpp:78, costmap_plugins.xml:40.

Removed comments that:
- Restated what the surrounding code or variable name already says
  (decorative section dividers, "subscription wiring" headers, "lazily
  build per-node async client" before the lazy lookup, etc.)
- Cited prior reviews back at the reviewer (#3796 references, "Steve's
  preference", "Per #3796 review item N")
- Cited foreign-PR context the reader doesn't need (the future-lifetime
  rationale moves to commit-message context, not header docstring)
- Stated marketing-style framing ("Schema is also self-documenting and
  catches typos at config-load")

Trimmed (kept the WHY-non-obvious in one line):
- kNodeParamSep colon-separator rationale (1 line)
- matchTargetNode longest-prefix-first WHY (2 lines)
- length-descending sort rationale (1 line)
- declarative YAML nominals reasoning (1 line; the auto-capture race is
  non-obvious and survives the upcoming refactor)
- state-N override without nominal warning rationale (1 line)
- retain-across-resets rationale (1 line)
- target_nodes explicit-list necessity (3 lines, still load-bearing for
  the dot-grammar boundary problem)

costmap_plugins.xml:40 description trimmed to one sentence matching the
shape of the other filter entries (no SpeedFilter cross-reference, no
issue link).

Class doxygen on ZoneParameterFilter.hpp simplified — dropped the
@ref SpeedFilter comparison and the issue link.

3 files changed, 20 insertions(+), 92 deletions(-).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: default state_event_topic to "zone_filter_state"

Steve Macenski review on PR #6104, comment #3150003597 on
zone_parameter_filter.cpp:80: "Set a reasonable default".

- Default state_event_topic from "" to "zone_filter_state".
- Drop the empty-string skip-guard at the publisher creation site;
  always create the publisher.

Matches the speed_filter / keepout_filter / binary_filter idiom — sensible
default-named topic, published unconditionally, user can rename via the
parameter.

Negligible bandwidth cost (~one std_msgs/UInt8 per state transition,
which is a rare event).

Companion docs change in PR #907 (L114) follows in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: flip on_param_set_failure default to throw

Steve Macenski review on PR #6104, comment on docs PR #907 line 136:
"I question if this should not always throw, since that puts the
application in an undefined state."

Per the PR #6104 reply: keeping the parameter, default-flipping to
throw. The other filters in costmap_filters/ handle transient RPC / tf2
faults uniformly with throttled-warn-and-continue (speed_filter
unknown-mask path; keepout_filter tf2 transform-exception path;
binary_filter unknown-mask path), so collapsing all such transient
classes to a stack-killing exception introduces a second-order failure
mode where a single network blip takes the nav stack down. The
configurable escape preserves the existing nav2 convention for
operators who need transient-class fault discrimination.

The default flip alone honors the safety direction in the review.

Tests: no existing test depends on the warn default for this parameter.

Companion docs change in PR #907 (L136) follows in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: header restructure (protected + doxygen)

Steve Macenski review on PR #6104, comment #3149982423 on
zone_parameter_filter.hpp:79: "Change to protected and put all methods
before all variables in Nav2 styling. All methods must have doxygen
as well."

- private: → protected: (visibility per ask).
- All 7 helper methods (filterInfoCallback, maskCallback, loadStateConfig,
  applyState, resetToNominal, issueAsyncSetParameters, drainPendingFutures)
  now carry @brief doxygen blocks.
- Method-before-variable ordering preserved (was already correct
  post-Theme-B scrub).

Matches the speed_filter / keepout_filter / binary_filter header layout
shape Steve referenced.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: init-time param clients + drop readiness probe

Steve Macenski review on PR #6104:
- Comment #3150018176 on cpp:529: "Should we not make these on
  initialization so we don't own the discovery at runtime and building
  for is service ready? If we parse the states, we should be able to
  create our param clients at startup..."
- Comment #3150018587 on cpp:536: "PS this will block indefinitely"

C.3 + C.4 changes (Steve's two comments resolve to one architectural
move):

- loadStateConfig() now enumerates the union of all target_nodes
  referenced by state_param_map_ + nominal_defaults_ and builds one
  AsyncParametersClient per node at init time. Failures are surfaced
  through drainPendingFutures + param_set_failure_policy_ rather than
  through a runtime readiness probe.
- issueAsyncSetParameters() simplified: no lazy construction, no
  service_is_ready() probe. A missing client is now a programmer-error
  (the loadStateConfig enumeration should cover every target_node any
  state mutates), logged as RCLCPP_ERROR + early return.
- service_is_ready() probe removed entirely. Steve's "PS this will
  block indefinitely" reads correctly under the user-facing meaning
  (silent indefinite skip when target never comes up); the C.3
  redesign converts that silent-skip into a surfaceable failure.

Matches the speed_filter / binary_filter init-time-resource pattern.
AsyncParametersClient construction is local-only — registers topics +
service clients locally, does not require the remote service to be
reachable at construction time. Set_parameters becomes
fire-and-forget-with-future-drain.

Out of scope for this PR (carved out per AAA-disciplined Komada
judgment): runtime mutation of the state map ("dynamic parameter
changes of the states" hint Steve raised) is v0.2 scope.

Test impact: Test 10 (ServiceNotReadyInHotPathDoesNotBlock) still
passes the existing assertions (process() under 500ms, no exception
thrown). Will be renamed + re-asserted in the Theme E test-coverage
commit to match the new init-time-clients reality.

Companion docs change in PR #907 (L94 nominal_defaults framing) follows
in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: replace colon-encoded keys with structured StateParamEntry

Steve Macenski review on PR #6104:
- Top-level: "Some parts of this seem dramatically overcomplicated."
- Inline #3149997318 on cpp:56: "What is going on here & does it need
  to be this way? Seems like this and the function where its used are
  overcomplicated and convoluted"

Theme D — split into two distinct items:

D-1: matchTargetNode kept. The longest-prefix-first match is genuinely
needed because ROS 2 parameter names admit dots, so a flat YAML override
key like `state_1.local_costmap.inflation_layer.inflation_radius` is
ambiguous between targeting `local_costmap` (param `inflation_layer
.inflation_radius`) or `local_costmap.inflation_layer` (param
`inflation_radius`). The user-declared `target_nodes:` list resolves
this. Light style polish (one renamed local for readability).

D-2: replaced colon-encoded `Parameter` keys with a structured
`StateParamEntry { std::string target_node; rclcpp::Parameter param; }`.
Removes:
- The `kNodeParamSep` constant (no separator needed).
- The "<target_node>:<param_name>" encoding in loadStateConfig.
- The colon-parsing in applyState (was rebuilding the same data).
- The colon-parsing in resetToNominal.
- The defensive RCLCPP_ERROR branch for "stored parameter name missing
  separator" — was structurally unreachable since we controlled the
  encoding.

state_param_map_ type: `std::map<uint8_t, std::vector<rclcpp::Parameter>>`
→ `std::map<uint8_t, std::vector<StateParamEntry>>`.

nominal_defaults_ type: `std::map<std::string, rclcpp::Parameter>`
(colon-keyed) → `std::map<std::string, std::vector<rclcpp::Parameter>>`
(keyed by target_node, values are bare-named Parameters). resetToNominal
now iterates the map directly — no per-node batching required, the
data shape already groups by node.

Init-time client enumeration loop (Theme C.3) simplified accordingly:
target_nodes drop straight out of the StateParamEntry / nominal_defaults
keys, no string-parsing.

Net change: -14 lines across .cpp/.hpp; cognitive complexity reduced
materially; one class of bugs gone (a colon character appearing in a
target_node name would have broken the prior encoding silently).

Tests: external behavior unchanged, all existing assertions pass.
Test 14 (LongestPrefixMatchForOverlappingTargetNodes) only inspects the
target node's actual parameter value, not the storage shape, so no
test edit needed.

Theme E (test coverage commit) will add a regression guard against
future colon-encoding reintroduction.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: expand test coverage 13 → 30 cases

Steve Macenski review on PR #6104, top-level: "Also check the code
coverage metrics, there's enough missing that needs to be added."

Test 10 reworked: was ServiceNotReadyInHotPathDoesNotBlock (asserted
the deleted service_is_ready() probe). Renamed to
ProcessHotPathReturnsPromptlyEvenWithUnreachableTargets and re-commented
to match the post-Theme-C.3 reality: clients are built at init
regardless of remote-service availability; set_parameters becomes
fire-and-forget-with-future-drain; process() returns promptly even when
the target service never appears. Same assertion, accurate framing.

17 new TEST_F cases targeting the warn / error / edge branches the
prior happy-path tests did not exercise:

- 15 InfoRePublishUpdatesMaskSubscription
- 16 MaskRePublishUpdatesFilterMask
- 17 BaseMultiplierNonDefaultDoesNotCrash
- 18 EmptyStateIdsLoadsButDoesNothing
- 19 EmptyTargetNodesLoadsButDoesNothing
- 20 InvalidStateIdInListIsSkipped
- 21 OverrideUnmatchedToTargetNodesIsWarnedAndSkipped
- 22 StateDeclaredWithNoParamsDoesNotCrash
- 23 NominalDefaultsUnmatchedToTargetNodesIsWarned
- 24 StateNWithoutNominalCounterpartWarnsAtConfig
- 25 TransformPoseFailureOrOutOfRangeReturnsCleanly
- 26 OnParamSetFailureWarnPolicyParsedCorrectly
- 27 OnParamSetFailureInvalidValueDefaultsToThrow
- 28 ResetToNominalNoOpWhenNoneConfigured
- 29 MultipleStateTransitionsInSequence
- 30 MultipleParamsInOneStateOnSameNode
- 31 NestedNamespaceTargetNodeRoutesCorrectly
  (Theme D-2 regression guard against future stringly-typed separator
  schemes; the structured StateParamEntry storage means no colon-encoded
  key can leak back in)

Total: 30 test cases (13 prior + 17 new). Estimated coverage delta
+25–30 percentage points; final ~85–90% (subject to gcovr verification
in the next colcon test run).

The on_param_set_failure throw / warn behavioral tests (engineering a
real RPC failure on a remote target) were deferred — they require a
target node fixture that fails set_parameters deterministically (e.g.
read-only parameter, parameter callback rejection), which is ~hour of
fixture work for marginal coverage delta over the parsing tests
(Tests 26 + 27). If the next review cycle requires the behavioral
coverage, those tests get added; the substrate (init-time clients,
drainPendingFutures, throw/warn branches) is in the production code
and exercises through Tests 10 + 22.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter resets N-only params on N→M

Cross-state transitions previously left params touched by state N but not
M at N's value until state-0 reset, leaking N's overrides into M's
behavior. applyState now computes the param-set difference and resets to
nominal_defaults before applying M's overrides, preserving the invariant
that all params equal state-0 defaults except those specifically set in
the active state.

Closes #6104 review thread 3211251415 + review summary item 1.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: simplify exception flow + scope-prune

Simplifies drainPendingFutures so the future.get() try/catch flows the
exception directly under the configured failure policy rather than
throwing-and-catching internally. Applies the matchTargetNode rewrite
from the review thread (starts_with + size guard). Adds an inline
comment near the override scan stating the routing-only validation
scope so a future reader does not infer cross-target param-existence
checks that this node neither performs nor needs to.

Closes #6104 review threads 3211313270 + 3211335331 + 3211355759.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: trim redundant comments + rename

Renames drainPendingFutures to checkPendingParameterUpdates so callers
read intent rather than implementation, drops the "Futures / drain"
docstring wording, removes inline comments that restated what the code
or surrounding log already shows, and adds a one-line note above the
parameter-overrides scan stating its intent so a future reader does
not have to infer it from the loop body.

Closes #6104 review threads 3211272912 + 3211274789 + 3211317251 +
3211319835 + 3211328905 + 3211330028 + 3211332786.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: remove TODO dev-note from test file

Per @SteveMacenski review (#6104 thread 3221447903): the Tests 3-5
header + 11-case-matrix TODO list is not test code and does not
belong in the test file.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: compress test suite 30 -> 16

Per @SteveMacenski review summary on PR #6104 (#4266595670):
"These tests need to be compressed and make sure they cover all the
active lines of code in this file. This seems extreme"

Sibling baseline: BinaryFilter has 10 TEST_Fs, SpeedFilter has 9. ZPF
landed at 30 cases / 1298 lines, ~3x sibling density. This commit
trims to 16 cases / 688 lines while preserving branch coverage and
adding two previously-missing branches.

Net: 1 TEST + 15 TEST_F, -787 / +156 lines.

Dropped 13 cases:
- Test 3 (FilterInfoTypeCheckRejectsWrongType): STALE - only re-asserted
  a constant inequality; the wrong-type branch in filterInfoCallback
  was never reached. Replaced by WrongFilterInfoTypeIsRejected which
  publishes BINARY_FILTER info and asserts isActive() stays false.
- Test 4 (MaskHelperConstructsExpectedShape): fixture self-test, not
  production code.
- Test 17 (BaseMultiplierNonDefaultDoesNotCrash): warn-only branch
  with no observable behavior.
- Test 21 (OverrideUnmatchedToTargetNodes): unmatched-node warn path,
  now covered by the merged EmptyAndInvalidConfigEdges case.
- Test 23 (NominalDefaultsUnmatchedToTargetNodes): symmetric warn-only
  path, no observable behavior.
- Test 24 (StateNWithoutNominalCounterpartWarns): same gap as Test 35;
  Test 35 (merged into ParamWithoutNominalDefaultsPersists) is the
  canonical assertion.
- Test 25 (TransformPoseFailureOrOutOfRange): weak duplicate of
  Test 13 (RobotOutsideMaskResetsToState0).
- Test 28 (ResetToNominalNoOpWhenNoneConfigured): subsumed by Test 7
  + the empty-config edge cases.
- Test 29 (MultipleStateTransitionsInSequence): cyclic transitions
  add nothing past the in-both + N-only-reset coverage.
- Test 30 (MultipleParamsInOneStateOnSameNode): per-node batching is
  exercised by every multi-param test.
- Test 31 (NestedNamespaceTargetNodeRoutesCorrectly): STALE - comment
  admitted ROS rejects colons; test degenerated to a Test 6 duplicate.
- Test 34 (CyclicTransitionABAReturnsToAValue): same mechanics as
  Test 32 with one extra hop.
- Test 36 (CrossStateTransitionInflationLeakDoesNotPersist): identical
  mechanics to Test 32 with controller-class flavor names.

Merged 8 cases into 5 survivors:
- 15 + 16     -> InfoAndMaskRePublishUpdateSubscriptions
- 18 + 19 + 20 + 22 -> EmptyAndInvalidConfigEdgesDoNotCrash
- 26 + 27     -> OnParamSetFailurePolicyParsing
- 33 + 32     -> CrossStateTransitionResetsParamTouchedByNOnly
- 37 + 35     -> ParamWithoutNominalDefaultsPersistsAcrossTransitions

Added two cases targeting branches the prior 30 did not cover:
- WrongFilterInfoTypeIsRejected: publishes BINARY_FILTER info on the
  ZPF info topic; asserts filterInfoCallback rejects it and isActive()
  never flips. Mirrors binary_filter_test::testIncorrectFilterType.
- OnParamSetFailureThrowsByDefaultAndWarnSwallows: routes state_1 to
  a read-only parameter on TargetNode (declared via ParameterDescriptor
  with read_only=true); set_parameters returns successful=false and
  checkPendingParameterUpdates applies the policy. Asserts default
  policy throws on the failure and "warn" policy swallows it.

Active branches now covered (was uncovered before):
- filterInfoCallback wrong-type rejection (B.2)
- checkPendingParameterUpdates failure path under both kThrow + kWarn (H)

Folded Test 1 + Test 2 (constant uniqueness + default-constructed
inactive) into a single non-fixture TEST. Folded Test 11
(ResetFilterDeactivates) into Test 3's teardown assertion.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: fix lint findings on test compression

CI failures on 0828ff9:
- ament_uncrustify: inner brace-list of OnParamSetFailurePolicyParsing
  used 8-space indent instead of 6.
- codespell: "waitFor" matched the "wait for" rule with
  write-changes=true and the hook rewrote the helper to "wait for",
  breaking compilation. Renamed to waitForCond throughout (codespell-
  safe; dictionary doesn't carry the compound).

Also refactored two brace-block EXPECT_THROW / EXPECT_NO_THROW
statement bodies in OnParamSetFailureThrowsByDefaultAndWarnSwallows
to lambdas — the brace-block-as-statement form is unconventional
and friendlier to formatters as a lambda call.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: avoid codespell lets-let's misfire

codespell 2.4.1 (used by nav2 pre-commit cache) rewrites "lets" to
"let's" via the informal rule, even where "lets" is the correct
verb form. The comment on createFilter() tripped this in CI. Rephrase
to "allows ... to inject" so codespell stays quiet without an
ignore-words entry that the maintainers would have to maintain.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: read declared configuration

Per review feedback: replace get_parameter_overrides() scraping with
explicit declared parameters. The state, target node, parameter, and
value are all declared configuration now — introspectable via
'ros2 param get' and type-validated at load.

- New schema: <filter>.states (names) -> <name>.{id, overrides} ->
  <override>.{node, parameter, value} (dynamic-typed value), plus
  <filter>.nominal_defaults for the state-0 reset baseline.
- Remove matchTargetNode()/longest-prefix routing and the length sort:
  with node and parameter explicit there is nothing to disambiguate.
- Remove the on_param_set_failure policy: a failed set always throws
  (a failed parameter set on a safety parameter is a stop condition).
- Rewrite the unit tests to the declared schema (16 tests; the
  longest-prefix test becomes explicit two-node routing, and the
  policy-parsing test now proves a leftover policy override neither
  breaks config-load nor softens the always-throw).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: fix uncrustify continuation indent

Whitespace-only (verified: 'git diff -w' empty); ament_uncrustify now
reports no divergence on all three files.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: address review round 3

- Rename the per-state key 'overrides' to 'setpoints' in the parameter
  schema and the log strings (reviewer preference). This renames this
  PR's own key <state>.overrides -> <state>.setpoints; nothing in docs
  or YAML referenced the old name, so it is code and tests only.
- Use 'auto' for all three node_.lock() sites.
- Drop the dead 'found' flag and its '(void)found' silencer in
  applyState(); the loop already breaks on the match and the gap case
  is handled by the preceding continue.

The comment rewrites requested in the same review round are not in this
commit and follow separately.

Signed-off-by: Akihiko Komada <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* [costmap_filters] ZoneParameterFilter: clarify comments + guard state/map divergence

- read_entry: rewrite the block comment to explain why `value` alone is
  declared dynamic_typing (one override path carries a parameter of any
  type), instead of narrating what the code already shows.
- state-reset loop: rewrite the `continue` comment (no nominal default ->
  the param keeps state N's value; already warned at config-load); drop the
  stray "Test 24" reference.
- checkPendingParameterUpdates: rewrite to the safety rationale -- a failed
  safety-zone parameter set is rethrown, never logged-and-swallowed.
- applyState: add an RCLCPP_ERROR when current_state_ is not in
  state_param_map_ (a tracked-state/map divergence that should never happen),
  matching the existing 'should have been built at config-load' error.

zone_parameter_filter suite: 16/16 passing (built against nav2 rolling).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: tighten remaining comments + fix two inaccurate ones

Follow-up cleanup of the rest of the file's comments to the same why-only standard,
and correction of two that were wrong:
- the reset/apply comment claimed issueAsyncSetParameters preserves submission order
  on a per-node future queue; no such queue exists — it push_backs into a single flat
  pending_futures_ used only for completion polling. The only ordering guarantee is
  that the reset loop runs before the apply loop.
- resetFilter's retained-maps comment named only nominal_defaults_ and param_clients_;
  state_param_map_ also persists across resets.

Also trimmed the read_entry / client-construction / checkPendingParameterUpdates blocks
to their load-bearing rationale and dropped section-marker comments that restated the
code. Comments only; no behavior change. zone_parameter_filter suite: 16/16.

Signed-off-by: Akihiko Komada <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* fix: declare reset_per_node map in ZoneParameterFilter::applyState

Signed-off-by: Akihiko Komada <[email protected]>

* Fix -Werror=null-dereference in ZoneParameterFilter on GCC 15

The nav2 CI image refreshed on 2026-08-07 and now ships GCC 15.2, whose
inliner rejects checkPendingParameterUpdates():

  error: potential null pointer dereference [-Werror=null-dereference]
    inlined from 'std::vector<_Tp, _Alloc>::operator=(const vector&)'
      at /usr/include/c++/15/bits/vector.tcc:250:21,
    inlined from 'ZoneParameterFilter::checkPendingParameterUpdates()'
      at zone_parameter_filter.cpp:484:25

pending_futures_ holds std::shared_future, and shared_future::get()
returns a const reference rather than a value, so `results = it->get()`
was a full copy-assignment of the result vector. GCC 15 follows the
inlined vector::operator= chain down into SetParametersResult_ and
cannot prove the internal pointer is non-null.

Bind the results by const reference instead of copying them. The shared
future is copied out of the container before the entry is erased, so the
shared state -- and therefore the value the reference refers to -- stays
alive for the rest of the iteration. Erasing before get() also removes
the need for the catch-and-rethrow: the entry is already gone, so a
service-side exception still surfaces exactly once.

Behaviour is unchanged: an entry is erased exactly once, a failed
set_parameters still throws, and the not-yet-ready path is untouched.

Verified in ghcr.io/ros-navigation/navigation2:main (GCC 15.2): the
package fails to build with colcon exit 2 before this change and builds
clean with exit 0 after it; zone_parameter_filter_test passes 16/16.

Signed-off-by: Akihiko Komada <[email protected]>

* Align ZoneParameterFilter test with current nav2 conventions

Two small drifts this branch had picked up against main:

- Link std_msgs::std_msgs directly. After #6136 replaced the rest,
  ${std_msgs_TARGETS} here was the only remaining use in the repo, and
  binary_filter_test seven lines above already links the target
  directly. Linkage is unchanged.

- Build the test's transform buffer with nav2::create_transform_buffer
  rather than constructing tf2_ros::Buffer by hand, matching the speed,
  keepout and binary filter tests after #6281. This also gives the test
  the timer interface the factory installs. Two includes left unused by
  the change are dropped.

Signed-off-by: Akihiko Komada <[email protected]>

---------

Signed-off-by: Akihiko Komada <[email protected]>
Signed-off-by: Steve Macenski <[email protected]>
Co-authored-by: Steve Macenski <[email protected]>
(cherry picked from commit ea95cc3)
SteveMacenski added a commit that referenced this pull request Aug 12, 2026
…rameter overrides (#6104) (#6334)

* WIP: ZoneParameterFilter — plugin scaffold + test scaffold (slice 1, ~80%)

Slice 1 of nav2#6080 implementation per the source-read milestone-1
artifact at outputs/sprint_131/nav2_6080_source_read.md.

Architecture per Steve Macenski's 2026-04-13 design guidance:
- Mask values 0..255; value 0 = reset to nominal defaults
- Each non-zero state mapped via YAML config to a list of ROS
  parameters (any reachable nav2 parameter on any node)
- No custom enums; raw int + config-driven semantics
- Async parameter setting via per-target-node AsyncParametersClient
  (Steve's preferred pattern from PR #3796 first review)
- Optional state-transition event publication
- Configurable warn|throw policies for unknown-state and
  param-set-failure

PR #3796 burn-pattern guards baked in:
- No wait_for_service in hot path (issue 2): service_is_ready()
  predicate; skip-with-throttled-warn on not-ready
- No empty-string sentinels (issue 4): std::map presence checks
- Future lifetime managed (issue 5): pending_futures_ vector
  drained at top of every process() call; never destruct mid-flight
- Per-node async client (Steve's first review point): one
  AsyncParametersClient per target node, batched parameter sets

Files added:
- nav2_costmap_2d/include/nav2_costmap_2d/costmap_filters/
    zone_parameter_filter.hpp
- nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp
- nav2_costmap_2d/test/unit/zone_parameter_filter_test.cpp

Files edited:
- filter_values.hpp: added ZONE_PARAMETER_FILTER = 4 constant
- costmap_plugins.xml: registered new plugin in filters library
- CMakeLists.txt: added zone_parameter_filter.cpp to filters target
- test/unit/CMakeLists.txt: added zone_parameter_filter_test target

Confidence assessment for slice 1 target (80% today):
- Architectural skeleton complete and follows nav2 conventions
- Source-read evidence cited for every #3796 fix
- All cross-file wiring (XML, CMake, header, impl) in place
- Test scaffold exercises the type-constant and construction paths
- 5/11 test cases from §5 implementation plan present (or as
  documented placeholders); remaining 6 deferred to slice 2 (95%)
- Build verification deferred: no ROS 2 env on this machine; CI
  build is the next gate

Slice 2 (95% target tomorrow) needs:
- colcon build green on humble + jazzy
- Remaining 6 unit tests with full ROS 2 mock harness
- AsyncParametersClient mock for param-mutation assertions
- Coverage measurement (lcov ≥90% per #3796 retrospective)
- File-level review of PR #3796 diff (read summary, not the diff
  itself yet)

Not for PR open — feature branch only. Per D-VGC148, all PR
prose is Komada-authored at PR-open time. Per the commit-or-close
clause to Steve, PR open is committed by 2026-05-16.




* fix(zone_parameter_filter): uncrustify lint nits (Path C build verification round 1)

Three style fixes per ament_uncrustify on rolling:

1. plugins/costmap_filters/zone_parameter_filter.cpp:60-61 — split a
   140-char declare_or_get_parameter call across two lines.
2. plugins/costmap_filters/zone_parameter_filter.cpp:138-140 — same
   for an RCLCPP_ERROR call.
3. test/unit/zone_parameter_filter_test.cpp:72,89 — convert
   single-line destructors to multi-line bodies (matches binary_filter_test
   pattern).

Verification context: Path C source-build in ros:rolling docker
container compiled the package cleanly and ran 4/4 of our new
gtest cases. The 3 failures in the 399-test suite were all
uncrustify diffs on these lines — zero correctness regressions.
This commit closes the lint gates.




* test(zone_parameter_filter): add TestZpf lifecycle fixture + first real test (slice 2a)

Adds a gtest fixture mirroring binary_filter_test.cpp's TestNode pattern,
adapted for ZoneParameterFilter's parameter-mutation semantics:

- TargetNode helper — minimal rclcpp::Node with declared parameters that
  ZPF will mutate via AsyncParametersClient
- TestZpf fixture — LifecycleNode host + separate executors + helpers for
  filter creation, process() invocation, and predicate-based wait
- State1AppliesParameterToTargetNode — first real lifecycle test:
  state_ids=[1] + state_1.zpf_target_node.speed=0.5 fed via
  parameter_overrides; mask filled with 1; pose at center cell;
  process() triggers state 0→1 transition; async set_parameters
  propagates to target node within 1.5s timeout; asserts speed=0.5,
  inflation untouched

Verified on rolling (docker nav2:dev): 5/5 tests pass in 150ms total
(4 scaffold + 1 new lifecycle), zero build warnings, zero test failures.

Slice 2a complete; remaining slice-2b items per scaffold TODO list:
state_zero_resets, unknown_state_warn/throw, state_event_published,
service_not_ready_in_hot_path_does_not_block, etc.




* test(zone_parameter_filter): add 3 lifecycle cases + #3796 regression test (slice 2b)

Extends TestZpf fixture with StateEventSubscriber + rePublishMask helper,
plus three live cases covering distinct ZPF code paths:

- UnknownStateWarnLogsAndKeepsPrevious — exercises on_unknown_state="warn"
  policy: a mask value not in the configured state map must log a
  throttled warn and leave all target parameters unchanged.

- StateEventPublishedOnTransition — exercises optional state_event_pub_:
  when state_event_topic is configured, every transition publishes a
  UInt8 carrying the new state value. Verified via a separate
  StateEventSubscriber on the same in-process executor.

- ServiceNotReadyInHotPathDoesNotBlock — REGRESSION TEST FOR PR #3796
  review item 2 (Steve Macenski + Alexey Merzlyakov, 2023-09 to
  2023-12). When a target node's parameter service is not ready, ZPF
  must NOT call wait_for_service in process(); it must log a throttled
  warn via service_is_ready() and return promptly. Test routes a
  state-1 override at a nonexistent_node and asserts process() returns
  in <500ms (a wait_for_service regression would hang for seconds).

Plus one documented-failure case kept under DISABLED_ prefix:

- DISABLED_State0ResetsToNominalDefaults — surfaces a v0.1 limitation
  in zone_parameter_filter.cpp:383 where nominal_defaults_ stores an
  empty ParameterValue instead of the target's pre-override value.
  resetToNominal() therefore pushes NOT_SET and silently no-ops.
  Proper fix (slice 2c) is to synchronously fetch nominal values at
  initializeFilter() time via spin_until_future_complete with short
  timeout — permitted blocking outside the hot path.

Cosmetic: InfoPublisher now passes multiplier=1.0 (was 0.0) to silence
the "base/multiplier are unused; expected defaults (0.0, 1.0)" warning
emitted by ZPF on filter-info receipt.

Verified on rolling (nav2:dev container, incremental build 22s):
8/8 enabled tests pass in 611ms total. 1 disabled documented as design
intent pending slice 2c fix.




* fix(zone_parameter_filter): YAML-declared nominal_defaults for state-0 reset (slice 2c)

Slice 2b's State0ResetsToNominalDefaults test surfaced a real v0.1 bug:
applyState() inserted an empty `ParameterValue` (NOT_SET type) as a
nominal-default sentinel, then resetToNominal() pushed that empty value
back to the target on state-0 transition — silent no-op, override never
restored. Steve Macenski's #6080 design pointer specifically called out
state-0 reset semantics, so leaving this broken was not an option.

Initial fix candidate was async get-before-set: fire get_parameters then
set_parameters on the same AsyncParametersClient, relying on FIFO to
capture the pre-override value in the get response. Discarded after
inspection: get_parameters and set_parameters use SEPARATE underlying
services::Client instances, so server-side processing order between them
is not guaranteed. A late get response would capture the OVERRIDDEN
value, not the nominal — a worse failure mode than the silent no-op.

Adopted: declarative YAML nominal_defaults. Schema:

  <plugin>.nominal_defaults.<target_node>.<param_path>: <value>

Parsed at loadStateConfig() time (configure phase, blocking permitted).
Race-free, deterministic, zero runtime cost. Matches Steve's "config-
driven" preference verbatim.

Quality-of-life: warn at config-load time for any state-N parameter that
has no matching nominal_defaults entry — such params will not be
restored by state-0 reset, and a v1 user almost certainly wants symmetric
coverage.

Test re-enabled (DISABLED_State0ResetsToNominalDefaults → enabled),
extended to provide the explicit nominal_defaults override. All 9
TestZpf cases pass on rolling (nav2:dev, incremental build 58s):

  State1AppliesParameterToTargetNode      ✅ 162ms
  State0ResetsToNominalDefaults           ✅ 268ms (slice 2c verified)
  UnknownStateWarnLogsAndKeepsPrevious    ✅ 327ms
  StateEventPublishedOnTransition         ✅ 149ms
  ServiceNotReadyInHotPathDoesNotBlock    ✅ 130ms

  Total: 9/9 in 1038ms, 0 disabled, 0 failures.




* fix(zone_parameter_filter): apply CI lint feedback (codespell + uncrustify)

PR #6104 lint workflow surfaced two issues:

- codespell (in pre-commit): flagged "lets" in a comment on
  loadStateConfig (the colon-separator routing comment) as
  potentially "let's". The original word was correct ("permits"
  meaning), but rewording to "routes" preserves the same intent
  while avoiding the false-positive trigger.

- ament_uncrustify: brace-block indentation inside the createFilter
  argument list across all 5 TestZpf cases. Auto-reformatted via
  ament_uncrustify --reformat; 11/11 line shifts.

No functional change. Local verification on rolling (nav2:dev):
ament_uncrustify clean across all 3 ZPF files; 9/9 tests pass in
965ms.




* fix(zone_parameter_filter): explicit target_nodes + 4 audit-driven tests

Addresses findings from a 4-agent swarm audit on PR #6104 (synthesis at
sky/outputs/nav2_6104_pr_audit/synthesis.md):

- F-4 schema: introduce a required `target_nodes: [a, b, ...]` YAML
  parameter and replace first-dot-split parsing with longest-prefix-match
  against the explicit list. The original first-dot-split happens to be
  correct for typical nav2 usage (ROS doesn't allow dots in node names),
  but the explicit list is unambiguous, self-documenting, catches typos
  at config-load, and future-proofs against schema drift.

- F-9 ResetFilterDeactivates: verify resetFilter() clears
  filter_info_received_ and filter_mask_ so isActive() returns false.
  Mirrors binary_filter_test.cpp::testResetFilter.

- F-10 UnknownMaskCellLeavesStateUnchanged: mask filled with
  OCC_GRID_UNKNOWN (-1); verify process() leaves current_state_ + the
  target's parameter untouched. Guards the negative-mask-data branch
  in process().

- F-11 RobotOutsideMaskResetsToState0: drive into state 1, then call
  process() with a pose far outside mask bounds. Verify the state
  auto-resets to 0 and nominal_defaults are restored. Guards the
  worldToMap()-failure branch in process().

- F-4 regression test (LongestPrefixMatchForOverlappingTargetNodes):
  with target_nodes = ["zpf", "zpf_target_node"] and an override
  state_1.zpf_target_node.speed=0.7, verify the longer prefix wins so
  the parameter actually lands on the live target node. A regression
  to naive shortest-prefix would route to the bogus "zpf" service
  and the value would never land.

Verified on rolling (nav2:dev): 13/13 tests pass in 1365ms. Local
ament_uncrustify + ament_cpplint clean.




* [costmap_filters] ZoneParameterFilter: always throw on unknown mask state

Removes the on_unknown_state parameter and the paired UnknownStatePolicy
enum. The hot path now throws std::runtime_error unconditionally when the
mask emits a state value not in the configured state_ids/state_<N> map.

This makes configuration / data-integrity faults fail-safe at the
lifecycle layer rather than continuing with stale parameters. ZPF mutates
parameters on other nodes with safety-relevant downstream effects (speed
caps, inflation radius, controller limits); silently keeping the previous
state when the mask says "I don't know what zone I'm in" is strictly worse
than surfacing the fault to the lifecycle layer where the integrator can
react.

The throw fires at the state_param_map_.find(new_state) miss point, BEFORE
any per-node iteration begins, so no partial-state leak is possible.
Test 8 inverted from UnknownStateWarnLogsAndKeepsPrevious to
UnknownStateThrows (EXPECT_THROW std::runtime_error + post-throw assertion
that the target speed is unchanged at the nominal default).

Addresses the unknown_state half of Steve Macenski's review comment on
zone_parameter_filter.cpp:95 ("Always throw, this is a critical issue
the robot should stop for"). The on_param_set_failure half is treated
separately per the prior reply on the PR.



* [costmap_filters] ZoneParameterFilter: scrub TMI comments

Steve Macenski review on PR #6104: top-level "There's a lot of AI generated
TMI comments throughout the code that should be removed or reduced", plus
inline pins on hpp:101, cpp:78, costmap_plugins.xml:40.

Removed comments that:
- Restated what the surrounding code or variable name already says
  (decorative section dividers, "subscription wiring" headers, "lazily
  build per-node async client" before the lazy lookup, etc.)
- Cited prior reviews back at the reviewer (#3796 references, "Steve's
  preference", "Per #3796 review item N")
- Cited foreign-PR context the reader doesn't need (the future-lifetime
  rationale moves to commit-message context, not header docstring)
- Stated marketing-style framing ("Schema is also self-documenting and
  catches typos at config-load")

Trimmed (kept the WHY-non-obvious in one line):
- kNodeParamSep colon-separator rationale (1 line)
- matchTargetNode longest-prefix-first WHY (2 lines)
- length-descending sort rationale (1 line)
- declarative YAML nominals reasoning (1 line; the auto-capture race is
  non-obvious and survives the upcoming refactor)
- state-N override without nominal warning rationale (1 line)
- retain-across-resets rationale (1 line)
- target_nodes explicit-list necessity (3 lines, still load-bearing for
  the dot-grammar boundary problem)

costmap_plugins.xml:40 description trimmed to one sentence matching the
shape of the other filter entries (no SpeedFilter cross-reference, no
issue link).

Class doxygen on ZoneParameterFilter.hpp simplified — dropped the
@ref SpeedFilter comparison and the issue link.

3 files changed, 20 insertions(+), 92 deletions(-).



* [costmap_filters] ZoneParameterFilter: default state_event_topic to "zone_filter_state"

Steve Macenski review on PR #6104, comment #3150003597 on
zone_parameter_filter.cpp:80: "Set a reasonable default".

- Default state_event_topic from "" to "zone_filter_state".
- Drop the empty-string skip-guard at the publisher creation site;
  always create the publisher.

Matches the speed_filter / keepout_filter / binary_filter idiom — sensible
default-named topic, published unconditionally, user can rename via the
parameter.

Negligible bandwidth cost (~one std_msgs/UInt8 per state transition,
which is a rare event).

Companion docs change in PR #907 (L114) follows in a paired commit.



* [costmap_filters] ZoneParameterFilter: flip on_param_set_failure default to throw

Steve Macenski review on PR #6104, comment on docs PR #907 line 136:
"I question if this should not always throw, since that puts the
application in an undefined state."

Per the PR #6104 reply: keeping the parameter, default-flipping to
throw. The other filters in costmap_filters/ handle transient RPC / tf2
faults uniformly with throttled-warn-and-continue (speed_filter
unknown-mask path; keepout_filter tf2 transform-exception path;
binary_filter unknown-mask path), so collapsing all such transient
classes to a stack-killing exception introduces a second-order failure
mode where a single network blip takes the nav stack down. The
configurable escape preserves the existing nav2 convention for
operators who need transient-class fault discrimination.

The default flip alone honors the safety direction in the review.

Tests: no existing test depends on the warn default for this parameter.

Companion docs change in PR #907 (L136) follows in a paired commit.



* [costmap_filters] ZoneParameterFilter: header restructure (protected + doxygen)

Steve Macenski review on PR #6104, comment #3149982423 on
zone_parameter_filter.hpp:79: "Change to protected and put all methods
before all variables in Nav2 styling. All methods must have doxygen
as well."

- private: → protected: (visibility per ask).
- All 7 helper methods (filterInfoCallback, maskCallback, loadStateConfig,
  applyState, resetToNominal, issueAsyncSetParameters, drainPendingFutures)
  now carry @brief doxygen blocks.
- Method-before-variable ordering preserved (was already correct
  post-Theme-B scrub).

Matches the speed_filter / keepout_filter / binary_filter header layout
shape Steve referenced.



* [costmap_filters] ZoneParameterFilter: init-time param clients + drop readiness probe

Steve Macenski review on PR #6104:
- Comment #3150018176 on cpp:529: "Should we not make these on
  initialization so we don't own the discovery at runtime and building
  for is service ready? If we parse the states, we should be able to
  create our param clients at startup..."
- Comment #3150018587 on cpp:536: "PS this will block indefinitely"

C.3 + C.4 changes (Steve's two comments resolve to one architectural
move):

- loadStateConfig() now enumerates the union of all target_nodes
  referenced by state_param_map_ + nominal_defaults_ and builds one
  AsyncParametersClient per node at init time. Failures are surfaced
  through drainPendingFutures + param_set_failure_policy_ rather than
  through a runtime readiness probe.
- issueAsyncSetParameters() simplified: no lazy construction, no
  service_is_ready() probe. A missing client is now a programmer-error
  (the loadStateConfig enumeration should cover every target_node any
  state mutates), logged as RCLCPP_ERROR + early return.
- service_is_ready() probe removed entirely. Steve's "PS this will
  block indefinitely" reads correctly under the user-facing meaning
  (silent indefinite skip when target never comes up); the C.3
  redesign converts that silent-skip into a surfaceable failure.

Matches the speed_filter / binary_filter init-time-resource pattern.
AsyncParametersClient construction is local-only — registers topics +
service clients locally, does not require the remote service to be
reachable at construction time. Set_parameters becomes
fire-and-forget-with-future-drain.

Out of scope for this PR (carved out per AAA-disciplined Komada
judgment): runtime mutation of the state map ("dynamic parameter
changes of the states" hint Steve raised) is v0.2 scope.

Test impact: Test 10 (ServiceNotReadyInHotPathDoesNotBlock) still
passes the existing assertions (process() under 500ms, no exception
thrown). Will be renamed + re-asserted in the Theme E test-coverage
commit to match the new init-time-clients reality.

Companion docs change in PR #907 (L94 nominal_defaults framing) follows
in a paired commit.



* [costmap_filters] ZoneParameterFilter: replace colon-encoded keys with structured StateParamEntry

Steve Macenski review on PR #6104:
- Top-level: "Some parts of this seem dramatically overcomplicated."
- Inline #3149997318 on cpp:56: "What is going on here & does it need
  to be this way? Seems like this and the function where its used are
  overcomplicated and convoluted"

Theme D — split into two distinct items:

D-1: matchTargetNode kept. The longest-prefix-first match is genuinely
needed because ROS 2 parameter names admit dots, so a flat YAML override
key like `state_1.local_costmap.inflation_layer.inflation_radius` is
ambiguous between targeting `local_costmap` (param `inflation_layer
.inflation_radius`) or `local_costmap.inflation_layer` (param
`inflation_radius`). The user-declared `target_nodes:` list resolves
this. Light style polish (one renamed local for readability).

D-2: replaced colon-encoded `Parameter` keys with a structured
`StateParamEntry { std::string target_node; rclcpp::Parameter param; }`.
Removes:
- The `kNodeParamSep` constant (no separator needed).
- The "<target_node>:<param_name>" encoding in loadStateConfig.
- The colon-parsing in applyState (was rebuilding the same data).
- The colon-parsing in resetToNominal.
- The defensive RCLCPP_ERROR branch for "stored parameter name missing
  separator" — was structurally unreachable since we controlled the
  encoding.

state_param_map_ type: `std::map<uint8_t, std::vector<rclcpp::Parameter>>`
→ `std::map<uint8_t, std::vector<StateParamEntry>>`.

nominal_defaults_ type: `std::map<std::string, rclcpp::Parameter>`
(colon-keyed) → `std::map<std::string, std::vector<rclcpp::Parameter>>`
(keyed by target_node, values are bare-named Parameters). resetToNominal
now iterates the map directly — no per-node batching required, the
data shape already groups by node.

Init-time client enumeration loop (Theme C.3) simplified accordingly:
target_nodes drop straight out of the StateParamEntry / nominal_defaults
keys, no string-parsing.

Net change: -14 lines across .cpp/.hpp; cognitive complexity reduced
materially; one class of bugs gone (a colon character appearing in a
target_node name would have broken the prior encoding silently).

Tests: external behavior unchanged, all existing assertions pass.
Test 14 (LongestPrefixMatchForOverlappingTargetNodes) only inspects the
target node's actual parameter value, not the storage shape, so no
test edit needed.

Theme E (test coverage commit) will add a regression guard against
future colon-encoding reintroduction.



* [costmap_filters] ZoneParameterFilter: expand test coverage 13 → 30 cases

Steve Macenski review on PR #6104, top-level: "Also check the code
coverage metrics, there's enough missing that needs to be added."

Test 10 reworked: was ServiceNotReadyInHotPathDoesNotBlock (asserted
the deleted service_is_ready() probe). Renamed to
ProcessHotPathReturnsPromptlyEvenWithUnreachableTargets and re-commented
to match the post-Theme-C.3 reality: clients are built at init
regardless of remote-service availability; set_parameters becomes
fire-and-forget-with-future-drain; process() returns promptly even when
the target service never appears. Same assertion, accurate framing.

17 new TEST_F cases targeting the warn / error / edge branches the
prior happy-path tests did not exercise:

- 15 InfoRePublishUpdatesMaskSubscription
- 16 MaskRePublishUpdatesFilterMask
- 17 BaseMultiplierNonDefaultDoesNotCrash
- 18 EmptyStateIdsLoadsButDoesNothing
- 19 EmptyTargetNodesLoadsButDoesNothing
- 20 InvalidStateIdInListIsSkipped
- 21 OverrideUnmatchedToTargetNodesIsWarnedAndSkipped
- 22 StateDeclaredWithNoParamsDoesNotCrash
- 23 NominalDefaultsUnmatchedToTargetNodesIsWarned
- 24 StateNWithoutNominalCounterpartWarnsAtConfig
- 25 TransformPoseFailureOrOutOfRangeReturnsCleanly
- 26 OnParamSetFailureWarnPolicyParsedCorrectly
- 27 OnParamSetFailureInvalidValueDefaultsToThrow
- 28 ResetToNominalNoOpWhenNoneConfigured
- 29 MultipleStateTransitionsInSequence
- 30 MultipleParamsInOneStateOnSameNode
- 31 NestedNamespaceTargetNodeRoutesCorrectly
  (Theme D-2 regression guard against future stringly-typed separator
  schemes; the structured StateParamEntry storage means no colon-encoded
  key can leak back in)

Total: 30 test cases (13 prior + 17 new). Estimated coverage delta
+25–30 percentage points; final ~85–90% (subject to gcovr verification
in the next colcon test run).

The on_param_set_failure throw / warn behavioral tests (engineering a
real RPC failure on a remote target) were deferred — they require a
target node fixture that fails set_parameters deterministically (e.g.
read-only parameter, parameter callback rejection), which is ~hour of
fixture work for marginal coverage delta over the parsing tests
(Tests 26 + 27). If the next review cycle requires the behavioral
coverage, those tests get added; the substrate (init-time clients,
drainPendingFutures, throw/warn branches) is in the production code
and exercises through Tests 10 + 22.



* [costmap_filters] ZoneParameterFilter resets N-only params on N→M

Cross-state transitions previously left params touched by state N but not
M at N's value until state-0 reset, leaking N's overrides into M's
behavior. applyState now computes the param-set difference and resets to
nominal_defaults before applying M's overrides, preserving the invariant
that all params equal state-0 defaults except those specifically set in
the active state.

Closes #6104 review thread 3211251415 + review summary item 1.



* [costmap_filters] ZoneParameterFilter: simplify exception flow + scope-prune

Simplifies drainPendingFutures so the future.get() try/catch flows the
exception directly under the configured failure policy rather than
throwing-and-catching internally. Applies the matchTargetNode rewrite
from the review thread (starts_with + size guard). Adds an inline
comment near the override scan stating the routing-only validation
scope so a future reader does not infer cross-target param-existence
checks that this node neither performs nor needs to.

Closes #6104 review threads 3211313270 + 3211335331 + 3211355759.



* [costmap_filters] ZoneParameterFilter: trim redundant comments + rename

Renames drainPendingFutures to checkPendingParameterUpdates so callers
read intent rather than implementation, drops the "Futures / drain"
docstring wording, removes inline comments that restated what the code
or surrounding log already shows, and adds a one-line note above the
parameter-overrides scan stating its intent so a future reader does
not have to infer it from the loop body.

Closes #6104 review threads 3211272912 + 3211274789 + 3211317251 +
3211319835 + 3211328905 + 3211330028 + 3211332786.



* [costmap_filters] ZoneParameterFilter: remove TODO dev-note from test file

Per @SteveMacenski review (#6104 thread 3221447903): the Tests 3-5
header + 11-case-matrix TODO list is not test code and does not
belong in the test file.



* [costmap_filters] ZoneParameterFilter: compress test suite 30 -> 16

Per @SteveMacenski review summary on PR #6104 (#4266595670):
"These tests need to be compressed and make sure they cover all the
active lines of code in this file. This seems extreme"

Sibling baseline: BinaryFilter has 10 TEST_Fs, SpeedFilter has 9. ZPF
landed at 30 cases / 1298 lines, ~3x sibling density. This commit
trims to 16 cases / 688 lines while preserving branch coverage and
adding two previously-missing branches.

Net: 1 TEST + 15 TEST_F, -787 / +156 lines.

Dropped 13 cases:
- Test 3 (FilterInfoTypeCheckRejectsWrongType): STALE - only re-asserted
  a constant inequality; the wrong-type branch in filterInfoCallback
  was never reached. Replaced by WrongFilterInfoTypeIsRejected which
  publishes BINARY_FILTER info and asserts isActive() stays false.
- Test 4 (MaskHelperConstructsExpectedShape): fixture self-test, not
  production code.
- Test 17 (BaseMultiplierNonDefaultDoesNotCrash): warn-only branch
  with no observable behavior.
- Test 21 (OverrideUnmatchedToTargetNodes): unmatched-node warn path,
  now covered by the merged EmptyAndInvalidConfigEdges case.
- Test 23 (NominalDefaultsUnmatchedToTargetNodes): symmetric warn-only
  path, no observable behavior.
- Test 24 (StateNWithoutNominalCounterpartWarns): same gap as Test 35;
  Test 35 (merged into ParamWithoutNominalDefaultsPersists) is the
  canonical assertion.
- Test 25 (TransformPoseFailureOrOutOfRange): weak duplicate of
  Test 13 (RobotOutsideMaskResetsToState0).
- Test 28 (ResetToNominalNoOpWhenNoneConfigured): subsumed by Test 7
  + the empty-config edge cases.
- Test 29 (MultipleStateTransitionsInSequence): cyclic transitions
  add nothing past the in-both + N-only-reset coverage.
- Test 30 (MultipleParamsInOneStateOnSameNode): per-node batching is
  exercised by every multi-param test.
- Test 31 (NestedNamespaceTargetNodeRoutesCorrectly): STALE - comment
  admitted ROS rejects colons; test degenerated to a Test 6 duplicate.
- Test 34 (CyclicTransitionABAReturnsToAValue): same mechanics as
  Test 32 with one extra hop.
- Test 36 (CrossStateTransitionInflationLeakDoesNotPersist): identical
  mechanics to Test 32 with controller-class flavor names.

Merged 8 cases into 5 survivors:
- 15 + 16     -> InfoAndMaskRePublishUpdateSubscriptions
- 18 + 19 + 20 + 22 -> EmptyAndInvalidConfigEdgesDoNotCrash
- 26 + 27     -> OnParamSetFailurePolicyParsing
- 33 + 32     -> CrossStateTransitionResetsParamTouchedByNOnly
- 37 + 35     -> ParamWithoutNominalDefaultsPersistsAcrossTransitions

Added two cases targeting branches the prior 30 did not cover:
- WrongFilterInfoTypeIsRejected: publishes BINARY_FILTER info on the
  ZPF info topic; asserts filterInfoCallback rejects it and isActive()
  never flips. Mirrors binary_filter_test::testIncorrectFilterType.
- OnParamSetFailureThrowsByDefaultAndWarnSwallows: routes state_1 to
  a read-only parameter on TargetNode (declared via ParameterDescriptor
  with read_only=true); set_parameters returns successful=false and
  checkPendingParameterUpdates applies the policy. Asserts default
  policy throws on the failure and "warn" policy swallows it.

Active branches now covered (was uncovered before):
- filterInfoCallback wrong-type rejection (B.2)
- checkPendingParameterUpdates failure path under both kThrow + kWarn (H)

Folded Test 1 + Test 2 (constant uniqueness + default-constructed
inactive) into a single non-fixture TEST. Folded Test 11
(ResetFilterDeactivates) into Test 3's teardown assertion.



* [costmap_filters] ZoneParameterFilter: fix lint findings on test compression

CI failures on 0828ff9:
- ament_uncrustify: inner brace-list of OnParamSetFailurePolicyParsing
  used 8-space indent instead of 6.
- codespell: "waitFor" matched the "wait for" rule with
  write-changes=true and the hook rewrote the helper to "wait for",
  breaking compilation. Renamed to waitForCond throughout (codespell-
  safe; dictionary doesn't carry the compound).

Also refactored two brace-block EXPECT_THROW / EXPECT_NO_THROW
statement bodies in OnParamSetFailureThrowsByDefaultAndWarnSwallows
to lambdas — the brace-block-as-statement form is unconventional
and friendlier to formatters as a lambda call.



* [costmap_filters] ZoneParameterFilter: avoid codespell lets-let's misfire

codespell 2.4.1 (used by nav2 pre-commit cache) rewrites "lets" to
"let's" via the informal rule, even where "lets" is the correct
verb form. The comment on createFilter() tripped this in CI. Rephrase
to "allows ... to inject" so codespell stays quiet without an
ignore-words entry that the maintainers would have to maintain.



* [costmap_filters] ZoneParameterFilter: read declared configuration

Per review feedback: replace get_parameter_overrides() scraping with
explicit declared parameters. The state, target node, parameter, and
value are all declared configuration now — introspectable via
'ros2 param get' and type-validated at load.

- New schema: <filter>.states (names) -> <name>.{id, overrides} ->
  <override>.{node, parameter, value} (dynamic-typed value), plus
  <filter>.nominal_defaults for the state-0 reset baseline.
- Remove matchTargetNode()/longest-prefix routing and the length sort:
  with node and parameter explicit there is nothing to disambiguate.
- Remove the on_param_set_failure policy: a failed set always throws
  (a failed parameter set on a safety parameter is a stop condition).
- Rewrite the unit tests to the declared schema (16 tests; the
  longest-prefix test becomes explicit two-node routing, and the
  policy-parsing test now proves a leftover policy override neither
  breaks config-load nor softens the always-throw).



* [costmap_filters] ZoneParameterFilter: fix uncrustify continuation indent

Whitespace-only (verified: 'git diff -w' empty); ament_uncrustify now
reports no divergence on all three files.



* [costmap_filters] ZoneParameterFilter: address review round 3

- Rename the per-state key 'overrides' to 'setpoints' in the parameter
  schema and the log strings (reviewer preference). This renames this
  PR's own key <state>.overrides -> <state>.setpoints; nothing in docs
  or YAML referenced the old name, so it is code and tests only.
- Use 'auto' for all three node_.lock() sites.
- Drop the dead 'found' flag and its '(void)found' silencer in
  applyState(); the loop already breaks on the match and the gap case
  is handled by the preceding continue.

The comment rewrites requested in the same review round are not in this
commit and follow separately.



* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp



* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp



* [costmap_filters] ZoneParameterFilter: clarify comments + guard state/map divergence

- read_entry: rewrite the block comment to explain why `value` alone is
  declared dynamic_typing (one override path carries a parameter of any
  type), instead of narrating what the code already shows.
- state-reset loop: rewrite the `continue` comment (no nominal default ->
  the param keeps state N's value; already warned at config-load); drop the
  stray "Test 24" reference.
- checkPendingParameterUpdates: rewrite to the safety rationale -- a failed
  safety-zone parameter set is rethrown, never logged-and-swallowed.
- applyState: add an RCLCPP_ERROR when current_state_ is not in
  state_param_map_ (a tracked-state/map divergence that should never happen),
  matching the existing 'should have been built at config-load' error.

zone_parameter_filter suite: 16/16 passing (built against nav2 rolling).



* [costmap_filters] ZoneParameterFilter: tighten remaining comments + fix two inaccurate ones

Follow-up cleanup of the rest of the file's comments to the same why-only standard,
and correction of two that were wrong:
- the reset/apply comment claimed issueAsyncSetParameters preserves submission order
  on a per-node future queue; no such queue exists — it push_backs into a single flat
  pending_futures_ used only for completion polling. The only ordering guarantee is
  that the reset loop runs before the apply loop.
- resetFilter's retained-maps comment named only nominal_defaults_ and param_clients_;
  state_param_map_ also persists across resets.

Also trimmed the read_entry / client-construction / checkPendingParameterUpdates blocks
to their load-bearing rationale and dropped section-marker comments that restated the
code. Comments only; no behavior change. zone_parameter_filter suite: 16/16.



* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp



* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp



* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp



* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp



* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp



* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp



* fix: declare reset_per_node map in ZoneParameterFilter::applyState



* Fix -Werror=null-dereference in ZoneParameterFilter on GCC 15

The nav2 CI image refreshed on 2026-08-07 and now ships GCC 15.2, whose
inliner rejects checkPendingParameterUpdates():

  error: potential null pointer dereference [-Werror=null-dereference]
    inlined from 'std::vector<_Tp, _Alloc>::operator=(const vector&)'
      at /usr/include/c++/15/bits/vector.tcc:250:21,
    inlined from 'ZoneParameterFilter::checkPendingParameterUpdates()'
      at zone_parameter_filter.cpp:484:25

pending_futures_ holds std::shared_future, and shared_future::get()
returns a const reference rather than a value, so `results = it->get()`
was a full copy-assignment of the result vector. GCC 15 follows the
inlined vector::operator= chain down into SetParametersResult_ and
cannot prove the internal pointer is non-null.

Bind the results by const reference instead of copying them. The shared
future is copied out of the container before the entry is erased, so the
shared state -- and therefore the value the reference refers to -- stays
alive for the rest of the iteration. Erasing before get() also removes
the need for the catch-and-rethrow: the entry is already gone, so a
service-side exception still surfaces exactly once.

Behaviour is unchanged: an entry is erased exactly once, a failed
set_parameters still throws, and the not-yet-ready path is untouched.

Verified in ghcr.io/ros-navigation/navigation2:main (GCC 15.2): the
package fails to build with colcon exit 2 before this change and builds
clean with exit 0 after it; zone_parameter_filter_test passes 16/16.



* Align ZoneParameterFilter test with current nav2 conventions

Two small drifts this branch had picked up against main:

- Link std_msgs::std_msgs directly. After #6136 replaced the rest,
  ${std_msgs_TARGETS} here was the only remaining use in the repo, and
  binary_filter_test seven lines above already links the target
  directly. Linkage is unchanged.

- Build the test's transform buffer with nav2::create_transform_buffer
  rather than constructing tf2_ros::Buffer by hand, matching the speed,
  keepout and binary filter tests after #6281. This also gives the test
  the timer interface the factory installs. Two includes left unused by
  the change are dropped.



---------




(cherry picked from commit ea95cc3)

Signed-off-by: Akihiko Komada <[email protected]>
Signed-off-by: Steve Macenski <[email protected]>
Co-authored-by: Akihiko Komada <[email protected]>
Co-authored-by: Steve Macenski <[email protected]>
mini-1235 pushed a commit to mini-1235/navigation2 that referenced this pull request Aug 16, 2026
…rameter overrides (ros-navigation#6104)

* WIP: ZoneParameterFilter — plugin scaffold + test scaffold (slice 1, ~80%)

Slice 1 of nav2#6080 implementation per the source-read milestone-1
artifact at outputs/sprint_131/nav2_6080_source_read.md.

Architecture per Steve Macenski's 2026-04-13 design guidance:
- Mask values 0..255; value 0 = reset to nominal defaults
- Each non-zero state mapped via YAML config to a list of ROS
  parameters (any reachable nav2 parameter on any node)
- No custom enums; raw int + config-driven semantics
- Async parameter setting via per-target-node AsyncParametersClient
  (Steve's preferred pattern from PR ros-navigation#3796 first review)
- Optional state-transition event publication
- Configurable warn|throw policies for unknown-state and
  param-set-failure

PR ros-navigation#3796 burn-pattern guards baked in:
- No wait_for_service in hot path (issue 2): service_is_ready()
  predicate; skip-with-throttled-warn on not-ready
- No empty-string sentinels (issue 4): std::map presence checks
- Future lifetime managed (issue 5): pending_futures_ vector
  drained at top of every process() call; never destruct mid-flight
- Per-node async client (Steve's first review point): one
  AsyncParametersClient per target node, batched parameter sets

Files added:
- nav2_costmap_2d/include/nav2_costmap_2d/costmap_filters/
    zone_parameter_filter.hpp
- nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp
- nav2_costmap_2d/test/unit/zone_parameter_filter_test.cpp

Files edited:
- filter_values.hpp: added ZONE_PARAMETER_FILTER = 4 constant
- costmap_plugins.xml: registered new plugin in filters library
- CMakeLists.txt: added zone_parameter_filter.cpp to filters target
- test/unit/CMakeLists.txt: added zone_parameter_filter_test target

Confidence assessment for slice 1 target (80% today):
- Architectural skeleton complete and follows nav2 conventions
- Source-read evidence cited for every ros-navigation#3796 fix
- All cross-file wiring (XML, CMake, header, impl) in place
- Test scaffold exercises the type-constant and construction paths
- 5/11 test cases from §5 implementation plan present (or as
  documented placeholders); remaining 6 deferred to slice 2 (95%)
- Build verification deferred: no ROS 2 env on this machine; CI
  build is the next gate

Slice 2 (95% target tomorrow) needs:
- colcon build green on humble + jazzy
- Remaining 6 unit tests with full ROS 2 mock harness
- AsyncParametersClient mock for param-mutation assertions
- Coverage measurement (lcov ≥90% per ros-navigation#3796 retrospective)
- File-level review of PR ros-navigation#3796 diff (read summary, not the diff
  itself yet)

Not for PR open — feature branch only. Per D-VGC148, all PR
prose is Komada-authored at PR-open time. Per the commit-or-close
clause to Steve, PR open is committed by 2026-05-16.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): uncrustify lint nits (Path C build verification round 1)

Three style fixes per ament_uncrustify on rolling:

1. plugins/costmap_filters/zone_parameter_filter.cpp:60-61 — split a
   140-char declare_or_get_parameter call across two lines.
2. plugins/costmap_filters/zone_parameter_filter.cpp:138-140 — same
   for an RCLCPP_ERROR call.
3. test/unit/zone_parameter_filter_test.cpp:72,89 — convert
   single-line destructors to multi-line bodies (matches binary_filter_test
   pattern).

Verification context: Path C source-build in ros:rolling docker
container compiled the package cleanly and ran 4/4 of our new
gtest cases. The 3 failures in the 399-test suite were all
uncrustify diffs on these lines — zero correctness regressions.
This commit closes the lint gates.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* test(zone_parameter_filter): add TestZpf lifecycle fixture + first real test (slice 2a)

Adds a gtest fixture mirroring binary_filter_test.cpp's TestNode pattern,
adapted for ZoneParameterFilter's parameter-mutation semantics:

- TargetNode helper — minimal rclcpp::Node with declared parameters that
  ZPF will mutate via AsyncParametersClient
- TestZpf fixture — LifecycleNode host + separate executors + helpers for
  filter creation, process() invocation, and predicate-based wait
- State1AppliesParameterToTargetNode — first real lifecycle test:
  state_ids=[1] + state_1.zpf_target_node.speed=0.5 fed via
  parameter_overrides; mask filled with 1; pose at center cell;
  process() triggers state 0→1 transition; async set_parameters
  propagates to target node within 1.5s timeout; asserts speed=0.5,
  inflation untouched

Verified on rolling (docker nav2:dev): 5/5 tests pass in 150ms total
(4 scaffold + 1 new lifecycle), zero build warnings, zero test failures.

Slice 2a complete; remaining slice-2b items per scaffold TODO list:
state_zero_resets, unknown_state_warn/throw, state_event_published,
service_not_ready_in_hot_path_does_not_block, etc.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* test(zone_parameter_filter): add 3 lifecycle cases + ros-navigation#3796 regression test (slice 2b)

Extends TestZpf fixture with StateEventSubscriber + rePublishMask helper,
plus three live cases covering distinct ZPF code paths:

- UnknownStateWarnLogsAndKeepsPrevious — exercises on_unknown_state="warn"
  policy: a mask value not in the configured state map must log a
  throttled warn and leave all target parameters unchanged.

- StateEventPublishedOnTransition — exercises optional state_event_pub_:
  when state_event_topic is configured, every transition publishes a
  UInt8 carrying the new state value. Verified via a separate
  StateEventSubscriber on the same in-process executor.

- ServiceNotReadyInHotPathDoesNotBlock — REGRESSION TEST FOR PR ros-navigation#3796
  review item 2 (Steve Macenski + Alexey Merzlyakov, 2023-09 to
  2023-12). When a target node's parameter service is not ready, ZPF
  must NOT call wait_for_service in process(); it must log a throttled
  warn via service_is_ready() and return promptly. Test routes a
  state-1 override at a nonexistent_node and asserts process() returns
  in <500ms (a wait_for_service regression would hang for seconds).

Plus one documented-failure case kept under DISABLED_ prefix:

- DISABLED_State0ResetsToNominalDefaults — surfaces a v0.1 limitation
  in zone_parameter_filter.cpp:383 where nominal_defaults_ stores an
  empty ParameterValue instead of the target's pre-override value.
  resetToNominal() therefore pushes NOT_SET and silently no-ops.
  Proper fix (slice 2c) is to synchronously fetch nominal values at
  initializeFilter() time via spin_until_future_complete with short
  timeout — permitted blocking outside the hot path.

Cosmetic: InfoPublisher now passes multiplier=1.0 (was 0.0) to silence
the "base/multiplier are unused; expected defaults (0.0, 1.0)" warning
emitted by ZPF on filter-info receipt.

Verified on rolling (nav2:dev container, incremental build 22s):
8/8 enabled tests pass in 611ms total. 1 disabled documented as design
intent pending slice 2c fix.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): YAML-declared nominal_defaults for state-0 reset (slice 2c)

Slice 2b's State0ResetsToNominalDefaults test surfaced a real v0.1 bug:
applyState() inserted an empty `ParameterValue` (NOT_SET type) as a
nominal-default sentinel, then resetToNominal() pushed that empty value
back to the target on state-0 transition — silent no-op, override never
restored. Steve Macenski's ros-navigation#6080 design pointer specifically called out
state-0 reset semantics, so leaving this broken was not an option.

Initial fix candidate was async get-before-set: fire get_parameters then
set_parameters on the same AsyncParametersClient, relying on FIFO to
capture the pre-override value in the get response. Discarded after
inspection: get_parameters and set_parameters use SEPARATE underlying
services::Client instances, so server-side processing order between them
is not guaranteed. A late get response would capture the OVERRIDDEN
value, not the nominal — a worse failure mode than the silent no-op.

Adopted: declarative YAML nominal_defaults. Schema:

  <plugin>.nominal_defaults.<target_node>.<param_path>: <value>

Parsed at loadStateConfig() time (configure phase, blocking permitted).
Race-free, deterministic, zero runtime cost. Matches Steve's "config-
driven" preference verbatim.

Quality-of-life: warn at config-load time for any state-N parameter that
has no matching nominal_defaults entry — such params will not be
restored by state-0 reset, and a v1 user almost certainly wants symmetric
coverage.

Test re-enabled (DISABLED_State0ResetsToNominalDefaults → enabled),
extended to provide the explicit nominal_defaults override. All 9
TestZpf cases pass on rolling (nav2:dev, incremental build 58s):

  State1AppliesParameterToTargetNode      ✅ 162ms
  State0ResetsToNominalDefaults           ✅ 268ms (slice 2c verified)
  UnknownStateWarnLogsAndKeepsPrevious    ✅ 327ms
  StateEventPublishedOnTransition         ✅ 149ms
  ServiceNotReadyInHotPathDoesNotBlock    ✅ 130ms

  Total: 9/9 in 1038ms, 0 disabled, 0 failures.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): apply CI lint feedback (codespell + uncrustify)

PR ros-navigation#6104 lint workflow surfaced two issues:

- codespell (in pre-commit): flagged "lets" in a comment on
  loadStateConfig (the colon-separator routing comment) as
  potentially "let's". The original word was correct ("permits"
  meaning), but rewording to "routes" preserves the same intent
  while avoiding the false-positive trigger.

- ament_uncrustify: brace-block indentation inside the createFilter
  argument list across all 5 TestZpf cases. Auto-reformatted via
  ament_uncrustify --reformat; 11/11 line shifts.

No functional change. Local verification on rolling (nav2:dev):
ament_uncrustify clean across all 3 ZPF files; 9/9 tests pass in
965ms.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): explicit target_nodes + 4 audit-driven tests

Addresses findings from a 4-agent swarm audit on PR ros-navigation#6104 (synthesis at
sky/outputs/nav2_6104_pr_audit/synthesis.md):

- F-4 schema: introduce a required `target_nodes: [a, b, ...]` YAML
  parameter and replace first-dot-split parsing with longest-prefix-match
  against the explicit list. The original first-dot-split happens to be
  correct for typical nav2 usage (ROS doesn't allow dots in node names),
  but the explicit list is unambiguous, self-documenting, catches typos
  at config-load, and future-proofs against schema drift.

- F-9 ResetFilterDeactivates: verify resetFilter() clears
  filter_info_received_ and filter_mask_ so isActive() returns false.
  Mirrors binary_filter_test.cpp::testResetFilter.

- F-10 UnknownMaskCellLeavesStateUnchanged: mask filled with
  OCC_GRID_UNKNOWN (-1); verify process() leaves current_state_ + the
  target's parameter untouched. Guards the negative-mask-data branch
  in process().

- F-11 RobotOutsideMaskResetsToState0: drive into state 1, then call
  process() with a pose far outside mask bounds. Verify the state
  auto-resets to 0 and nominal_defaults are restored. Guards the
  worldToMap()-failure branch in process().

- F-4 regression test (LongestPrefixMatchForOverlappingTargetNodes):
  with target_nodes = ["zpf", "zpf_target_node"] and an override
  state_1.zpf_target_node.speed=0.7, verify the longer prefix wins so
  the parameter actually lands on the live target node. A regression
  to naive shortest-prefix would route to the bogus "zpf" service
  and the value would never land.

Verified on rolling (nav2:dev): 13/13 tests pass in 1365ms. Local
ament_uncrustify + ament_cpplint clean.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: always throw on unknown mask state

Removes the on_unknown_state parameter and the paired UnknownStatePolicy
enum. The hot path now throws std::runtime_error unconditionally when the
mask emits a state value not in the configured state_ids/state_<N> map.

This makes configuration / data-integrity faults fail-safe at the
lifecycle layer rather than continuing with stale parameters. ZPF mutates
parameters on other nodes with safety-relevant downstream effects (speed
caps, inflation radius, controller limits); silently keeping the previous
state when the mask says "I don't know what zone I'm in" is strictly worse
than surfacing the fault to the lifecycle layer where the integrator can
react.

The throw fires at the state_param_map_.find(new_state) miss point, BEFORE
any per-node iteration begins, so no partial-state leak is possible.
Test 8 inverted from UnknownStateWarnLogsAndKeepsPrevious to
UnknownStateThrows (EXPECT_THROW std::runtime_error + post-throw assertion
that the target speed is unchanged at the nominal default).

Addresses the unknown_state half of Steve Macenski's review comment on
zone_parameter_filter.cpp:95 ("Always throw, this is a critical issue
the robot should stop for"). The on_param_set_failure half is treated
separately per the prior reply on the PR.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: scrub TMI comments

Steve Macenski review on PR ros-navigation#6104: top-level "There's a lot of AI generated
TMI comments throughout the code that should be removed or reduced", plus
inline pins on hpp:101, cpp:78, costmap_plugins.xml:40.

Removed comments that:
- Restated what the surrounding code or variable name already says
  (decorative section dividers, "subscription wiring" headers, "lazily
  build per-node async client" before the lazy lookup, etc.)
- Cited prior reviews back at the reviewer (ros-navigation#3796 references, "Steve's
  preference", "Per ros-navigation#3796 review item N")
- Cited foreign-PR context the reader doesn't need (the future-lifetime
  rationale moves to commit-message context, not header docstring)
- Stated marketing-style framing ("Schema is also self-documenting and
  catches typos at config-load")

Trimmed (kept the WHY-non-obvious in one line):
- kNodeParamSep colon-separator rationale (1 line)
- matchTargetNode longest-prefix-first WHY (2 lines)
- length-descending sort rationale (1 line)
- declarative YAML nominals reasoning (1 line; the auto-capture race is
  non-obvious and survives the upcoming refactor)
- state-N override without nominal warning rationale (1 line)
- retain-across-resets rationale (1 line)
- target_nodes explicit-list necessity (3 lines, still load-bearing for
  the dot-grammar boundary problem)

costmap_plugins.xml:40 description trimmed to one sentence matching the
shape of the other filter entries (no SpeedFilter cross-reference, no
issue link).

Class doxygen on ZoneParameterFilter.hpp simplified — dropped the
@ref SpeedFilter comparison and the issue link.

3 files changed, 20 insertions(+), 92 deletions(-).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: default state_event_topic to "zone_filter_state"

Steve Macenski review on PR ros-navigation#6104, comment #3150003597 on
zone_parameter_filter.cpp:80: "Set a reasonable default".

- Default state_event_topic from "" to "zone_filter_state".
- Drop the empty-string skip-guard at the publisher creation site;
  always create the publisher.

Matches the speed_filter / keepout_filter / binary_filter idiom — sensible
default-named topic, published unconditionally, user can rename via the
parameter.

Negligible bandwidth cost (~one std_msgs/UInt8 per state transition,
which is a rare event).

Companion docs change in PR ros-navigation#907 (L114) follows in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: flip on_param_set_failure default to throw

Steve Macenski review on PR ros-navigation#6104, comment on docs PR ros-navigation#907 line 136:
"I question if this should not always throw, since that puts the
application in an undefined state."

Per the PR ros-navigation#6104 reply: keeping the parameter, default-flipping to
throw. The other filters in costmap_filters/ handle transient RPC / tf2
faults uniformly with throttled-warn-and-continue (speed_filter
unknown-mask path; keepout_filter tf2 transform-exception path;
binary_filter unknown-mask path), so collapsing all such transient
classes to a stack-killing exception introduces a second-order failure
mode where a single network blip takes the nav stack down. The
configurable escape preserves the existing nav2 convention for
operators who need transient-class fault discrimination.

The default flip alone honors the safety direction in the review.

Tests: no existing test depends on the warn default for this parameter.

Companion docs change in PR ros-navigation#907 (L136) follows in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: header restructure (protected + doxygen)

Steve Macenski review on PR ros-navigation#6104, comment #3149982423 on
zone_parameter_filter.hpp:79: "Change to protected and put all methods
before all variables in Nav2 styling. All methods must have doxygen
as well."

- private: → protected: (visibility per ask).
- All 7 helper methods (filterInfoCallback, maskCallback, loadStateConfig,
  applyState, resetToNominal, issueAsyncSetParameters, drainPendingFutures)
  now carry @brief doxygen blocks.
- Method-before-variable ordering preserved (was already correct
  post-Theme-B scrub).

Matches the speed_filter / keepout_filter / binary_filter header layout
shape Steve referenced.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: init-time param clients + drop readiness probe

Steve Macenski review on PR ros-navigation#6104:
- Comment #3150018176 on cpp:529: "Should we not make these on
  initialization so we don't own the discovery at runtime and building
  for is service ready? If we parse the states, we should be able to
  create our param clients at startup..."
- Comment #3150018587 on cpp:536: "PS this will block indefinitely"

C.3 + C.4 changes (Steve's two comments resolve to one architectural
move):

- loadStateConfig() now enumerates the union of all target_nodes
  referenced by state_param_map_ + nominal_defaults_ and builds one
  AsyncParametersClient per node at init time. Failures are surfaced
  through drainPendingFutures + param_set_failure_policy_ rather than
  through a runtime readiness probe.
- issueAsyncSetParameters() simplified: no lazy construction, no
  service_is_ready() probe. A missing client is now a programmer-error
  (the loadStateConfig enumeration should cover every target_node any
  state mutates), logged as RCLCPP_ERROR + early return.
- service_is_ready() probe removed entirely. Steve's "PS this will
  block indefinitely" reads correctly under the user-facing meaning
  (silent indefinite skip when target never comes up); the C.3
  redesign converts that silent-skip into a surfaceable failure.

Matches the speed_filter / binary_filter init-time-resource pattern.
AsyncParametersClient construction is local-only — registers topics +
service clients locally, does not require the remote service to be
reachable at construction time. Set_parameters becomes
fire-and-forget-with-future-drain.

Out of scope for this PR (carved out per AAA-disciplined Komada
judgment): runtime mutation of the state map ("dynamic parameter
changes of the states" hint Steve raised) is v0.2 scope.

Test impact: Test 10 (ServiceNotReadyInHotPathDoesNotBlock) still
passes the existing assertions (process() under 500ms, no exception
thrown). Will be renamed + re-asserted in the Theme E test-coverage
commit to match the new init-time-clients reality.

Companion docs change in PR ros-navigation#907 (L94 nominal_defaults framing) follows
in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: replace colon-encoded keys with structured StateParamEntry

Steve Macenski review on PR ros-navigation#6104:
- Top-level: "Some parts of this seem dramatically overcomplicated."
- Inline #3149997318 on cpp:56: "What is going on here & does it need
  to be this way? Seems like this and the function where its used are
  overcomplicated and convoluted"

Theme D — split into two distinct items:

D-1: matchTargetNode kept. The longest-prefix-first match is genuinely
needed because ROS 2 parameter names admit dots, so a flat YAML override
key like `state_1.local_costmap.inflation_layer.inflation_radius` is
ambiguous between targeting `local_costmap` (param `inflation_layer
.inflation_radius`) or `local_costmap.inflation_layer` (param
`inflation_radius`). The user-declared `target_nodes:` list resolves
this. Light style polish (one renamed local for readability).

D-2: replaced colon-encoded `Parameter` keys with a structured
`StateParamEntry { std::string target_node; rclcpp::Parameter param; }`.
Removes:
- The `kNodeParamSep` constant (no separator needed).
- The "<target_node>:<param_name>" encoding in loadStateConfig.
- The colon-parsing in applyState (was rebuilding the same data).
- The colon-parsing in resetToNominal.
- The defensive RCLCPP_ERROR branch for "stored parameter name missing
  separator" — was structurally unreachable since we controlled the
  encoding.

state_param_map_ type: `std::map<uint8_t, std::vector<rclcpp::Parameter>>`
→ `std::map<uint8_t, std::vector<StateParamEntry>>`.

nominal_defaults_ type: `std::map<std::string, rclcpp::Parameter>`
(colon-keyed) → `std::map<std::string, std::vector<rclcpp::Parameter>>`
(keyed by target_node, values are bare-named Parameters). resetToNominal
now iterates the map directly — no per-node batching required, the
data shape already groups by node.

Init-time client enumeration loop (Theme C.3) simplified accordingly:
target_nodes drop straight out of the StateParamEntry / nominal_defaults
keys, no string-parsing.

Net change: -14 lines across .cpp/.hpp; cognitive complexity reduced
materially; one class of bugs gone (a colon character appearing in a
target_node name would have broken the prior encoding silently).

Tests: external behavior unchanged, all existing assertions pass.
Test 14 (LongestPrefixMatchForOverlappingTargetNodes) only inspects the
target node's actual parameter value, not the storage shape, so no
test edit needed.

Theme E (test coverage commit) will add a regression guard against
future colon-encoding reintroduction.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: expand test coverage 13 → 30 cases

Steve Macenski review on PR ros-navigation#6104, top-level: "Also check the code
coverage metrics, there's enough missing that needs to be added."

Test 10 reworked: was ServiceNotReadyInHotPathDoesNotBlock (asserted
the deleted service_is_ready() probe). Renamed to
ProcessHotPathReturnsPromptlyEvenWithUnreachableTargets and re-commented
to match the post-Theme-C.3 reality: clients are built at init
regardless of remote-service availability; set_parameters becomes
fire-and-forget-with-future-drain; process() returns promptly even when
the target service never appears. Same assertion, accurate framing.

17 new TEST_F cases targeting the warn / error / edge branches the
prior happy-path tests did not exercise:

- 15 InfoRePublishUpdatesMaskSubscription
- 16 MaskRePublishUpdatesFilterMask
- 17 BaseMultiplierNonDefaultDoesNotCrash
- 18 EmptyStateIdsLoadsButDoesNothing
- 19 EmptyTargetNodesLoadsButDoesNothing
- 20 InvalidStateIdInListIsSkipped
- 21 OverrideUnmatchedToTargetNodesIsWarnedAndSkipped
- 22 StateDeclaredWithNoParamsDoesNotCrash
- 23 NominalDefaultsUnmatchedToTargetNodesIsWarned
- 24 StateNWithoutNominalCounterpartWarnsAtConfig
- 25 TransformPoseFailureOrOutOfRangeReturnsCleanly
- 26 OnParamSetFailureWarnPolicyParsedCorrectly
- 27 OnParamSetFailureInvalidValueDefaultsToThrow
- 28 ResetToNominalNoOpWhenNoneConfigured
- 29 MultipleStateTransitionsInSequence
- 30 MultipleParamsInOneStateOnSameNode
- 31 NestedNamespaceTargetNodeRoutesCorrectly
  (Theme D-2 regression guard against future stringly-typed separator
  schemes; the structured StateParamEntry storage means no colon-encoded
  key can leak back in)

Total: 30 test cases (13 prior + 17 new). Estimated coverage delta
+25–30 percentage points; final ~85–90% (subject to gcovr verification
in the next colcon test run).

The on_param_set_failure throw / warn behavioral tests (engineering a
real RPC failure on a remote target) were deferred — they require a
target node fixture that fails set_parameters deterministically (e.g.
read-only parameter, parameter callback rejection), which is ~hour of
fixture work for marginal coverage delta over the parsing tests
(Tests 26 + 27). If the next review cycle requires the behavioral
coverage, those tests get added; the substrate (init-time clients,
drainPendingFutures, throw/warn branches) is in the production code
and exercises through Tests 10 + 22.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter resets N-only params on N→M

Cross-state transitions previously left params touched by state N but not
M at N's value until state-0 reset, leaking N's overrides into M's
behavior. applyState now computes the param-set difference and resets to
nominal_defaults before applying M's overrides, preserving the invariant
that all params equal state-0 defaults except those specifically set in
the active state.

Closes ros-navigation#6104 review thread 3211251415 + review summary item 1.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: simplify exception flow + scope-prune

Simplifies drainPendingFutures so the future.get() try/catch flows the
exception directly under the configured failure policy rather than
throwing-and-catching internally. Applies the matchTargetNode rewrite
from the review thread (starts_with + size guard). Adds an inline
comment near the override scan stating the routing-only validation
scope so a future reader does not infer cross-target param-existence
checks that this node neither performs nor needs to.

Closes ros-navigation#6104 review threads 3211313270 + 3211335331 + 3211355759.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: trim redundant comments + rename

Renames drainPendingFutures to checkPendingParameterUpdates so callers
read intent rather than implementation, drops the "Futures / drain"
docstring wording, removes inline comments that restated what the code
or surrounding log already shows, and adds a one-line note above the
parameter-overrides scan stating its intent so a future reader does
not have to infer it from the loop body.

Closes ros-navigation#6104 review threads 3211272912 + 3211274789 + 3211317251 +
3211319835 + 3211328905 + 3211330028 + 3211332786.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: remove TODO dev-note from test file

Per @SteveMacenski review (ros-navigation#6104 thread 3221447903): the Tests 3-5
header + 11-case-matrix TODO list is not test code and does not
belong in the test file.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: compress test suite 30 -> 16

Per @SteveMacenski review summary on PR ros-navigation#6104 (#4266595670):
"These tests need to be compressed and make sure they cover all the
active lines of code in this file. This seems extreme"

Sibling baseline: BinaryFilter has 10 TEST_Fs, SpeedFilter has 9. ZPF
landed at 30 cases / 1298 lines, ~3x sibling density. This commit
trims to 16 cases / 688 lines while preserving branch coverage and
adding two previously-missing branches.

Net: 1 TEST + 15 TEST_F, -787 / +156 lines.

Dropped 13 cases:
- Test 3 (FilterInfoTypeCheckRejectsWrongType): STALE - only re-asserted
  a constant inequality; the wrong-type branch in filterInfoCallback
  was never reached. Replaced by WrongFilterInfoTypeIsRejected which
  publishes BINARY_FILTER info and asserts isActive() stays false.
- Test 4 (MaskHelperConstructsExpectedShape): fixture self-test, not
  production code.
- Test 17 (BaseMultiplierNonDefaultDoesNotCrash): warn-only branch
  with no observable behavior.
- Test 21 (OverrideUnmatchedToTargetNodes): unmatched-node warn path,
  now covered by the merged EmptyAndInvalidConfigEdges case.
- Test 23 (NominalDefaultsUnmatchedToTargetNodes): symmetric warn-only
  path, no observable behavior.
- Test 24 (StateNWithoutNominalCounterpartWarns): same gap as Test 35;
  Test 35 (merged into ParamWithoutNominalDefaultsPersists) is the
  canonical assertion.
- Test 25 (TransformPoseFailureOrOutOfRange): weak duplicate of
  Test 13 (RobotOutsideMaskResetsToState0).
- Test 28 (ResetToNominalNoOpWhenNoneConfigured): subsumed by Test 7
  + the empty-config edge cases.
- Test 29 (MultipleStateTransitionsInSequence): cyclic transitions
  add nothing past the in-both + N-only-reset coverage.
- Test 30 (MultipleParamsInOneStateOnSameNode): per-node batching is
  exercised by every multi-param test.
- Test 31 (NestedNamespaceTargetNodeRoutesCorrectly): STALE - comment
  admitted ROS rejects colons; test degenerated to a Test 6 duplicate.
- Test 34 (CyclicTransitionABAReturnsToAValue): same mechanics as
  Test 32 with one extra hop.
- Test 36 (CrossStateTransitionInflationLeakDoesNotPersist): identical
  mechanics to Test 32 with controller-class flavor names.

Merged 8 cases into 5 survivors:
- 15 + 16     -> InfoAndMaskRePublishUpdateSubscriptions
- 18 + 19 + 20 + 22 -> EmptyAndInvalidConfigEdgesDoNotCrash
- 26 + 27     -> OnParamSetFailurePolicyParsing
- 33 + 32     -> CrossStateTransitionResetsParamTouchedByNOnly
- 37 + 35     -> ParamWithoutNominalDefaultsPersistsAcrossTransitions

Added two cases targeting branches the prior 30 did not cover:
- WrongFilterInfoTypeIsRejected: publishes BINARY_FILTER info on the
  ZPF info topic; asserts filterInfoCallback rejects it and isActive()
  never flips. Mirrors binary_filter_test::testIncorrectFilterType.
- OnParamSetFailureThrowsByDefaultAndWarnSwallows: routes state_1 to
  a read-only parameter on TargetNode (declared via ParameterDescriptor
  with read_only=true); set_parameters returns successful=false and
  checkPendingParameterUpdates applies the policy. Asserts default
  policy throws on the failure and "warn" policy swallows it.

Active branches now covered (was uncovered before):
- filterInfoCallback wrong-type rejection (B.2)
- checkPendingParameterUpdates failure path under both kThrow + kWarn (H)

Folded Test 1 + Test 2 (constant uniqueness + default-constructed
inactive) into a single non-fixture TEST. Folded Test 11
(ResetFilterDeactivates) into Test 3's teardown assertion.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: fix lint findings on test compression

CI failures on 0828ff9:
- ament_uncrustify: inner brace-list of OnParamSetFailurePolicyParsing
  used 8-space indent instead of 6.
- codespell: "waitFor" matched the "wait for" rule with
  write-changes=true and the hook rewrote the helper to "wait for",
  breaking compilation. Renamed to waitForCond throughout (codespell-
  safe; dictionary doesn't carry the compound).

Also refactored two brace-block EXPECT_THROW / EXPECT_NO_THROW
statement bodies in OnParamSetFailureThrowsByDefaultAndWarnSwallows
to lambdas — the brace-block-as-statement form is unconventional
and friendlier to formatters as a lambda call.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: avoid codespell lets-let's misfire

codespell 2.4.1 (used by nav2 pre-commit cache) rewrites "lets" to
"let's" via the informal rule, even where "lets" is the correct
verb form. The comment on createFilter() tripped this in CI. Rephrase
to "allows ... to inject" so codespell stays quiet without an
ignore-words entry that the maintainers would have to maintain.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: read declared configuration

Per review feedback: replace get_parameter_overrides() scraping with
explicit declared parameters. The state, target node, parameter, and
value are all declared configuration now — introspectable via
'ros2 param get' and type-validated at load.

- New schema: <filter>.states (names) -> <name>.{id, overrides} ->
  <override>.{node, parameter, value} (dynamic-typed value), plus
  <filter>.nominal_defaults for the state-0 reset baseline.
- Remove matchTargetNode()/longest-prefix routing and the length sort:
  with node and parameter explicit there is nothing to disambiguate.
- Remove the on_param_set_failure policy: a failed set always throws
  (a failed parameter set on a safety parameter is a stop condition).
- Rewrite the unit tests to the declared schema (16 tests; the
  longest-prefix test becomes explicit two-node routing, and the
  policy-parsing test now proves a leftover policy override neither
  breaks config-load nor softens the always-throw).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: fix uncrustify continuation indent

Whitespace-only (verified: 'git diff -w' empty); ament_uncrustify now
reports no divergence on all three files.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: address review round 3

- Rename the per-state key 'overrides' to 'setpoints' in the parameter
  schema and the log strings (reviewer preference). This renames this
  PR's own key <state>.overrides -> <state>.setpoints; nothing in docs
  or YAML referenced the old name, so it is code and tests only.
- Use 'auto' for all three node_.lock() sites.
- Drop the dead 'found' flag and its '(void)found' silencer in
  applyState(); the loop already breaks on the match and the gap case
  is handled by the preceding continue.

The comment rewrites requested in the same review round are not in this
commit and follow separately.

Signed-off-by: Akihiko Komada <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* [costmap_filters] ZoneParameterFilter: clarify comments + guard state/map divergence

- read_entry: rewrite the block comment to explain why `value` alone is
  declared dynamic_typing (one override path carries a parameter of any
  type), instead of narrating what the code already shows.
- state-reset loop: rewrite the `continue` comment (no nominal default ->
  the param keeps state N's value; already warned at config-load); drop the
  stray "Test 24" reference.
- checkPendingParameterUpdates: rewrite to the safety rationale -- a failed
  safety-zone parameter set is rethrown, never logged-and-swallowed.
- applyState: add an RCLCPP_ERROR when current_state_ is not in
  state_param_map_ (a tracked-state/map divergence that should never happen),
  matching the existing 'should have been built at config-load' error.

zone_parameter_filter suite: 16/16 passing (built against nav2 rolling).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: tighten remaining comments + fix two inaccurate ones

Follow-up cleanup of the rest of the file's comments to the same why-only standard,
and correction of two that were wrong:
- the reset/apply comment claimed issueAsyncSetParameters preserves submission order
  on a per-node future queue; no such queue exists — it push_backs into a single flat
  pending_futures_ used only for completion polling. The only ordering guarantee is
  that the reset loop runs before the apply loop.
- resetFilter's retained-maps comment named only nominal_defaults_ and param_clients_;
  state_param_map_ also persists across resets.

Also trimmed the read_entry / client-construction / checkPendingParameterUpdates blocks
to their load-bearing rationale and dropped section-marker comments that restated the
code. Comments only; no behavior change. zone_parameter_filter suite: 16/16.

Signed-off-by: Akihiko Komada <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* fix: declare reset_per_node map in ZoneParameterFilter::applyState

Signed-off-by: Akihiko Komada <[email protected]>

* Fix -Werror=null-dereference in ZoneParameterFilter on GCC 15

The nav2 CI image refreshed on 2026-08-07 and now ships GCC 15.2, whose
inliner rejects checkPendingParameterUpdates():

  error: potential null pointer dereference [-Werror=null-dereference]
    inlined from 'std::vector<_Tp, _Alloc>::operator=(const vector&)'
      at /usr/include/c++/15/bits/vector.tcc:250:21,
    inlined from 'ZoneParameterFilter::checkPendingParameterUpdates()'
      at zone_parameter_filter.cpp:484:25

pending_futures_ holds std::shared_future, and shared_future::get()
returns a const reference rather than a value, so `results = it->get()`
was a full copy-assignment of the result vector. GCC 15 follows the
inlined vector::operator= chain down into SetParametersResult_ and
cannot prove the internal pointer is non-null.

Bind the results by const reference instead of copying them. The shared
future is copied out of the container before the entry is erased, so the
shared state -- and therefore the value the reference refers to -- stays
alive for the rest of the iteration. Erasing before get() also removes
the need for the catch-and-rethrow: the entry is already gone, so a
service-side exception still surfaces exactly once.

Behaviour is unchanged: an entry is erased exactly once, a failed
set_parameters still throws, and the not-yet-ready path is untouched.

Verified in ghcr.io/ros-navigation/navigation2:main (GCC 15.2): the
package fails to build with colcon exit 2 before this change and builds
clean with exit 0 after it; zone_parameter_filter_test passes 16/16.

Signed-off-by: Akihiko Komada <[email protected]>

* Align ZoneParameterFilter test with current nav2 conventions

Two small drifts this branch had picked up against main:

- Link std_msgs::std_msgs directly. After ros-navigation#6136 replaced the rest,
  ${std_msgs_TARGETS} here was the only remaining use in the repo, and
  binary_filter_test seven lines above already links the target
  directly. Linkage is unchanged.

- Build the test's transform buffer with nav2::create_transform_buffer
  rather than constructing tf2_ros::Buffer by hand, matching the speed,
  keepout and binary filter tests after ros-navigation#6281. This also gives the test
  the timer interface the factory installs. Two includes left unused by
  the change are dropped.

Signed-off-by: Akihiko Komada <[email protected]>

---------

Signed-off-by: Akihiko Komada <[email protected]>
Signed-off-by: Steve Macenski <[email protected]>
Co-authored-by: Steve Macenski <[email protected]>
Signed-off-by: mini-1235 <[email protected]>
mbloechli pushed a commit to Duatic/navigation2 that referenced this pull request Aug 18, 2026
…rameter overrides (ros-navigation#6104)

* WIP: ZoneParameterFilter — plugin scaffold + test scaffold (slice 1, ~80%)

Slice 1 of nav2#6080 implementation per the source-read milestone-1
artifact at outputs/sprint_131/nav2_6080_source_read.md.

Architecture per Steve Macenski's 2026-04-13 design guidance:
- Mask values 0..255; value 0 = reset to nominal defaults
- Each non-zero state mapped via YAML config to a list of ROS
  parameters (any reachable nav2 parameter on any node)
- No custom enums; raw int + config-driven semantics
- Async parameter setting via per-target-node AsyncParametersClient
  (Steve's preferred pattern from PR ros-navigation#3796 first review)
- Optional state-transition event publication
- Configurable warn|throw policies for unknown-state and
  param-set-failure

PR ros-navigation#3796 burn-pattern guards baked in:
- No wait_for_service in hot path (issue 2): service_is_ready()
  predicate; skip-with-throttled-warn on not-ready
- No empty-string sentinels (issue 4): std::map presence checks
- Future lifetime managed (issue 5): pending_futures_ vector
  drained at top of every process() call; never destruct mid-flight
- Per-node async client (Steve's first review point): one
  AsyncParametersClient per target node, batched parameter sets

Files added:
- nav2_costmap_2d/include/nav2_costmap_2d/costmap_filters/
    zone_parameter_filter.hpp
- nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp
- nav2_costmap_2d/test/unit/zone_parameter_filter_test.cpp

Files edited:
- filter_values.hpp: added ZONE_PARAMETER_FILTER = 4 constant
- costmap_plugins.xml: registered new plugin in filters library
- CMakeLists.txt: added zone_parameter_filter.cpp to filters target
- test/unit/CMakeLists.txt: added zone_parameter_filter_test target

Confidence assessment for slice 1 target (80% today):
- Architectural skeleton complete and follows nav2 conventions
- Source-read evidence cited for every ros-navigation#3796 fix
- All cross-file wiring (XML, CMake, header, impl) in place
- Test scaffold exercises the type-constant and construction paths
- 5/11 test cases from §5 implementation plan present (or as
  documented placeholders); remaining 6 deferred to slice 2 (95%)
- Build verification deferred: no ROS 2 env on this machine; CI
  build is the next gate

Slice 2 (95% target tomorrow) needs:
- colcon build green on humble + jazzy
- Remaining 6 unit tests with full ROS 2 mock harness
- AsyncParametersClient mock for param-mutation assertions
- Coverage measurement (lcov ≥90% per ros-navigation#3796 retrospective)
- File-level review of PR ros-navigation#3796 diff (read summary, not the diff
  itself yet)

Not for PR open — feature branch only. Per D-VGC148, all PR
prose is Komada-authored at PR-open time. Per the commit-or-close
clause to Steve, PR open is committed by 2026-05-16.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): uncrustify lint nits (Path C build verification round 1)

Three style fixes per ament_uncrustify on rolling:

1. plugins/costmap_filters/zone_parameter_filter.cpp:60-61 — split a
   140-char declare_or_get_parameter call across two lines.
2. plugins/costmap_filters/zone_parameter_filter.cpp:138-140 — same
   for an RCLCPP_ERROR call.
3. test/unit/zone_parameter_filter_test.cpp:72,89 — convert
   single-line destructors to multi-line bodies (matches binary_filter_test
   pattern).

Verification context: Path C source-build in ros:rolling docker
container compiled the package cleanly and ran 4/4 of our new
gtest cases. The 3 failures in the 399-test suite were all
uncrustify diffs on these lines — zero correctness regressions.
This commit closes the lint gates.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* test(zone_parameter_filter): add TestZpf lifecycle fixture + first real test (slice 2a)

Adds a gtest fixture mirroring binary_filter_test.cpp's TestNode pattern,
adapted for ZoneParameterFilter's parameter-mutation semantics:

- TargetNode helper — minimal rclcpp::Node with declared parameters that
  ZPF will mutate via AsyncParametersClient
- TestZpf fixture — LifecycleNode host + separate executors + helpers for
  filter creation, process() invocation, and predicate-based wait
- State1AppliesParameterToTargetNode — first real lifecycle test:
  state_ids=[1] + state_1.zpf_target_node.speed=0.5 fed via
  parameter_overrides; mask filled with 1; pose at center cell;
  process() triggers state 0→1 transition; async set_parameters
  propagates to target node within 1.5s timeout; asserts speed=0.5,
  inflation untouched

Verified on rolling (docker nav2:dev): 5/5 tests pass in 150ms total
(4 scaffold + 1 new lifecycle), zero build warnings, zero test failures.

Slice 2a complete; remaining slice-2b items per scaffold TODO list:
state_zero_resets, unknown_state_warn/throw, state_event_published,
service_not_ready_in_hot_path_does_not_block, etc.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* test(zone_parameter_filter): add 3 lifecycle cases + ros-navigation#3796 regression test (slice 2b)

Extends TestZpf fixture with StateEventSubscriber + rePublishMask helper,
plus three live cases covering distinct ZPF code paths:

- UnknownStateWarnLogsAndKeepsPrevious — exercises on_unknown_state="warn"
  policy: a mask value not in the configured state map must log a
  throttled warn and leave all target parameters unchanged.

- StateEventPublishedOnTransition — exercises optional state_event_pub_:
  when state_event_topic is configured, every transition publishes a
  UInt8 carrying the new state value. Verified via a separate
  StateEventSubscriber on the same in-process executor.

- ServiceNotReadyInHotPathDoesNotBlock — REGRESSION TEST FOR PR ros-navigation#3796
  review item 2 (Steve Macenski + Alexey Merzlyakov, 2023-09 to
  2023-12). When a target node's parameter service is not ready, ZPF
  must NOT call wait_for_service in process(); it must log a throttled
  warn via service_is_ready() and return promptly. Test routes a
  state-1 override at a nonexistent_node and asserts process() returns
  in <500ms (a wait_for_service regression would hang for seconds).

Plus one documented-failure case kept under DISABLED_ prefix:

- DISABLED_State0ResetsToNominalDefaults — surfaces a v0.1 limitation
  in zone_parameter_filter.cpp:383 where nominal_defaults_ stores an
  empty ParameterValue instead of the target's pre-override value.
  resetToNominal() therefore pushes NOT_SET and silently no-ops.
  Proper fix (slice 2c) is to synchronously fetch nominal values at
  initializeFilter() time via spin_until_future_complete with short
  timeout — permitted blocking outside the hot path.

Cosmetic: InfoPublisher now passes multiplier=1.0 (was 0.0) to silence
the "base/multiplier are unused; expected defaults (0.0, 1.0)" warning
emitted by ZPF on filter-info receipt.

Verified on rolling (nav2:dev container, incremental build 22s):
8/8 enabled tests pass in 611ms total. 1 disabled documented as design
intent pending slice 2c fix.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): YAML-declared nominal_defaults for state-0 reset (slice 2c)

Slice 2b's State0ResetsToNominalDefaults test surfaced a real v0.1 bug:
applyState() inserted an empty `ParameterValue` (NOT_SET type) as a
nominal-default sentinel, then resetToNominal() pushed that empty value
back to the target on state-0 transition — silent no-op, override never
restored. Steve Macenski's ros-navigation#6080 design pointer specifically called out
state-0 reset semantics, so leaving this broken was not an option.

Initial fix candidate was async get-before-set: fire get_parameters then
set_parameters on the same AsyncParametersClient, relying on FIFO to
capture the pre-override value in the get response. Discarded after
inspection: get_parameters and set_parameters use SEPARATE underlying
services::Client instances, so server-side processing order between them
is not guaranteed. A late get response would capture the OVERRIDDEN
value, not the nominal — a worse failure mode than the silent no-op.

Adopted: declarative YAML nominal_defaults. Schema:

  <plugin>.nominal_defaults.<target_node>.<param_path>: <value>

Parsed at loadStateConfig() time (configure phase, blocking permitted).
Race-free, deterministic, zero runtime cost. Matches Steve's "config-
driven" preference verbatim.

Quality-of-life: warn at config-load time for any state-N parameter that
has no matching nominal_defaults entry — such params will not be
restored by state-0 reset, and a v1 user almost certainly wants symmetric
coverage.

Test re-enabled (DISABLED_State0ResetsToNominalDefaults → enabled),
extended to provide the explicit nominal_defaults override. All 9
TestZpf cases pass on rolling (nav2:dev, incremental build 58s):

  State1AppliesParameterToTargetNode      ✅ 162ms
  State0ResetsToNominalDefaults           ✅ 268ms (slice 2c verified)
  UnknownStateWarnLogsAndKeepsPrevious    ✅ 327ms
  StateEventPublishedOnTransition         ✅ 149ms
  ServiceNotReadyInHotPathDoesNotBlock    ✅ 130ms

  Total: 9/9 in 1038ms, 0 disabled, 0 failures.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): apply CI lint feedback (codespell + uncrustify)

PR ros-navigation#6104 lint workflow surfaced two issues:

- codespell (in pre-commit): flagged "lets" in a comment on
  loadStateConfig (the colon-separator routing comment) as
  potentially "let's". The original word was correct ("permits"
  meaning), but rewording to "routes" preserves the same intent
  while avoiding the false-positive trigger.

- ament_uncrustify: brace-block indentation inside the createFilter
  argument list across all 5 TestZpf cases. Auto-reformatted via
  ament_uncrustify --reformat; 11/11 line shifts.

No functional change. Local verification on rolling (nav2:dev):
ament_uncrustify clean across all 3 ZPF files; 9/9 tests pass in
965ms.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* fix(zone_parameter_filter): explicit target_nodes + 4 audit-driven tests

Addresses findings from a 4-agent swarm audit on PR ros-navigation#6104 (synthesis at
sky/outputs/nav2_6104_pr_audit/synthesis.md):

- F-4 schema: introduce a required `target_nodes: [a, b, ...]` YAML
  parameter and replace first-dot-split parsing with longest-prefix-match
  against the explicit list. The original first-dot-split happens to be
  correct for typical nav2 usage (ROS doesn't allow dots in node names),
  but the explicit list is unambiguous, self-documenting, catches typos
  at config-load, and future-proofs against schema drift.

- F-9 ResetFilterDeactivates: verify resetFilter() clears
  filter_info_received_ and filter_mask_ so isActive() returns false.
  Mirrors binary_filter_test.cpp::testResetFilter.

- F-10 UnknownMaskCellLeavesStateUnchanged: mask filled with
  OCC_GRID_UNKNOWN (-1); verify process() leaves current_state_ + the
  target's parameter untouched. Guards the negative-mask-data branch
  in process().

- F-11 RobotOutsideMaskResetsToState0: drive into state 1, then call
  process() with a pose far outside mask bounds. Verify the state
  auto-resets to 0 and nominal_defaults are restored. Guards the
  worldToMap()-failure branch in process().

- F-4 regression test (LongestPrefixMatchForOverlappingTargetNodes):
  with target_nodes = ["zpf", "zpf_target_node"] and an override
  state_1.zpf_target_node.speed=0.7, verify the longer prefix wins so
  the parameter actually lands on the live target node. A regression
  to naive shortest-prefix would route to the bogus "zpf" service
  and the value would never land.

Verified on rolling (nav2:dev): 13/13 tests pass in 1365ms. Local
ament_uncrustify + ament_cpplint clean.

Co-Authored-By: Claude and aki1770-del <[email protected]>
Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: always throw on unknown mask state

Removes the on_unknown_state parameter and the paired UnknownStatePolicy
enum. The hot path now throws std::runtime_error unconditionally when the
mask emits a state value not in the configured state_ids/state_<N> map.

This makes configuration / data-integrity faults fail-safe at the
lifecycle layer rather than continuing with stale parameters. ZPF mutates
parameters on other nodes with safety-relevant downstream effects (speed
caps, inflation radius, controller limits); silently keeping the previous
state when the mask says "I don't know what zone I'm in" is strictly worse
than surfacing the fault to the lifecycle layer where the integrator can
react.

The throw fires at the state_param_map_.find(new_state) miss point, BEFORE
any per-node iteration begins, so no partial-state leak is possible.
Test 8 inverted from UnknownStateWarnLogsAndKeepsPrevious to
UnknownStateThrows (EXPECT_THROW std::runtime_error + post-throw assertion
that the target speed is unchanged at the nominal default).

Addresses the unknown_state half of Steve Macenski's review comment on
zone_parameter_filter.cpp:95 ("Always throw, this is a critical issue
the robot should stop for"). The on_param_set_failure half is treated
separately per the prior reply on the PR.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: scrub TMI comments

Steve Macenski review on PR ros-navigation#6104: top-level "There's a lot of AI generated
TMI comments throughout the code that should be removed or reduced", plus
inline pins on hpp:101, cpp:78, costmap_plugins.xml:40.

Removed comments that:
- Restated what the surrounding code or variable name already says
  (decorative section dividers, "subscription wiring" headers, "lazily
  build per-node async client" before the lazy lookup, etc.)
- Cited prior reviews back at the reviewer (ros-navigation#3796 references, "Steve's
  preference", "Per ros-navigation#3796 review item N")
- Cited foreign-PR context the reader doesn't need (the future-lifetime
  rationale moves to commit-message context, not header docstring)
- Stated marketing-style framing ("Schema is also self-documenting and
  catches typos at config-load")

Trimmed (kept the WHY-non-obvious in one line):
- kNodeParamSep colon-separator rationale (1 line)
- matchTargetNode longest-prefix-first WHY (2 lines)
- length-descending sort rationale (1 line)
- declarative YAML nominals reasoning (1 line; the auto-capture race is
  non-obvious and survives the upcoming refactor)
- state-N override without nominal warning rationale (1 line)
- retain-across-resets rationale (1 line)
- target_nodes explicit-list necessity (3 lines, still load-bearing for
  the dot-grammar boundary problem)

costmap_plugins.xml:40 description trimmed to one sentence matching the
shape of the other filter entries (no SpeedFilter cross-reference, no
issue link).

Class doxygen on ZoneParameterFilter.hpp simplified — dropped the
@ref SpeedFilter comparison and the issue link.

3 files changed, 20 insertions(+), 92 deletions(-).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: default state_event_topic to "zone_filter_state"

Steve Macenski review on PR ros-navigation#6104, comment #3150003597 on
zone_parameter_filter.cpp:80: "Set a reasonable default".

- Default state_event_topic from "" to "zone_filter_state".
- Drop the empty-string skip-guard at the publisher creation site;
  always create the publisher.

Matches the speed_filter / keepout_filter / binary_filter idiom — sensible
default-named topic, published unconditionally, user can rename via the
parameter.

Negligible bandwidth cost (~one std_msgs/UInt8 per state transition,
which is a rare event).

Companion docs change in PR ros-navigation#907 (L114) follows in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: flip on_param_set_failure default to throw

Steve Macenski review on PR ros-navigation#6104, comment on docs PR ros-navigation#907 line 136:
"I question if this should not always throw, since that puts the
application in an undefined state."

Per the PR ros-navigation#6104 reply: keeping the parameter, default-flipping to
throw. The other filters in costmap_filters/ handle transient RPC / tf2
faults uniformly with throttled-warn-and-continue (speed_filter
unknown-mask path; keepout_filter tf2 transform-exception path;
binary_filter unknown-mask path), so collapsing all such transient
classes to a stack-killing exception introduces a second-order failure
mode where a single network blip takes the nav stack down. The
configurable escape preserves the existing nav2 convention for
operators who need transient-class fault discrimination.

The default flip alone honors the safety direction in the review.

Tests: no existing test depends on the warn default for this parameter.

Companion docs change in PR ros-navigation#907 (L136) follows in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: header restructure (protected + doxygen)

Steve Macenski review on PR ros-navigation#6104, comment #3149982423 on
zone_parameter_filter.hpp:79: "Change to protected and put all methods
before all variables in Nav2 styling. All methods must have doxygen
as well."

- private: → protected: (visibility per ask).
- All 7 helper methods (filterInfoCallback, maskCallback, loadStateConfig,
  applyState, resetToNominal, issueAsyncSetParameters, drainPendingFutures)
  now carry @brief doxygen blocks.
- Method-before-variable ordering preserved (was already correct
  post-Theme-B scrub).

Matches the speed_filter / keepout_filter / binary_filter header layout
shape Steve referenced.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: init-time param clients + drop readiness probe

Steve Macenski review on PR ros-navigation#6104:
- Comment #3150018176 on cpp:529: "Should we not make these on
  initialization so we don't own the discovery at runtime and building
  for is service ready? If we parse the states, we should be able to
  create our param clients at startup..."
- Comment #3150018587 on cpp:536: "PS this will block indefinitely"

C.3 + C.4 changes (Steve's two comments resolve to one architectural
move):

- loadStateConfig() now enumerates the union of all target_nodes
  referenced by state_param_map_ + nominal_defaults_ and builds one
  AsyncParametersClient per node at init time. Failures are surfaced
  through drainPendingFutures + param_set_failure_policy_ rather than
  through a runtime readiness probe.
- issueAsyncSetParameters() simplified: no lazy construction, no
  service_is_ready() probe. A missing client is now a programmer-error
  (the loadStateConfig enumeration should cover every target_node any
  state mutates), logged as RCLCPP_ERROR + early return.
- service_is_ready() probe removed entirely. Steve's "PS this will
  block indefinitely" reads correctly under the user-facing meaning
  (silent indefinite skip when target never comes up); the C.3
  redesign converts that silent-skip into a surfaceable failure.

Matches the speed_filter / binary_filter init-time-resource pattern.
AsyncParametersClient construction is local-only — registers topics +
service clients locally, does not require the remote service to be
reachable at construction time. Set_parameters becomes
fire-and-forget-with-future-drain.

Out of scope for this PR (carved out per AAA-disciplined Komada
judgment): runtime mutation of the state map ("dynamic parameter
changes of the states" hint Steve raised) is v0.2 scope.

Test impact: Test 10 (ServiceNotReadyInHotPathDoesNotBlock) still
passes the existing assertions (process() under 500ms, no exception
thrown). Will be renamed + re-asserted in the Theme E test-coverage
commit to match the new init-time-clients reality.

Companion docs change in PR ros-navigation#907 (L94 nominal_defaults framing) follows
in a paired commit.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: replace colon-encoded keys with structured StateParamEntry

Steve Macenski review on PR ros-navigation#6104:
- Top-level: "Some parts of this seem dramatically overcomplicated."
- Inline #3149997318 on cpp:56: "What is going on here & does it need
  to be this way? Seems like this and the function where its used are
  overcomplicated and convoluted"

Theme D — split into two distinct items:

D-1: matchTargetNode kept. The longest-prefix-first match is genuinely
needed because ROS 2 parameter names admit dots, so a flat YAML override
key like `state_1.local_costmap.inflation_layer.inflation_radius` is
ambiguous between targeting `local_costmap` (param `inflation_layer
.inflation_radius`) or `local_costmap.inflation_layer` (param
`inflation_radius`). The user-declared `target_nodes:` list resolves
this. Light style polish (one renamed local for readability).

D-2: replaced colon-encoded `Parameter` keys with a structured
`StateParamEntry { std::string target_node; rclcpp::Parameter param; }`.
Removes:
- The `kNodeParamSep` constant (no separator needed).
- The "<target_node>:<param_name>" encoding in loadStateConfig.
- The colon-parsing in applyState (was rebuilding the same data).
- The colon-parsing in resetToNominal.
- The defensive RCLCPP_ERROR branch for "stored parameter name missing
  separator" — was structurally unreachable since we controlled the
  encoding.

state_param_map_ type: `std::map<uint8_t, std::vector<rclcpp::Parameter>>`
→ `std::map<uint8_t, std::vector<StateParamEntry>>`.

nominal_defaults_ type: `std::map<std::string, rclcpp::Parameter>`
(colon-keyed) → `std::map<std::string, std::vector<rclcpp::Parameter>>`
(keyed by target_node, values are bare-named Parameters). resetToNominal
now iterates the map directly — no per-node batching required, the
data shape already groups by node.

Init-time client enumeration loop (Theme C.3) simplified accordingly:
target_nodes drop straight out of the StateParamEntry / nominal_defaults
keys, no string-parsing.

Net change: -14 lines across .cpp/.hpp; cognitive complexity reduced
materially; one class of bugs gone (a colon character appearing in a
target_node name would have broken the prior encoding silently).

Tests: external behavior unchanged, all existing assertions pass.
Test 14 (LongestPrefixMatchForOverlappingTargetNodes) only inspects the
target node's actual parameter value, not the storage shape, so no
test edit needed.

Theme E (test coverage commit) will add a regression guard against
future colon-encoding reintroduction.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: expand test coverage 13 → 30 cases

Steve Macenski review on PR ros-navigation#6104, top-level: "Also check the code
coverage metrics, there's enough missing that needs to be added."

Test 10 reworked: was ServiceNotReadyInHotPathDoesNotBlock (asserted
the deleted service_is_ready() probe). Renamed to
ProcessHotPathReturnsPromptlyEvenWithUnreachableTargets and re-commented
to match the post-Theme-C.3 reality: clients are built at init
regardless of remote-service availability; set_parameters becomes
fire-and-forget-with-future-drain; process() returns promptly even when
the target service never appears. Same assertion, accurate framing.

17 new TEST_F cases targeting the warn / error / edge branches the
prior happy-path tests did not exercise:

- 15 InfoRePublishUpdatesMaskSubscription
- 16 MaskRePublishUpdatesFilterMask
- 17 BaseMultiplierNonDefaultDoesNotCrash
- 18 EmptyStateIdsLoadsButDoesNothing
- 19 EmptyTargetNodesLoadsButDoesNothing
- 20 InvalidStateIdInListIsSkipped
- 21 OverrideUnmatchedToTargetNodesIsWarnedAndSkipped
- 22 StateDeclaredWithNoParamsDoesNotCrash
- 23 NominalDefaultsUnmatchedToTargetNodesIsWarned
- 24 StateNWithoutNominalCounterpartWarnsAtConfig
- 25 TransformPoseFailureOrOutOfRangeReturnsCleanly
- 26 OnParamSetFailureWarnPolicyParsedCorrectly
- 27 OnParamSetFailureInvalidValueDefaultsToThrow
- 28 ResetToNominalNoOpWhenNoneConfigured
- 29 MultipleStateTransitionsInSequence
- 30 MultipleParamsInOneStateOnSameNode
- 31 NestedNamespaceTargetNodeRoutesCorrectly
  (Theme D-2 regression guard against future stringly-typed separator
  schemes; the structured StateParamEntry storage means no colon-encoded
  key can leak back in)

Total: 30 test cases (13 prior + 17 new). Estimated coverage delta
+25–30 percentage points; final ~85–90% (subject to gcovr verification
in the next colcon test run).

The on_param_set_failure throw / warn behavioral tests (engineering a
real RPC failure on a remote target) were deferred — they require a
target node fixture that fails set_parameters deterministically (e.g.
read-only parameter, parameter callback rejection), which is ~hour of
fixture work for marginal coverage delta over the parsing tests
(Tests 26 + 27). If the next review cycle requires the behavioral
coverage, those tests get added; the substrate (init-time clients,
drainPendingFutures, throw/warn branches) is in the production code
and exercises through Tests 10 + 22.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter resets N-only params on N→M

Cross-state transitions previously left params touched by state N but not
M at N's value until state-0 reset, leaking N's overrides into M's
behavior. applyState now computes the param-set difference and resets to
nominal_defaults before applying M's overrides, preserving the invariant
that all params equal state-0 defaults except those specifically set in
the active state.

Closes ros-navigation#6104 review thread 3211251415 + review summary item 1.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: simplify exception flow + scope-prune

Simplifies drainPendingFutures so the future.get() try/catch flows the
exception directly under the configured failure policy rather than
throwing-and-catching internally. Applies the matchTargetNode rewrite
from the review thread (starts_with + size guard). Adds an inline
comment near the override scan stating the routing-only validation
scope so a future reader does not infer cross-target param-existence
checks that this node neither performs nor needs to.

Closes ros-navigation#6104 review threads 3211313270 + 3211335331 + 3211355759.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: trim redundant comments + rename

Renames drainPendingFutures to checkPendingParameterUpdates so callers
read intent rather than implementation, drops the "Futures / drain"
docstring wording, removes inline comments that restated what the code
or surrounding log already shows, and adds a one-line note above the
parameter-overrides scan stating its intent so a future reader does
not have to infer it from the loop body.

Closes ros-navigation#6104 review threads 3211272912 + 3211274789 + 3211317251 +
3211319835 + 3211328905 + 3211330028 + 3211332786.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: remove TODO dev-note from test file

Per @SteveMacenski review (ros-navigation#6104 thread 3221447903): the Tests 3-5
header + 11-case-matrix TODO list is not test code and does not
belong in the test file.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: compress test suite 30 -> 16

Per @SteveMacenski review summary on PR ros-navigation#6104 (#4266595670):
"These tests need to be compressed and make sure they cover all the
active lines of code in this file. This seems extreme"

Sibling baseline: BinaryFilter has 10 TEST_Fs, SpeedFilter has 9. ZPF
landed at 30 cases / 1298 lines, ~3x sibling density. This commit
trims to 16 cases / 688 lines while preserving branch coverage and
adding two previously-missing branches.

Net: 1 TEST + 15 TEST_F, -787 / +156 lines.

Dropped 13 cases:
- Test 3 (FilterInfoTypeCheckRejectsWrongType): STALE - only re-asserted
  a constant inequality; the wrong-type branch in filterInfoCallback
  was never reached. Replaced by WrongFilterInfoTypeIsRejected which
  publishes BINARY_FILTER info and asserts isActive() stays false.
- Test 4 (MaskHelperConstructsExpectedShape): fixture self-test, not
  production code.
- Test 17 (BaseMultiplierNonDefaultDoesNotCrash): warn-only branch
  with no observable behavior.
- Test 21 (OverrideUnmatchedToTargetNodes): unmatched-node warn path,
  now covered by the merged EmptyAndInvalidConfigEdges case.
- Test 23 (NominalDefaultsUnmatchedToTargetNodes): symmetric warn-only
  path, no observable behavior.
- Test 24 (StateNWithoutNominalCounterpartWarns): same gap as Test 35;
  Test 35 (merged into ParamWithoutNominalDefaultsPersists) is the
  canonical assertion.
- Test 25 (TransformPoseFailureOrOutOfRange): weak duplicate of
  Test 13 (RobotOutsideMaskResetsToState0).
- Test 28 (ResetToNominalNoOpWhenNoneConfigured): subsumed by Test 7
  + the empty-config edge cases.
- Test 29 (MultipleStateTransitionsInSequence): cyclic transitions
  add nothing past the in-both + N-only-reset coverage.
- Test 30 (MultipleParamsInOneStateOnSameNode): per-node batching is
  exercised by every multi-param test.
- Test 31 (NestedNamespaceTargetNodeRoutesCorrectly): STALE - comment
  admitted ROS rejects colons; test degenerated to a Test 6 duplicate.
- Test 34 (CyclicTransitionABAReturnsToAValue): same mechanics as
  Test 32 with one extra hop.
- Test 36 (CrossStateTransitionInflationLeakDoesNotPersist): identical
  mechanics to Test 32 with controller-class flavor names.

Merged 8 cases into 5 survivors:
- 15 + 16     -> InfoAndMaskRePublishUpdateSubscriptions
- 18 + 19 + 20 + 22 -> EmptyAndInvalidConfigEdgesDoNotCrash
- 26 + 27     -> OnParamSetFailurePolicyParsing
- 33 + 32     -> CrossStateTransitionResetsParamTouchedByNOnly
- 37 + 35     -> ParamWithoutNominalDefaultsPersistsAcrossTransitions

Added two cases targeting branches the prior 30 did not cover:
- WrongFilterInfoTypeIsRejected: publishes BINARY_FILTER info on the
  ZPF info topic; asserts filterInfoCallback rejects it and isActive()
  never flips. Mirrors binary_filter_test::testIncorrectFilterType.
- OnParamSetFailureThrowsByDefaultAndWarnSwallows: routes state_1 to
  a read-only parameter on TargetNode (declared via ParameterDescriptor
  with read_only=true); set_parameters returns successful=false and
  checkPendingParameterUpdates applies the policy. Asserts default
  policy throws on the failure and "warn" policy swallows it.

Active branches now covered (was uncovered before):
- filterInfoCallback wrong-type rejection (B.2)
- checkPendingParameterUpdates failure path under both kThrow + kWarn (H)

Folded Test 1 + Test 2 (constant uniqueness + default-constructed
inactive) into a single non-fixture TEST. Folded Test 11
(ResetFilterDeactivates) into Test 3's teardown assertion.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: fix lint findings on test compression

CI failures on 0828ff9:
- ament_uncrustify: inner brace-list of OnParamSetFailurePolicyParsing
  used 8-space indent instead of 6.
- codespell: "waitFor" matched the "wait for" rule with
  write-changes=true and the hook rewrote the helper to "wait for",
  breaking compilation. Renamed to waitForCond throughout (codespell-
  safe; dictionary doesn't carry the compound).

Also refactored two brace-block EXPECT_THROW / EXPECT_NO_THROW
statement bodies in OnParamSetFailureThrowsByDefaultAndWarnSwallows
to lambdas — the brace-block-as-statement form is unconventional
and friendlier to formatters as a lambda call.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: avoid codespell lets-let's misfire

codespell 2.4.1 (used by nav2 pre-commit cache) rewrites "lets" to
"let's" via the informal rule, even where "lets" is the correct
verb form. The comment on createFilter() tripped this in CI. Rephrase
to "allows ... to inject" so codespell stays quiet without an
ignore-words entry that the maintainers would have to maintain.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: read declared configuration

Per review feedback: replace get_parameter_overrides() scraping with
explicit declared parameters. The state, target node, parameter, and
value are all declared configuration now — introspectable via
'ros2 param get' and type-validated at load.

- New schema: <filter>.states (names) -> <name>.{id, overrides} ->
  <override>.{node, parameter, value} (dynamic-typed value), plus
  <filter>.nominal_defaults for the state-0 reset baseline.
- Remove matchTargetNode()/longest-prefix routing and the length sort:
  with node and parameter explicit there is nothing to disambiguate.
- Remove the on_param_set_failure policy: a failed set always throws
  (a failed parameter set on a safety parameter is a stop condition).
- Rewrite the unit tests to the declared schema (16 tests; the
  longest-prefix test becomes explicit two-node routing, and the
  policy-parsing test now proves a leftover policy override neither
  breaks config-load nor softens the always-throw).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: fix uncrustify continuation indent

Whitespace-only (verified: 'git diff -w' empty); ament_uncrustify now
reports no divergence on all three files.

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: address review round 3

- Rename the per-state key 'overrides' to 'setpoints' in the parameter
  schema and the log strings (reviewer preference). This renames this
  PR's own key <state>.overrides -> <state>.setpoints; nothing in docs
  or YAML referenced the old name, so it is code and tests only.
- Use 'auto' for all three node_.lock() sites.
- Drop the dead 'found' flag and its '(void)found' silencer in
  applyState(); the loop already breaks on the match and the gap case
  is handled by the preceding continue.

The comment rewrites requested in the same review round are not in this
commit and follow separately.

Signed-off-by: Akihiko Komada <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* [costmap_filters] ZoneParameterFilter: clarify comments + guard state/map divergence

- read_entry: rewrite the block comment to explain why `value` alone is
  declared dynamic_typing (one override path carries a parameter of any
  type), instead of narrating what the code already shows.
- state-reset loop: rewrite the `continue` comment (no nominal default ->
  the param keeps state N's value; already warned at config-load); drop the
  stray "Test 24" reference.
- checkPendingParameterUpdates: rewrite to the safety rationale -- a failed
  safety-zone parameter set is rethrown, never logged-and-swallowed.
- applyState: add an RCLCPP_ERROR when current_state_ is not in
  state_param_map_ (a tracked-state/map divergence that should never happen),
  matching the existing 'should have been built at config-load' error.

zone_parameter_filter suite: 16/16 passing (built against nav2 rolling).

Signed-off-by: Akihiko Komada <[email protected]>

* [costmap_filters] ZoneParameterFilter: tighten remaining comments + fix two inaccurate ones

Follow-up cleanup of the rest of the file's comments to the same why-only standard,
and correction of two that were wrong:
- the reset/apply comment claimed issueAsyncSetParameters preserves submission order
  on a per-node future queue; no such queue exists — it push_backs into a single flat
  pending_futures_ used only for completion polling. The only ordering guarantee is
  that the reset loop runs before the apply loop.
- resetFilter's retained-maps comment named only nominal_defaults_ and param_clients_;
  state_param_map_ also persists across resets.

Also trimmed the read_entry / client-construction / checkPendingParameterUpdates blocks
to their load-bearing rationale and dropped section-marker comments that restated the
code. Comments only; no behavior change. zone_parameter_filter suite: 16/16.

Signed-off-by: Akihiko Komada <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* Update nav2_costmap_2d/plugins/costmap_filters/zone_parameter_filter.cpp

Signed-off-by: Steve Macenski <[email protected]>

* fix: declare reset_per_node map in ZoneParameterFilter::applyState

Signed-off-by: Akihiko Komada <[email protected]>

* Fix -Werror=null-dereference in ZoneParameterFilter on GCC 15

The nav2 CI image refreshed on 2026-08-07 and now ships GCC 15.2, whose
inliner rejects checkPendingParameterUpdates():

  error: potential null pointer dereference [-Werror=null-dereference]
    inlined from 'std::vector<_Tp, _Alloc>::operator=(const vector&)'
      at /usr/include/c++/15/bits/vector.tcc:250:21,
    inlined from 'ZoneParameterFilter::checkPendingParameterUpdates()'
      at zone_parameter_filter.cpp:484:25

pending_futures_ holds std::shared_future, and shared_future::get()
returns a const reference rather than a value, so `results = it->get()`
was a full copy-assignment of the result vector. GCC 15 follows the
inlined vector::operator= chain down into SetParametersResult_ and
cannot prove the internal pointer is non-null.

Bind the results by const reference instead of copying them. The shared
future is copied out of the container before the entry is erased, so the
shared state -- and therefore the value the reference refers to -- stays
alive for the rest of the iteration. Erasing before get() also removes
the need for the catch-and-rethrow: the entry is already gone, so a
service-side exception still surfaces exactly once.

Behaviour is unchanged: an entry is erased exactly once, a failed
set_parameters still throws, and the not-yet-ready path is untouched.

Verified in ghcr.io/ros-navigation/navigation2:main (GCC 15.2): the
package fails to build with colcon exit 2 before this change and builds
clean with exit 0 after it; zone_parameter_filter_test passes 16/16.

Signed-off-by: Akihiko Komada <[email protected]>

* Align ZoneParameterFilter test with current nav2 conventions

Two small drifts this branch had picked up against main:

- Link std_msgs::std_msgs directly. After ros-navigation#6136 replaced the rest,
  ${std_msgs_TARGETS} here was the only remaining use in the repo, and
  binary_filter_test seven lines above already links the target
  directly. Linkage is unchanged.

- Build the test's transform buffer with nav2::create_transform_buffer
  rather than constructing tf2_ros::Buffer by hand, matching the speed,
  keepout and binary filter tests after ros-navigation#6281. This also gives the test
  the timer interface the factory installs. Two includes left unused by
  the change are dropped.

Signed-off-by: Akihiko Komada <[email protected]>

---------

Signed-off-by: Akihiko Komada <[email protected]>
Signed-off-by: Steve Macenski <[email protected]>
Co-authored-by: Steve Macenski <[email protected]>
Signed-off-by: mbloechli <[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