Add MessageIntrospector for message schema inspection#1346
Merged
Conversation
minggangw
reviewed
Dec 10, 2025
065519d to
3a79a7a
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a new MessageIntrospector class to provide a convenient way to inspect ROS 2 message structure, fields, and default values without directly using loader.loadInterface. This is useful for debugging, documentation generation, and building dynamic UIs.
Key changes:
- Added
MessageIntrospectorclass with properties for type name, fields, schema, and default values - Implemented deep cloning for default values to prevent mutation
- Provided comprehensive TypeScript definitions and test coverage
Reviewed changes
Copilot reviewed 7 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/message_introspector.js | Core implementation of MessageIntrospector class with getters for message metadata and default values |
| types/message_introspector.d.ts | TypeScript type definitions for MessageIntrospector and ROSMessageDef interface |
| types/base.d.ts | Added reference to new message_introspector type definitions |
| index.js | Exported MessageIntrospector class from main module |
| test/test-message-introspector.js | Comprehensive test suite covering constructor validation, properties, and defaults |
| example/message-introspector/message-introspector-example.js | Example demonstrating usage with Twist, String, and JointState messages |
| example/message-introspector/README.md | Documentation and usage guide for MessageIntrospector |
| src/rcl_utilities.cpp | Code formatting fix for RCPPUTILS_SCOPE_EXIT macro |
| src/rcl_logging_bindings.cpp | Code formatting fix for closing brace indentation |
| CONTRIBUTORS.md | Added contributor credit for MessageIntrospector feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
minggangw
approved these changes
Dec 12, 2025
c33b593
into
RobotWebTools:develop
14 of 15 checks passed
minggangw
pushed a commit
that referenced
this pull request
Jan 6, 2026
MessageIntrospector, a utility class that provides a simplified API for inspecting ROS 2 message structure without directly using loader.loadInterface. - typeName: Returns the full message type (e.g., geometry_msgs/msg/Twist) - fields:- Returns an array of top-level field names - defaults: Returns a deep copy of the message's default values - schema: Returns the underlying ROSMessageDef object - typeClass: Returns the underlying constructor
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.
Public API Changes
Added
MessageIntrospectorclass to inspect ROS 2 message structure without usingloader.loadInterfacedirectly. Useful for debugging, documentation, and building dynamic UIs based on message structure.Constructor:
new MessageIntrospector(typeName)- Create an introspector for any message typeProperties:
introspector.typeName- Get the full message type nameintrospector.typeClass- Get the underlying message class constructorintrospector.fields- Get array of field namesintrospector.schema- Get ROSMessageDef schema objectintrospector.defaults- Get default values for all fields (cached, returns deep copy)TypeScript:
MessageIntrospector<T>classROSMessageDefinterface#1343