Skip to content

Add MessageIntrospector for message schema inspection#1346

Merged
mahmoud-ghalayini merged 2 commits into
RobotWebTools:developfrom
mahmoud-ghalayini:add-message-factory-helpers-with-smart-defaults-and-partial-construction-1343
Dec 12, 2025
Merged

Add MessageIntrospector for message schema inspection#1346
mahmoud-ghalayini merged 2 commits into
RobotWebTools:developfrom
mahmoud-ghalayini:add-message-factory-helpers-with-smart-defaults-and-partial-construction-1343

Conversation

@mahmoud-ghalayini

@mahmoud-ghalayini mahmoud-ghalayini commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

Public API Changes

Added MessageIntrospector class to inspect ROS 2 message structure without using loader.loadInterface directly. Useful for debugging, documentation, and building dynamic UIs based on message structure.

Constructor:

  • new MessageIntrospector(typeName) - Create an introspector for any message type

Properties:

  • introspector.typeName - Get the full message type name
  • introspector.typeClass - Get the underlying message class constructor
  • introspector.fields - Get array of field names
  • introspector.schema - Get ROSMessageDef schema object
  • introspector.defaults - Get default values for all fields (cached, returns deep copy)

TypeScript:

  • Added MessageIntrospector<T> class
  • Added ROSMessageDef interface

#1343

@coveralls

coveralls commented Dec 9, 2025

Copy link
Copy Markdown

Coverage Status

coverage: 80.602% (+0.07%) from 80.537%
when pulling b6b4484 on mahmoud-ghalayini:add-message-factory-helpers-with-smart-defaults-and-partial-construction-1343
into a97a449 on RobotWebTools:develop.

Comment thread example/message-template/message-template-example.js Outdated
@mahmoud-ghalayini mahmoud-ghalayini force-pushed the add-message-factory-helpers-with-smart-defaults-and-partial-construction-1343 branch from 065519d to 3a79a7a Compare December 11, 2025 09:04
@mahmoud-ghalayini mahmoud-ghalayini changed the title Add message factory helpers with smart defaults and partial construction Add MessageIntrospector for message schema inspection Dec 11, 2025
@minggangw minggangw requested a review from Copilot December 12, 2025 03:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 MessageIntrospector class 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.

Comment thread CONTRIBUTORS.md Outdated
Comment thread example/message-introspector/README.md Outdated
Comment thread lib/message_introspector.js

@minggangw minggangw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

Comment thread example/message-introspector/README.md Outdated
@mahmoud-ghalayini mahmoud-ghalayini merged commit c33b593 into RobotWebTools:develop Dec 12, 2025
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
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.

4 participants