diff --git a/.github/workflows/windows-build-and-test.yml b/.github/workflows/windows-build-and-test.yml index d8dc2d9f..1a31e03d 100644 --- a/.github/workflows/windows-build-and-test.yml +++ b/.github/workflows/windows-build-and-test.yml @@ -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 @@ -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)" diff --git a/binding.gyp b/binding.gyp index bdbc45a7..ce422a63 100644 --- a/binding.gyp +++ b/binding.gyp @@ -120,6 +120,9 @@ 'include_dirs': [ './src/third_party/dlfcn-win32/', ], + 'libraries': [ + '-lrmw_fastrtps_cpp', + ], 'msvs_settings': { 'VCCLCompilerTool': { 'ExceptionHandling': '2', # /EHsc diff --git a/lib/node.js b/lib/node.js index 5b5cb4f5..3cea9152 100644 --- a/lib/node.js +++ b/lib/node.js @@ -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. + */ + getRMWImplementationIdentifier() { + return rclnodejs.getRMWImplementationIdentifier(); + } + // returns on 1st error or result {successful, reason} _validateParameters(parameters = [], declareParameterMode = false) { for (const parameter of parameters) { diff --git a/src/rcl_node_bindings.cpp b/src/rcl_node_bindings.cpp index b36892b9..8138f999 100644 --- a/src/rcl_node_bindings.cpp +++ b/src/rcl_node_bindings.cpp @@ -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)); @@ -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; } diff --git a/test/test-node.js b/test/test-node.js index 1aab1d83..6637eda6 100644 --- a/test/test-node.js +++ b/test/test-node.js @@ -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); + }); }); diff --git a/test/types/index.test-d.ts b/test/types/index.test-d.ts index b7e487a1..fb1fb8df 100644 --- a/test/types/index.test-d.ts +++ b/test/types/index.test-d.ts @@ -80,6 +80,7 @@ expectType>( rclnodejs.Node.getDefaultOptions() ); expectType(node.getFullyQualifiedName()); +expectType(node.getRMWImplementationIdentifier()); // ---- LifecycleNode ---- const lifecycleNode = rclnodejs.createLifecycleNode(LIFECYCLE_NODE_NAME); diff --git a/types/node.d.ts b/types/node.d.ts index ad9cf4d2..04a79ce2 100644 --- a/types/node.d.ts +++ b/types/node.d.ts @@ -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; } }