Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
8 changes: 8 additions & 0 deletions lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,14 @@ class Node extends rclnodejs.ShadowNode {
}
}

/**
* Get the RMW implementation identifier
* @returns {string} - The RMW implementation identifier.
*/
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 @@ -419,6 +419,10 @@ Napi::Value GetNodeNames(const Napi::CallbackInfo& info) {
return result_list;
}

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 @@ -439,6 +443,8 @@ Napi::Object InitNodeBindings(Napi::Env env, Napi::Object exports) {
exports.Set("countServices", Napi::Function::New(env, CountServices));
#endif
exports.Set("getNodeNames", Napi::Function::New(env, GetNodeNames));
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 @@ -544,4 +544,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 @@ -76,6 +76,7 @@ expectType<number>(node.countServices(SERVICE_NAME));
expectType<rclnodejs.Options<string | rclnodejs.QoS>>(
rclnodejs.Node.getDefaultOptions()
);
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 @@ -796,5 +796,11 @@ declare module 'rclnodejs' {
* @returns Number of services.
*/
countServices(serviceName: string): number;

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