refactor(dc_measurements,dc_util): unify parameter declaration on dc_util helpers - #317
Merged
Minipada merged 1 commit intoAug 11, 2026
Conversation
…util helpers Every Measurement/Condition plugin declared its own parameters by calling nav2_util::declare_parameter_if_not_declared + get_parameter directly, duplicating the same declare/get/fatal-on-failure boilerplate that dc_util::get_*_type_param() already provided but only ~20 of ~90 call sites actually used; measurement_server.cpp additionally had 5 raw declare_parameter calls (throw-on-redeclare, not idempotent) for its own node-level parameters. Collapse dc_util/node_utils.hpp's 14 near-identical helpers onto one shared core, extend it with the missing double/array-of-scalar types and a node-level (unprefixed) variant, and route every plugin and measurement_server.cpp through it. nav2_util stays a dependency (MeasurementServer already inherits nav2_util::LifecycleNode) but is now only referenced from dc_util itself -- recorded in ADR-0008, along with why dc_group's Python side keeps its existing plain declare_parameter calls. Two pre-existing, unrelated bugs (bool_equal.cpp's double-typed field vs. its PARAMETER_BOOL declaration; distance_traveled.cpp reading back a different parameter name than it declares) were left untouched and flagged inline rather than silently fixed. Verified with a real colcon build + colcon test in a ROS 2 Jazzy environment: 6/6 packages build clean, 46/46 tests pass. Closes #178 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L56mFyxLcigqQxzZ7BzNgs Signed-off-by: David Bensoussan <d.bensoussan@proton.me>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## jazzy #317 +/- ##
==========================================
+ Coverage 40.48% 40.82% +0.34%
==========================================
Files 82 82
Lines 5094 4920 -174
==========================================
- Hits 2062 2008 -54
+ Misses 3032 2912 -120
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Minipada
deleted the
feature/178-unify-parameter-declaration-across-measu
branch
August 16, 2026 14:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dc_measurements/dc_groupontodc_util::get_*_type_param()/get_*_param(): all 34 Measurement/Condition plugin.cppfiles andmeasurement_server.cpp's own 5 rawdeclare_parameter+ 3 directnav2_util::declare_parameter_if_not_declaredcall sites now go throughdc_util, instead of ~90 call sites split across three inconsistent patterns.dc_util/include/dc_util/node_utils.hpprewritten: the 14 near-identical helper bodies collapse onto one shareddetail::declare_and_get<T>()core, extended with the type coverage plugins actually needed (double, mandatoryvector<bool>/vector<int64_t>/vector<double>) and a node-level (unprefixed) variant. The broken, unusedget_float_type_param(declaredPARAMETER_DOUBLE, returnedint, zero call sites) was deleted.docs/adr/0008-dc-util-owns-parameter-declaration.md:nav2_utilstays a dependency (MeasurementServeralready inheritsnav2_util::LifecycleNode),dc_utilbecomes the single sanctioned wrapper around it, anddc_group's existing plain Pythondeclare_parametercalls are left as-is (no equivalent idempotency problem exists there).doc/src/dc/contributing.md.bool_equal.cpp'svalue_field isdoubledespite aPARAMETER_BOOLdeclaration;distance_traveled.cppdeclarestransform_tolerancebut reads back the different, undeclaredtransform_timeout.Closes #178
Test plan
colcon build --packages-select dc_util dc_core dc_measurements dc_interfaces dc_common dc_group— clean, 6/6 packages, zero errors/warnings (real ROS 2 Jazzy Podman environment)colcon test --packages-select dc_util dc_measurements dc_group— 46 tests, 0 errors, 0 failures, 0 skippedpre-commit runon all changed files — clean (clang-format, black, codespell, XML/package metadata checks); only the pre-existing, environment-onlypoetry-requirementsfailure reproduces, unrelated to this diff🤖 Generated with Claude Code
https://claude.ai/code/session_01L56mFyxLcigqQxzZ7BzNgs