Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/windows-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
- name: Build rclnodejs
shell: cmd
run: |
set RMW_IMPLEMENTATION=rmw_fastrtps_cpp
call "c:\dev\${{ matrix.ros_distribution }}\ros2-windows\setup.bat"
npm i

Expand All @@ -70,5 +71,5 @@ jobs:
- name: Test rclnodejs
shell: cmd
run: |
set RMW_IMPLEMENTATION=rmw_fastrtps_cpp
call "c:\dev\${{ matrix.ros_distribution }}\ros2-windows\setup.bat"
cmd /c "if NOT ${{ matrix.ros_distribution }}==rolling if NOT ${{ matrix.ros_distribution }}==kilted (npm test)"
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
'-lrcl_yaml_param_parser',
'-lrcpputils',
'-lrmw',
'-lrmw_fastrtps_cpp',
Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

[nitpick] Hardcoding the FastRTPS library couples the build to one RMW implementation; consider linking only the generic rmw library or making this conditional based on the RMW_IMPLEMENTATION variable.

Suggested change
'-lrmw_fastrtps_cpp',
'<!(node -p "process.env.RMW_IMPLEMENTATION === \'fastrtps\' ? \'-lrmw_fastrtps_cpp\' : \'\'")',

Copilot uses AI. Check for mistakes.
'-lrosidl_runtime_c',
],
'defines': [
Expand Down
8 changes: 8 additions & 0 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1637,6 +1637,14 @@ class Node extends rclnodejs.ShadowNode {
return rclnodejs.getFullyQualifiedName(this.handle);
}

/**
* Get the RMW implementation identifier
* @returns {string} - The RMW implementation identifier.
Copy link

Copilot AI May 27, 2025

Choose a reason for hiding this comment

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

[nitpick] In the JSDoc comment, update the @returns tag to follow standard format: @returns {string} The RMW implementation identifier. (remove the hyphen).

Suggested change
* @returns {string} - The RMW implementation identifier.
* @returns {string} The RMW implementation identifier.

Copilot uses AI. Check for mistakes.
*/
getRMWImplementationIdentifier() {
return rclnodejs.getRMWImplementationIdentifier();
}

// returns on 1st error or result {successful, reason}
_validateParameters(parameters = [], declareParameterMode = false) {
for (const parameter of parameters) {
Expand Down
6 changes: 6 additions & 0 deletions src/rcl_node_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,10 @@ Napi::Value GetFullyQualifiedName(const Napi::CallbackInfo& info) {
return Napi::String::New(env, fully_qualified_node_name);
}

Napi::Value GetRMWImplementationIdentifier(const Napi::CallbackInfo& info) {
return Napi::String::New(info.Env(), rmw_get_implementation_identifier());
}

Napi::Object InitNodeBindings(Napi::Env env, Napi::Object exports) {
exports.Set("getParameterOverrides",
Napi::Function::New(env, GetParameterOverrides));
Expand All @@ -468,6 +472,8 @@ Napi::Object InitNodeBindings(Napi::Env env, Napi::Object exports) {
exports.Set("getNodeNames", Napi::Function::New(env, GetNodeNames));
exports.Set("getFullyQualifiedName",
Napi::Function::New(env, GetFullyQualifiedName));
exports.Set("getRMWImplementationIdentifier",
Napi::Function::New(env, GetRMWImplementationIdentifier));
return exports;
}

Expand Down
5 changes: 5 additions & 0 deletions test/test-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,4 +566,9 @@ describe('Test the node with no handles attached when initializing', function ()
);
}, 100);
});

it('Get RMW identifier', function () {
const node = rclnodejs.createNode('rmw', '/rmw_getter');
assert.notStrictEqual(node.getRMWImplementationIdentifier().length, 0);
});
});
1 change: 1 addition & 0 deletions test/types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ expectType<rclnodejs.Options<string | rclnodejs.QoS>>(
rclnodejs.Node.getDefaultOptions()
);
expectType<string>(node.getFullyQualifiedName());
expectType<string>(node.getRMWImplementationIdentifier());

// ---- LifecycleNode ----
const lifecycleNode = rclnodejs.createLifecycleNode(LIFECYCLE_NODE_NAME);
Expand Down
6 changes: 6 additions & 0 deletions types/node.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,5 +828,11 @@ declare module 'rclnodejs' {
* @returns String containing the fully qualified name of the node.
*/
getFullyQualifiedName(): string;

/**
* Get the RMW implementation identifier
* @returns - The RMW implementation identifier.
*/
getRMWImplementationIdentifier(): string;
}
}
Loading