feat(equivalences): support per-field ROS type overrides - #23
Open
MerinoSheep wants to merge 1 commit into
Open
Conversation
Add field_type_overrides to Configuration, letting a single Protobuf field's ROS type be overridden without remapping the whole message. Repeated fields may only be overridden to a fixed-size array of primitive types, which is handled in both C++ and Python conversion templates (zero-fill when the Protobuf field is unset, raise on length mismatch). Overrides of repeated composite types are rejected at validation time, since no conversion code is generated for them. An override short-circuits type translation rather than replacing its result, and reuses the fully qualified field name already computed for the any-expansion lookup. Fixed-size array detection uses the existing rosidl_adapter Type.is_fixed_size_array() rather than a local copy. Adds regression tests (FixedSizeVector) mirroring the pattern used for the other config knobs, and documents the new option in the README.
MerinoSheep
force-pushed
the
feat/field-type-overrides
branch
from
August 19, 2026 07:53
49824fd to
6dd8c88
Compare
mhidalgo-rai
self-requested a review
August 31, 2026 14:26
mhidalgo-rai
reviewed
Sep 1, 2026
mhidalgo-rai
left a comment
Collaborator
There was a problem hiding this comment.
@MerinoSheep thanks for the contribution, and sorry for delay. This one fell off my radar.
Code itself looks correct, but the functionality does make me wonder. Is it more general than it can be? The set of field type override tuples we can automatically handle is quite narrow when accounting for conversion code. That's why message re-mapping are whole.
So should this be a field_bounds setting instead?
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.
Proposed changes
Adds
field_type_overrides: a map from fully qualified Protobuf field name to ROS type, overriding one field's ROS type without touching the.proto.Protobuf has no fixed-size arrays, so a covariance matrix must be
repeated double. ROS hasfloat64[36]. Existingmessage_mappingandpackage_mappingonly remap whole message types.Changes:
Configuration.field_type_overrides+ README row.translate_fieldresolves the override by field FQN, in place oftranslate_type.std::arrayhas noclear()/reserve()/assign().Protobuf -> ROS, by source length:
Partial copies are never produced. ROS -> Protobuf needs no special handling.
Rejected at generation time:
Checklist
Additional comments
Run in containers from
.devcontainer/Dockerfilevia the CI chain (colcon build && colcon test && colcon test-result --all --verbose):Lint clean at pinned
.pre-commit-config.yamlversions (ruff 0.14.4, black 25.11.0, mypy 1.18.2, cpplint 1.6.1, clang-format 16.0.2).The zero-fill literal is type-derived (
0.0,False,"",0) — generated Python type checks each array item, so a bare0is rejected forfloat64[N]. C++ uses.fill({}).Repeated composite overrides are a possible follow-up: the composite branch of both templates would need the same three cases, using indexed assignment instead of
emplace_back.