Skip to content

Conversation

@minggangw
Copy link
Member

@minggangw minggangw commented Sep 9, 2025

This PR implements runtime message generation capabilities for rclnodejs, allowing custom ROS2 message types to be dynamically discovered, built, and loaded during execution rather than requiring pre-generation.

  • Adds runtime message discovery and generation functionality to the interface loader
  • Implements synchronous message generation using worker processes to avoid blocking the main thread
  • Includes comprehensive test infrastructure with a custom message package for validation

Fix: #1257

Copilot AI review requested due to automatic review settings September 9, 2025 07:37

This comment was marked as outdated.

@minggangw minggangw force-pushed the fix-1254 branch 3 times, most recently from eb7763e to cccca5b Compare September 9, 2025 11:02

This comment was marked as outdated.

@coveralls
Copy link

coveralls commented Sep 9, 2025

Coverage Status

coverage: 84.368% (+0.03%) from 84.335%
when pulling d2604e2 on minggangw:fix-1254
into 0448667 on RobotWebTools:develop.

@minggangw minggangw requested a review from Copilot September 10, 2025 05:02
Copy link

Copilot AI left a comment

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 implements runtime message generation capabilities for rclnodejs, allowing custom ROS2 message types to be dynamically discovered, built, and loaded during execution rather than requiring pre-generation. This addresses issue #1257 by adding automatic discovery and synchronous generation of missing message interfaces.

  • Adds runtime message discovery and generation functionality to the interface loader
  • Implements synchronous message generation using worker processes to avoid blocking the main thread
  • Includes comprehensive test infrastructure with a custom message package for validation

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
test/test-rosidl-message-generator.js Adds test case for runtime message generation with custom test package setup
test/custom_msg_test/ Complete ROS2 package with custom message definitions for testing runtime generation
rosidl_gen/index.js Adds synchronous worker-based message generation function and exports helper utilities
rosidl_gen/generate_worker.js New worker script for performing message generation in separate process
lib/interface_loader.js Implements runtime message discovery and generation when interfaces are not found
README.md Updates documentation to indicate manual message generation is no longer required

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

const idlPath = path.join(generatedRoot, 'share');
const useIDL = !!process.argv.find((arg) => arg === '--idl');

// Get target path from environment variable instead of workerData
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

This comment references 'workerData' but the code uses child_process.spawnSync, not worker_threads. The comment should be updated to reflect the actual implementation using environment variables and spawn processes.

Suggested change
// Get target path from environment variable instead of workerData
// Get target path from the WORKER_TARGET_PATH environment variable

Copilot uses AI. Check for mistakes.
Comment on lines 96 to 99
// We are going to ignore the path ROS2 installed.
if (pkgPath.includes('ros2-linux')) {
continue;
}
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

The hardcoded check for 'ros2-linux' is platform-specific and may not work on other operating systems or ROS2 installation methods. Consider using a more robust method to identify system ROS2 installations or make this configurable.

Copilot uses AI. Check for mistakes.
}
} catch (err) {
// Skip directories we can't read
console.error('Error reading directory:', dir, err.message);
Copy link

Copilot AI Sep 10, 2025

Choose a reason for hiding this comment

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

This error message is logged to console.error but doesn't provide enough context about what operation was being performed. Consider using a more descriptive message like 'Failed to read directory during message discovery:' or use a proper logging mechanism.

Suggested change
console.error('Error reading directory:', dir, err.message);
console.error(
`Failed to read directory during message discovery for package "${packageName}", type "${type}", message "${messageName}". Directory: ${dir}. Error: ${err.message}`
);

Copilot uses AI. Check for mistakes.
@minggangw minggangw merged commit 55a6511 into RobotWebTools:develop Sep 10, 2025
26 of 27 checks passed
minggangw added a commit that referenced this pull request Sep 10, 2025
This PR implements runtime message generation capabilities for rclnodejs, allowing custom ROS2 message types to be dynamically discovered, built, and loaded during execution rather than requiring pre-generation.

- Adds runtime message discovery and generation functionality to the interface loader
- Implements synchronous message generation using worker processes to avoid blocking the main thread
- Includes comprehensive test infrastructure with a custom message package for validation

Fix: #1257
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.

2 participants