Skip to content

Add tutorial for type description service#1268

Merged
minggangw merged 2 commits into
RobotWebTools:developfrom
minggangw:fix-1267
Sep 19, 2025
Merged

Add tutorial for type description service#1268
minggangw merged 2 commits into
RobotWebTools:developfrom
minggangw:fix-1267

Conversation

@minggangw

@minggangw minggangw commented Sep 19, 2025

Copy link
Copy Markdown
Member

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

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 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}`);

Copilot AI Sep 19, 2025

Copy link

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.
Comment thread tutorials/type-description-service.md Outdated
processTypeDescription(typeName, response) {
const typeDesc = response.type_description.type_description;

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

Copilot AI Sep 19, 2025

Copy link

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.
Comment thread tutorials/type-description-service.md Outdated
}

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

Copilot AI Sep 19, 2025

Copy link

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 thread tutorials/type-description-service.md Outdated
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`;

Copilot AI Sep 19, 2025

Copy link

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 thread tutorials/type-description-service.md Outdated
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`;

Copilot AI Sep 19, 2025

Copy link

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 thread tutorials/type-description-service.md Outdated
markdown += `### Source Definition\\n\\n`;
markdown += `\`\`\`${doc.sources[0].encoding}\\n`;
markdown += doc.sources[0].raw_file_contents;
markdown += `\`\`\`\\n\\n`;

Copilot AI Sep 19, 2025

Copy link

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 thread tutorials/type-description-service.md Outdated
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`;

Copilot AI Sep 19, 2025

Copy link

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 thread tutorials/type-description-service.md Outdated
Comment on lines +1011 to +1013
console.log('\\n=== Type Hierarchy ===');
this.typeHierarchy.forEach((typeInfo, typeName) => {
console.log(`\\n${typeName}:`);

Copilot AI Sep 19, 2025

Copy link

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 thread tutorials/type-description-service.md Outdated
Comment on lines +1011 to +1013
console.log('\\n=== Type Hierarchy ===');
this.typeHierarchy.forEach((typeInfo, typeName) => {
console.log(`\\n${typeName}:`);

Copilot AI Sep 19, 2025

Copy link

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 thread tutorials/type-description-service.md Outdated
const minTime = Math.min(...this.queryTimes);
const maxTime = Math.max(...this.queryTimes);

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

Copilot AI Sep 19, 2025

Copy link

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

coveralls commented Sep 19, 2025

Copy link
Copy Markdown

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

3 participants