Skip to content

Commit 891804e

Browse files
committed
Support to get the RMW implementation identifier
1 parent 2b5711b commit 891804e

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

lib/node.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,6 +1637,14 @@ class Node extends rclnodejs.ShadowNode {
16371637
return rclnodejs.getFullyQualifiedName(this.handle);
16381638
}
16391639

1640+
/**
1641+
* Get the RMW implementation identifier
1642+
* @returns {string} - The RMW implementation identifier.
1643+
*/
1644+
getRMWImplementationIdentifier() {
1645+
return rclnodejs.getRMWImplementationIdentifier();
1646+
}
1647+
16401648
// returns on 1st error or result {successful, reason}
16411649
_validateParameters(parameters = [], declareParameterMode = false) {
16421650
for (const parameter of parameters) {

src/rcl_node_bindings.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ Napi::Value GetFullyQualifiedName(const Napi::CallbackInfo& info) {
446446
return Napi::String::New(env, fully_qualified_node_name);
447447
}
448448

449+
Napi::Value GetRMWImplementationIdentifier(const Napi::CallbackInfo& info) {
450+
return Napi::String::New(info.Env(), rmw_get_implementation_identifier());
451+
}
452+
449453
Napi::Object InitNodeBindings(Napi::Env env, Napi::Object exports) {
450454
exports.Set("getParameterOverrides",
451455
Napi::Function::New(env, GetParameterOverrides));
@@ -468,6 +472,8 @@ Napi::Object InitNodeBindings(Napi::Env env, Napi::Object exports) {
468472
exports.Set("getNodeNames", Napi::Function::New(env, GetNodeNames));
469473
exports.Set("getFullyQualifiedName",
470474
Napi::Function::New(env, GetFullyQualifiedName));
475+
exports.Set("getRMWImplementationIdentifier",
476+
Napi::Function::New(env, GetRMWImplementationIdentifier));
471477
return exports;
472478
}
473479

test/test-node.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,4 +566,9 @@ describe('Test the node with no handles attached when initializing', function ()
566566
);
567567
}, 100);
568568
});
569+
570+
it('Get RMW identifier', function () {
571+
const node = rclnodejs.createNode('rmw', '/rmw_getter');
572+
assert.notStrictEqual(node.getRMWImplementationIdentifier().length, 0);
573+
});
569574
});

test/types/index.test-d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ expectType<rclnodejs.Options<string | rclnodejs.QoS>>(
8080
rclnodejs.Node.getDefaultOptions()
8181
);
8282
expectType<string>(node.getFullyQualifiedName());
83+
expectType<string>(node.getRMWImplementationIdentifier());
8384

8485
// ---- LifecycleNode ----
8586
const lifecycleNode = rclnodejs.createLifecycleNode(LIFECYCLE_NODE_NAME);

types/node.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,5 +828,11 @@ declare module 'rclnodejs' {
828828
* @returns String containing the fully qualified name of the node.
829829
*/
830830
getFullyQualifiedName(): string;
831+
832+
/**
833+
* Get the RMW implementation identifier
834+
* @returns - The RMW implementation identifier.
835+
*/
836+
getRMWImplementationIdentifier(): string;
831837
}
832838
}

0 commit comments

Comments
 (0)