-
Notifications
You must be signed in to change notification settings - Fork 79
feat: add descriptor namespaces #1095
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add descriptor namespaces #1095
Conversation
|
Hi @minggangw, I would like to add a couple unit tests, but I'm not sure where/how you test the content of the |
|
Hi @imcelroy thanks for submitting the PR quickly, be honest, currently, we don't have kind of unit test targeting on the generated messages for typescript specifically. We have https://github.com/RobotWebTools/rclnodejs/blame/develop/test/types/index.test-d.ts that leverages dst to test the type definitions, I think we can add some test cases that verify the generated types under |
|
Hi @minggangw, yes that sounds good to me! I will take a look and add those asap. |
|
@minggangw I have added the unit tests and opened this for review, thanks for your help! |
|
@minggangw It's strange, |
|
All seems to be good now! The Windows build that is failing seems to be present on other pull requests as well, and not directly linked to my changes. Will that block us from merging this feature? |
I suspect the failure on Windows platform may be caused by env changes, because all tests do pass on ROS2 jazzy build. I will start the review work soon, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
rostsd_gen/index.js
Outdated
| useSamePkg, | ||
| descriptorInterfaceType | ||
| ); | ||
| const tmplEnd = indentString('}\n', indentlevel); |
Copilot
AI
Apr 8, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the saveMsgAsTSD function, there is an inconsistency between the variable names 'indentlevel' and 'indentLevel'. This may lead to formatting issues; consider using a consistent variable name throughout the function.
minggangw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for submitting the PR, the implementation looks good and some comments left.
rostsd_gen/index.js
Outdated
| } | ||
|
|
||
| function saveMsgAsTSD(rosMsgInterface, fd, descriptorInterfaceType = false) { | ||
| const indentlevel = descriptorInterfaceType ? 8 : 6; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I prefer renaming indentlevel because it confused with indentLevel on L.292
rostsd_gen/index.js
Outdated
| typePrefix = '', | ||
| useSamePackageSubFolder = false | ||
| useSamePackageSubFolder = false, | ||
| descriptorInterfaceType = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer renaming descriptorInterfaceType to willGenerateDescriptionInterface
| ); | ||
| expectAssignable<'action_msgs/msg/GoalInfo'>( | ||
| cancelGoalRequestDescriptor.goal_info | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really like these ut 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
rostsd_gen/index.js
Outdated
|
|
||
| // generate descriptor msg/srv/action interfaces | ||
| fs.writeSync(fd, ` namespace ${descriptorInterfaceNamespace} {\n`); | ||
| const descriptorInterfaceType = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
descriptorInterfaceType => willGenerateDescriptionInterface
rostsd_gen/index.js
Outdated
| isInternalServiceEventMsgInterface(rosMsgInterface); | ||
| saveMsgFieldsAsTSD(rosMsgInterface, fd, 8, ';', '', useSamePkg); | ||
| fs.writeSync(fd, ' }\n'); | ||
| const indentLevel = descriptorInterfaceType ? 10 : 8; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to abstract the functionality of getting the value of indent to a separate function in this file?
|
You can add your name into https://github.com/RobotWebTools/rclnodejs/blob/develop/CONTRIBUTORS.md, it's up to you 😄 |
- rename willGenerateDescriptorInterface - create getIndentSpacing funciton - avoid similar indentLevel variable names
|
@minggangw Thank you for the review! I think I have addressed all of your comments, let me know what you think! |
minggangw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
@imcelroy I have merged the PR, if you want to land the change in a new release asap, let me know, I can prepare for it this week. |
|
@minggangw Thank you very much! Yes, if you could add this to a new release asap that would be great! I appreciate it! |
This will add a new namespace called `descriptor` for each ROS package interface generated by `generate-ros-messages`. The new namespace is found inside the msg|srv|action namespace for each package. For example:
```typescript
namespace builtin_interfaces {
namespace msg {
export interface Duration {
sec: number;
nanosec: number;
}
export interface DurationConstructor {
new(other?: Duration): Duration;
}
export interface Time {
sec: number;
nanosec: number;
}
export interface TimeConstructor {
new(other?: Time): Time;
}
namespace descriptor {
export interface Duration {
sec: 'int32';
nanosec: 'uint32';
}
export interface Time {
sec: 'int32';
nanosec: 'uint32';
}
}
}
}
```
The descriptor interfaces always have the format `{field: "<interface_type>"}`. For example:
```typescript
namespace geometry_msgs {
namespace msg {
namespace descriptor {
export interface PointStamped {
header: 'std_msgs/msg/Header';
point: 'geometry_msgs/msg/Point';
}
}
}
}
```
Here is the discussion: [discussions/1091](#1091)
|
@minggangw wow! Thank you very much for the speed; that was impressive! 🎉 |
Public API Changes
None
Description
This will add a new namespace called
descriptorfor each ROS package interface generated bygenerate-ros-messages. The new namespace is found inside the msg|srv|action namespace for each package. For example:The descriptor interfaces always have the format
{field: "<interface_type>"}. For example:Here is the discussion: discussions/1091