Skip to content

Conversation

@minggangw
Copy link
Member

@minggangw minggangw commented Sep 19, 2025

This PR adds a comprehensive tutorial for the Type Description Service feature in rclnodejs. The tutorial provides detailed documentation on how to use the built-in ROS 2 introspection service that allows querying message and service type information from running nodes.

Key changes:

  • Complete tutorial covering Type Description Service functionality, requirements, and usage patterns
  • Multiple practical examples demonstrating basic usage, advanced features, and best practices
  • Comprehensive troubleshooting guide and performance considerations

Fix: #1267

Copilot AI review requested due to automatic review settings September 19, 2025 03:19
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 adds a comprehensive tutorial for the Type Description Service feature in rclnodejs. The tutorial provides detailed documentation on how to use the built-in ROS 2 introspection service that allows querying message and service type information from running nodes.

Key changes:

  • Complete tutorial covering Type Description Service functionality, requirements, and usage patterns
  • Multiple practical examples demonstrating basic usage, advanced features, and best practices
  • Comprehensive troubleshooting guide and performance considerations

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

}

async discoverNodeTypes(nodeName) {
console.log(`\\nDiscovering types for node: ${nodeName}`);
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The escaped newline character should be a literal newline. Replace \\n with \n.

Suggested change
console.log(`\\nDiscovering types for node: ${nodeName}`);
console.log(`\nDiscovering types for node: ${nodeName}`);

Copilot uses AI. Check for mistakes.
processTypeDescription(typeName, response) {
const typeDesc = response.type_description.type_description;

console.log(`\\n=== Type: ${typeName} ===`);
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The escaped newline character should be a literal newline. Replace \\n with \n.

Suggested change
console.log(`\\n=== Type: ${typeName} ===`);
console.log(`\n=== Type: ${typeName} ===`);

Copilot uses AI. Check for mistakes.
}

printSummary() {
console.log(`\\n=== Discovery Summary ===`);
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The escaped newline character should be a literal newline. Replace \\n with \n.

Suggested change
console.log(`\\n=== Discovery Summary ===`);
console.log(`\n=== Discovery Summary ===`);

Copilot uses AI. Check for mistakes.
Comment on lines 721 to 747
let markdown = `# Type Documentation for Node: ${nodeName}\\n\\n`;
markdown += `Generated on: ${new Date().toISOString()}\\n\\n`;

this.documentation.forEach((doc) => {
markdown += `## ${doc.typeName}\\n\\n`;
markdown += `**Topic**: \`${doc.topicName}\`\\n\\n`;

if (doc.description.fields.length > 0) {
markdown += `### Fields\\n\\n`;
markdown += `| Field Name | Type | Default Value |\\n`;
markdown += `|------------|------|---------------|\\n`;

doc.description.fields.forEach((field) => {
const typeStr = this.formatFieldTypeForDoc(field.type);
markdown += `| \`${field.name}\` | ${typeStr} | \`${field.default_value || 'N/A'}\` |\\n`;
});
markdown += `\\n`;
}

if (doc.sources.length > 0) {
markdown += `### Source Definition\\n\\n`;
markdown += `\`\`\`${doc.sources[0].encoding}\\n`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`\\n\\n`;
}

markdown += `---\\n\\n`;
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The escaped newline characters should be literal newlines. Replace \\n with \n.

Suggested change
let markdown = `# Type Documentation for Node: ${nodeName}\\n\\n`;
markdown += `Generated on: ${new Date().toISOString()}\\n\\n`;
this.documentation.forEach((doc) => {
markdown += `## ${doc.typeName}\\n\\n`;
markdown += `**Topic**: \`${doc.topicName}\`\\n\\n`;
if (doc.description.fields.length > 0) {
markdown += `### Fields\\n\\n`;
markdown += `| Field Name | Type | Default Value |\\n`;
markdown += `|------------|------|---------------|\\n`;
doc.description.fields.forEach((field) => {
const typeStr = this.formatFieldTypeForDoc(field.type);
markdown += `| \`${field.name}\` | ${typeStr} | \`${field.default_value || 'N/A'}\` |\\n`;
});
markdown += `\\n`;
}
if (doc.sources.length > 0) {
markdown += `### Source Definition\\n\\n`;
markdown += `\`\`\`${doc.sources[0].encoding}\\n`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`\\n\\n`;
}
markdown += `---\\n\\n`;
let markdown = `# Type Documentation for Node: ${nodeName}\n\n`;
markdown += `Generated on: ${new Date().toISOString()}\n\n`;
this.documentation.forEach((doc) => {
markdown += `## ${doc.typeName}\n\n`;
markdown += `**Topic**: \`${doc.topicName}\`\n\n`;
if (doc.description.fields.length > 0) {
markdown += `### Fields\n\n`;
markdown += `| Field Name | Type | Default Value |\n`;
markdown += `|------------|------|---------------|\n`;
doc.description.fields.forEach((field) => {
const typeStr = this.formatFieldTypeForDoc(field.type);
markdown += `| \`${field.name}\` | ${typeStr} | \`${field.default_value || 'N/A'}\` |\n`;
});
markdown += `\n`;
}
if (doc.sources.length > 0) {
markdown += `### Source Definition\n\n`;
markdown += `\`\`\`${doc.sources[0].encoding}\n`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`\n\n`;
}
markdown += `---\n\n`;

Copilot uses AI. Check for mistakes.
Comment on lines 721 to 747
let markdown = `# Type Documentation for Node: ${nodeName}\\n\\n`;
markdown += `Generated on: ${new Date().toISOString()}\\n\\n`;

this.documentation.forEach((doc) => {
markdown += `## ${doc.typeName}\\n\\n`;
markdown += `**Topic**: \`${doc.topicName}\`\\n\\n`;

if (doc.description.fields.length > 0) {
markdown += `### Fields\\n\\n`;
markdown += `| Field Name | Type | Default Value |\\n`;
markdown += `|------------|------|---------------|\\n`;

doc.description.fields.forEach((field) => {
const typeStr = this.formatFieldTypeForDoc(field.type);
markdown += `| \`${field.name}\` | ${typeStr} | \`${field.default_value || 'N/A'}\` |\\n`;
});
markdown += `\\n`;
}

if (doc.sources.length > 0) {
markdown += `### Source Definition\\n\\n`;
markdown += `\`\`\`${doc.sources[0].encoding}\\n`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`\\n\\n`;
}

markdown += `---\\n\\n`;
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The escaped newline characters should be literal newlines. Replace \\n with \n.

Suggested change
let markdown = `# Type Documentation for Node: ${nodeName}\\n\\n`;
markdown += `Generated on: ${new Date().toISOString()}\\n\\n`;
this.documentation.forEach((doc) => {
markdown += `## ${doc.typeName}\\n\\n`;
markdown += `**Topic**: \`${doc.topicName}\`\\n\\n`;
if (doc.description.fields.length > 0) {
markdown += `### Fields\\n\\n`;
markdown += `| Field Name | Type | Default Value |\\n`;
markdown += `|------------|------|---------------|\\n`;
doc.description.fields.forEach((field) => {
const typeStr = this.formatFieldTypeForDoc(field.type);
markdown += `| \`${field.name}\` | ${typeStr} | \`${field.default_value || 'N/A'}\` |\\n`;
});
markdown += `\\n`;
}
if (doc.sources.length > 0) {
markdown += `### Source Definition\\n\\n`;
markdown += `\`\`\`${doc.sources[0].encoding}\\n`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`\\n\\n`;
}
markdown += `---\\n\\n`;
let markdown = `# Type Documentation for Node: ${nodeName}\n\n`;
markdown += `Generated on: ${new Date().toISOString()}\n\n`;
this.documentation.forEach((doc) => {
markdown += `## ${doc.typeName}\n\n`;
markdown += `**Topic**: \`${doc.topicName}\`\n\n`;
if (doc.description.fields.length > 0) {
markdown += `### Fields\n\n`;
markdown += `| Field Name | Type | Default Value |\n`;
markdown += `|------------|------|---------------|\n`;
doc.description.fields.forEach((field) => {
const typeStr = this.formatFieldTypeForDoc(field.type);
markdown += `| \`${field.name}\` | ${typeStr} | \`${field.default_value || 'N/A'}\` |\n`;
});
markdown += `\n`;
}
if (doc.sources.length > 0) {
markdown += `### Source Definition\n\n`;
markdown += `\`\`\`${doc.sources[0].encoding}\n`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`\n\n`;
}
markdown += `---\n\n`;

Copilot uses AI. Check for mistakes.
markdown += `### Source Definition\\n\\n`;
markdown += `\`\`\`${doc.sources[0].encoding}\\n`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`\\n\\n`;
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The escaped newline characters should be literal newlines. Replace \\n with \n.

Suggested change
markdown += `\`\`\`\\n\\n`;
markdown += `\`\`\`\n\n`;

Copilot uses AI. Check for mistakes.
Comment on lines 721 to 747
let markdown = `# Type Documentation for Node: ${nodeName}\\n\\n`;
markdown += `Generated on: ${new Date().toISOString()}\\n\\n`;

this.documentation.forEach((doc) => {
markdown += `## ${doc.typeName}\\n\\n`;
markdown += `**Topic**: \`${doc.topicName}\`\\n\\n`;

if (doc.description.fields.length > 0) {
markdown += `### Fields\\n\\n`;
markdown += `| Field Name | Type | Default Value |\\n`;
markdown += `|------------|------|---------------|\\n`;

doc.description.fields.forEach((field) => {
const typeStr = this.formatFieldTypeForDoc(field.type);
markdown += `| \`${field.name}\` | ${typeStr} | \`${field.default_value || 'N/A'}\` |\\n`;
});
markdown += `\\n`;
}

if (doc.sources.length > 0) {
markdown += `### Source Definition\\n\\n`;
markdown += `\`\`\`${doc.sources[0].encoding}\\n`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`\\n\\n`;
}

markdown += `---\\n\\n`;
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The escaped newline characters should be literal newlines. Replace \\n with \n.

Suggested change
let markdown = `# Type Documentation for Node: ${nodeName}\\n\\n`;
markdown += `Generated on: ${new Date().toISOString()}\\n\\n`;
this.documentation.forEach((doc) => {
markdown += `## ${doc.typeName}\\n\\n`;
markdown += `**Topic**: \`${doc.topicName}\`\\n\\n`;
if (doc.description.fields.length > 0) {
markdown += `### Fields\\n\\n`;
markdown += `| Field Name | Type | Default Value |\\n`;
markdown += `|------------|------|---------------|\\n`;
doc.description.fields.forEach((field) => {
const typeStr = this.formatFieldTypeForDoc(field.type);
markdown += `| \`${field.name}\` | ${typeStr} | \`${field.default_value || 'N/A'}\` |\\n`;
});
markdown += `\\n`;
}
if (doc.sources.length > 0) {
markdown += `### Source Definition\\n\\n`;
markdown += `\`\`\`${doc.sources[0].encoding}\\n`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`\\n\\n`;
}
markdown += `---\\n\\n`;
let markdown = `# Type Documentation for Node: ${nodeName}
`;
markdown += `Generated on: ${new Date().toISOString()}
`;
this.documentation.forEach((doc) => {
markdown += `## ${doc.typeName}
`;
markdown += `**Topic**: \`${doc.topicName}\`
`;
if (doc.description.fields.length > 0) {
markdown += `### Fields
`;
markdown += `| Field Name | Type | Default Value |
`;
markdown += `|------------|------|---------------|
`;
doc.description.fields.forEach((field) => {
const typeStr = this.formatFieldTypeForDoc(field.type);
markdown += `| \`${field.name}\` | ${typeStr} | \`${field.default_value || 'N/A'}\` |
`;
});
markdown += `
`;
}
if (doc.sources.length > 0) {
markdown += `### Source Definition
`;
markdown += `\`\`\`${doc.sources[0].encoding}
`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`
`;
}
markdown += `---
`;

Copilot uses AI. Check for mistakes.
Comment on lines 1011 to 1013
console.log('\\n=== Type Hierarchy ===');
this.typeHierarchy.forEach((typeInfo, typeName) => {
console.log(`\\n${typeName}:`);
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The escaped newline character should be a literal newline. Replace \\n with \n.

Suggested change
console.log('\\n=== Type Hierarchy ===');
this.typeHierarchy.forEach((typeInfo, typeName) => {
console.log(`\\n${typeName}:`);
console.log('\n=== Type Hierarchy ===');
this.typeHierarchy.forEach((typeInfo, typeName) => {
console.log(`\n${typeName}:`);

Copilot uses AI. Check for mistakes.
Comment on lines 1011 to 1013
console.log('\\n=== Type Hierarchy ===');
this.typeHierarchy.forEach((typeInfo, typeName) => {
console.log(`\\n${typeName}:`);
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The escaped newline character should be a literal newline. Replace \\n with \n.

Suggested change
console.log('\\n=== Type Hierarchy ===');
this.typeHierarchy.forEach((typeInfo, typeName) => {
console.log(`\\n${typeName}:`);
console.log('\n=== Type Hierarchy ===');
this.typeHierarchy.forEach((typeInfo, typeName) => {
console.log(`\n${typeName}:`);

Copilot uses AI. Check for mistakes.
const minTime = Math.min(...this.queryTimes);
const maxTime = Math.max(...this.queryTimes);

console.log('\\n=== Performance Results ===');
Copy link

Copilot AI Sep 19, 2025

Choose a reason for hiding this comment

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

The escaped newline character should be a literal newline. Replace \\n with \n.

Suggested change
console.log('\\n=== Performance Results ===');
console.log('\n=== Performance Results ===');

Copilot uses AI. Check for mistakes.
@coveralls
Copy link

coveralls commented Sep 19, 2025

Coverage Status

coverage: 84.368% (+0.06%) from 84.306%
when pulling e6009b0 on minggangw:fix-1267
into f459eab on RobotWebTools:develop.

@minggangw minggangw merged commit 8aaa068 into RobotWebTools:develop Sep 19, 2025
18 checks passed
minggangw added a commit that referenced this pull request Oct 13, 2025
This PR adds a comprehensive tutorial for the Type Description Service feature in rclnodejs. The tutorial provides detailed documentation on how to use the built-in ROS 2 introspection service that allows querying message and service type information from running nodes.

Key changes:
- Complete tutorial covering Type Description Service functionality, requirements, and usage patterns
- Multiple practical examples demonstrating basic usage, advanced features, and best practices
- Comprehensive troubleshooting guide and performance considerations

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

Add tutorial for type description service

2 participants