Skip to content

Commit f2dd1f0

Browse files
authored
Support to get the RMW implementation identifier (#1148)
This PR adds support for retrieving the RMW implementation identifier via the Node API. - Implements a new C++ binding to call `rmw_get_implementation_identifier()` - Exposes an instance method `getRMWImplementationIdentifier()` on the JavaScript `Node` class - Adds corresponding unit tests in TypeScript and JavaScript - Updates build (linking `rmw_fastrtps_cpp`) and CI to use the FastRTPS RMW implementation Fix: #1149, #1153
1 parent 2b5711b commit f2dd1f0

File tree

7 files changed

+31
-1
lines changed

7 files changed

+31
-1
lines changed

.github/workflows/windows-build-and-test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
- name: Build rclnodejs
6363
shell: cmd
6464
run: |
65+
set RMW_IMPLEMENTATION=rmw_fastrtps_cpp
6566
call "c:\dev\${{ matrix.ros_distribution }}\ros2-windows\setup.bat"
6667
npm i
6768
@@ -70,5 +71,5 @@ jobs:
7071
- name: Test rclnodejs
7172
shell: cmd
7273
run: |
74+
set RMW_IMPLEMENTATION=rmw_fastrtps_cpp
7375
call "c:\dev\${{ matrix.ros_distribution }}\ros2-windows\setup.bat"
74-
cmd /c "if NOT ${{ matrix.ros_distribution }}==rolling if NOT ${{ matrix.ros_distribution }}==kilted (npm test)"

binding.gyp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@
120120
'include_dirs': [
121121
'./src/third_party/dlfcn-win32/',
122122
],
123+
'libraries': [
124+
'-lrmw_fastrtps_cpp',
125+
],
123126
'msvs_settings': {
124127
'VCCLCompilerTool': {
125128
'ExceptionHandling': '2', # /EHsc

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)