fix(generator): emit .msg syntax in _fields_and_field_types for bounded types#262
Open
vik-shah-ai wants to merge 1 commit into
Open
fix(generator): emit .msg syntax in _fields_and_field_types for bounded types#262vik-shah-ai wants to merge 1 commit into
vik-shah-ai wants to merge 1 commit into
Conversation
…ed types
_fields_and_field_types / get_fields_and_field_types() is documented as a
Python introspection API for message field types. However it was emitting
OMG IDL 4.2 syntax for bounded strings and sequences:
sequence<string<256>, 32> (IDL)
instead of the canonical ROS 2 .msg syntax:
string<=256[<=32] (.msg)
This breaks any consumer that passes the output directly to the MCAP
ros2msg schema encoder (e.g. mcap_utils _build_ros2_schema()), because
the ros2msg schema encoding requires .msg syntax per the MCAP registry
spec (https://mcap.dev/spec/registry#ros2msg). Foxglove and other
ros2msg-aware tools reject the IDL form.
Changes:
- Remove IDL-style sequence<> prefix/suffix generation in the
_fields_and_field_types dict template.
- Emit bounded string bound with <= (string<=N) instead of <N>.
- Emit bounded sequence bound as [<=N], unbounded sequence as [],
fixed-size array as [N] -- all matching .msg syntax.
- Update test_interfaces.py expected values accordingly.
The SLOT_TYPES tuple (rosidl_parser.definition objects) is unchanged
and remains the correct API for programmatic type inspection.
Signed-off-by: Vikrant Shah <vikrant.shah@applied.co>
82f5f9a to
a719377
Compare
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.
Problem
_fields_and_field_types/get_fields_and_field_types()currently emits OMG IDL 4.2 syntax for bounded strings and sequences:The canonical ROS 2
.msgsyntax for these is:This matters because
get_fields_and_field_types()is used by tools that buildros2msg-encoded MCAP schemas (e.g.rosbag2-to-MCAP converters,mcap_utilsin downstream tooling). The MCAP registry spec requiresros2msgschema data to contain.msg-syntax definitions. Consumers such as Foxglove reject the IDL form and silently fail to decode topics with bounded string arrays.Changes
sequence<>prefix/suffix from_fields_and_field_typestemplate.<=(string<=N) instead of<N>..msgsyntax:[<=N](bounded),[](unbounded),[N](fixed).test_interfaces.pyexpected values to match.SLOT_TYPES(which holdsrosidl_parser.definitionobjects) is unchanged and remains the correct API for programmatic type inspection.Relation to issue #99
Issue #99 proposes deprecating
get_fields_and_field_types()in favour ofSLOT_TYPES. This fix is complementary: until that deprecation lands and all consumers have migrated, the string API should emit valid.msgsyntax rather than leaking IDL internals.