rclnodejs 0.21.1 → 0.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,44 @@
1
+ name: Identify ROS Distro from GITHUB_REF_NAME
2
+
3
+ on:
4
+ workflow_call:
5
+ outputs:
6
+ distro:
7
+ description: "The ROS distribution short name"
8
+ value: ${{ jobs.identify-ros-distro.outputs.distro }}
9
+ linuxos:
10
+ description: "The ROS compatible Linux version"
11
+ value: ${{ jobs.identify-ros-distro.outputs.linuxos }}
12
+ env:
13
+ ROLLING_VAR: ${{ contains(github.ref, 'develop') }}
14
+ HUMBLE_VAR: ${{ contains(github.ref, 'humble') }}
15
+ GALACTIC_VAR: ${{ contains(github.ref, 'galactic') }}
16
+ FOXY_VAR: ${{ contains(github.ref, 'foxy') }}
17
+
18
+ jobs:
19
+ identify-ros-distro:
20
+ runs-on: ubuntu-latest
21
+ outputs:
22
+ distro: ${{ steps.identify.outputs.distro }}
23
+ linuxos: ${{ steps.identify.outputs.linuxos }}
24
+ steps:
25
+ - name: Identify distro
26
+ id: identify
27
+ run: |
28
+ if ${ROLLING_VAR} == true; then
29
+ echo "::set-output name=distro::rolling"
30
+ echo "::set-output name=linuxos::ubuntu-22.04"
31
+ elif ${HUMBLE_VAR} == true; then
32
+ echo "::set-output name=distro::humble"
33
+ echo "::set-output name=linuxos::ubuntu-22.04"
34
+ elif ${GALACTIC_VAR} == true; then
35
+ echo "::set-output name=distro::galactic"
36
+ echo "::set-output name=linuxos::ubuntu-20.04"
37
+ elif ${FOXY_VAR} == true; then
38
+ echo "::set-output name=distro::foxy"
39
+ echo "::set-output name=linuxos::ubuntu-20.04"
40
+ else
41
+ echo "Unable to map branch name to ROS distro, using ROLLING as default"
42
+ echo "::set-output name=distro::rolling"
43
+ echo "::set-output name=linuxos::ubuntu-22.04"
44
+ fi
@@ -0,0 +1,67 @@
1
+ on:
2
+ workflow_dispatch:
3
+
4
+ jobs:
5
+ build-humble-and-rolling: # humble and rolling distros
6
+ runs-on: ubuntu-22.04
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ node-version: [10.X, 12.x, 14.X, 16.X, 17.X]
11
+ ros_distribution:
12
+ - humble
13
+ - rolling
14
+
15
+ steps:
16
+ - name: Setup ROS2
17
+ uses: ros-tooling/setup-ros@v0.3
18
+ with:
19
+ required-ros-distributions: ${{ matrix.ros_distribution }}
20
+
21
+ - name: Install test-msgs on Linux
22
+ run: |
23
+ sudo apt install ros-${{ matrix.ros_distribution }}-test-msgs
24
+ - uses: actions/checkout@v3
25
+
26
+ - name: Setup Node.js ${{ matrix.node-version }}
27
+ uses: actions/setup-node@v2
28
+ with:
29
+ node-version: ${{ matrix.node-version }}
30
+
31
+ - name: Build and test rclnodejs
32
+ run: |
33
+ source /opt/ros/${{ matrix.ros_distribution }}/setup.bash
34
+ npm i
35
+ npm test
36
+
37
+ build-foxy-and-galactic: # foxy and galactic distros
38
+ runs-on: ubuntu-20.04
39
+ strategy:
40
+ fail-fast: false
41
+ matrix:
42
+ node-version: [10.X, 12.x, 14.X, 16.X, 17.X]
43
+ ros_distribution:
44
+ - foxy
45
+ - galactic
46
+
47
+ steps:
48
+ - name: Setup ROS2
49
+ uses: ros-tooling/setup-ros@v0.3
50
+ with:
51
+ required-ros-distributions: ${{ matrix.ros_distribution }}
52
+
53
+ - name: Install test-msgs on Linux
54
+ run: |
55
+ sudo apt install ros-${{ matrix.ros_distribution }}-test-msgs
56
+ - uses: actions/checkout@v3
57
+
58
+ - name: Setup Node.js ${{ matrix.node-version }}
59
+ uses: actions/setup-node@v2
60
+ with:
61
+ node-version: ${{ matrix.node-version }}
62
+
63
+ - name: Build and test rclnodejs
64
+ run: |
65
+ source /opt/ros/${{ matrix.ros_distribution }}/setup.bash
66
+ npm i
67
+ npm test
@@ -0,0 +1,51 @@
1
+
2
+ name: rclnodejs - Linux Build and Test
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - develop
8
+ - humble-hawksbill
9
+ - galactic-geochelone
10
+ - foxy-fitzroy
11
+ pull_request:
12
+ branches:
13
+ - develop
14
+ - humble-hawksbill
15
+ - galactic-geochelone
16
+ - foxy-fitzroy
17
+ workflow_dispatch:
18
+
19
+ jobs:
20
+ identify-ros-distro:
21
+ uses: ./.github/workflows/identify-ros-distro.yml
22
+
23
+ build:
24
+ needs: identify-ros-distro
25
+ runs-on: ${{ needs.identify-ros-distro.outputs.linuxos }}
26
+ strategy:
27
+ fail-fast: false
28
+ matrix:
29
+ node-version: [10.X, 12.X, 14.X, 16.11.X, 17.X]
30
+ steps:
31
+ - name: Setup Node.js ${{ matrix.node-version }}
32
+ uses: actions/setup-node@v2
33
+ with:
34
+ node-version: ${{ matrix.node-version }}
35
+
36
+ - name: Setup ROS2
37
+ uses: ros-tooling/setup-ros@v0.3
38
+ with:
39
+ required-ros-distributions: ${{ needs.identify-ros-distro.outputs.distro }}
40
+
41
+ - name: Install test-msgs on Linux
42
+ run: |
43
+ sudo apt install ros-${{ needs.identify-ros-distro.outputs.distro }}-test-msgs
44
+
45
+ - uses: actions/checkout@v3
46
+
47
+ - name: Build and test rclnodejs
48
+ run: |
49
+ source /opt/ros/${{ needs.identify-ros-distro.outputs.distro }}/setup.bash
50
+ npm i
51
+ npm test
@@ -0,0 +1,52 @@
1
+
2
+ name: rclnodejs - Windows Build & Test Compatibility
3
+
4
+ on:
5
+ workflow_dispatch:
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: windows-2019
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ node-version: [10.X, 12.X, 14.X, 16.11.X, 17.X]
14
+ ros_distribution:
15
+ - foxy
16
+ - galactic
17
+ - humble
18
+ - rolling
19
+ steps:
20
+ - name: Setup Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v2
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+
25
+ - name: Setup ROS2
26
+ uses: ros-tooling/setup-ros@v0.3
27
+ with:
28
+ required-ros-distributions: ${{ matrix.ros_distribution }}
29
+
30
+ - name: Install ROS2 Rolling (Conditional)
31
+ if: ${{ matrix.ros_distribution == 'rolling' }}
32
+ shell: bash
33
+ run: |
34
+ wget --quiet https://ci.ros2.org/view/packaging/job/packaging_windows/lastSuccessfulBuild/artifact/ws/ros2-package-windows-AMD64.zip -O rolling.zip
35
+ 7z x rolling.zip -y -o/c/dev/rolling
36
+
37
+ - name: Prebuild - Setup VS Dev Environment
38
+ uses: seanmiddleditch/gha-setup-vsdevenv@v4
39
+
40
+ - uses: actions/checkout@v3
41
+
42
+ - name: Build rclnodejs
43
+ shell: cmd
44
+ run: |
45
+ call "c:\dev\${{ matrix.ros_distribution }}\ros2-windows\setup.bat"
46
+ npm i
47
+
48
+ - name: Test rclnodejs
49
+ shell: cmd
50
+ run: |
51
+ call "c:\dev\${{ needs.identify-ros-distro.outputs.distro }}\ros2-windows\setup.bat"
52
+ npm test
@@ -0,0 +1,63 @@
1
+
2
+ name: rclnodejs - Windows Build & Test
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - develop
8
+ - humble-hawksbill
9
+ - galactic-geochelone
10
+ - foxy-fitzroy
11
+ pull_request:
12
+ branches:
13
+ - develop
14
+ - humble-hawksbill
15
+ - galactic-geochelone
16
+ - foxy-fitzroy
17
+ workflow_dispatch:
18
+
19
+ jobs:
20
+ identify-ros-distro:
21
+ uses: ./.github/workflows/identify-ros-distro.yml
22
+
23
+ build:
24
+ needs: identify-ros-distro
25
+ runs-on: windows-2019
26
+ strategy:
27
+ fail-fast: false
28
+ matrix:
29
+ node-version: [10.X, 12.X, 14.X, 16.11.X, 17.X]
30
+ steps:
31
+ - name: Setup Node.js ${{ matrix.node-version }}
32
+ uses: actions/setup-node@v2
33
+ with:
34
+ node-version: ${{ matrix.node-version }}
35
+
36
+ - name: Setup ROS2
37
+ uses: ros-tooling/setup-ros@v0.3
38
+ with:
39
+ required-ros-distributions: ${{ needs.identify-ros-distro.outputs.distro }}
40
+
41
+ - name: Install ROS2 Rolling (Conditional)
42
+ if: ${{ needs.identify-ros-distro.outputs.distro == 'rolling' }}
43
+ shell: bash
44
+ run: |
45
+ wget --quiet https://ci.ros2.org/view/packaging/job/packaging_windows/lastSuccessfulBuild/artifact/ws/ros2-package-windows-AMD64.zip -O rolling.zip
46
+ 7z x rolling.zip -y -o/c/dev/rolling
47
+
48
+ - name: Prebuild - Setup VS Dev Environment
49
+ uses: seanmiddleditch/gha-setup-vsdevenv@v4
50
+
51
+ - uses: actions/checkout@v3
52
+
53
+ - name: Build rclnodejs
54
+ shell: cmd
55
+ run: |
56
+ call "c:\dev\${{ needs.identify-ros-distro.outputs.distro }}\ros2-windows\setup.bat"
57
+ npm i
58
+
59
+ - name: Test rclnodejs
60
+ shell: cmd
61
+ run: |
62
+ call "c:\dev\${{ needs.identify-ros-distro.outputs.distro }}\ros2-windows\setup.bat"
63
+ npm test
package/README.md CHANGED
@@ -18,7 +18,7 @@ rclnodejs.init().then(() => {
18
18
 
19
19
  **Node.js**
20
20
 
21
- - [Node.js](https://nodejs.org/en/) version between 10.23 - 16.x.
21
+ - [Node.js](https://nodejs.org/en/) version between 10.23 - 17.x.
22
22
 
23
23
  **ROS 2 SDK**
24
24
 
@@ -43,10 +43,10 @@ npm i rclnodejs@x.y.z
43
43
 
44
44
  #### RCLNODEJS - ROS 2 Version Compatibility
45
45
 
46
- | RCLNODEJS Version | Compatible ROS 2 Release |
47
- | :-------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
48
- | [0.21.1 (current)](https://www.npmjs.com/package/rclnodejs/v/0.21.1) ([API](http://robotwebtools.org/rclnodejs/docs/0.21.0/index.html)) | [Galactic Geochelone](https://github.com/ros2/ros2/releases/tag/release-galactic-20210716) / [Foxy Fitzroy](https://github.com/ros2/ros2/releases/tag/release-foxy-20201211) / [Eloquent Elusor](https://github.com/ros2/ros2/releases/tag/release-eloquent-20200124) |
49
- | [0.10.3](https://github.com/RobotWebTools/rclnodejs/releases/tag/0.10.3) | [Dashing Diademata - Patch 4](https://github.com/ros2/ros2/releases/tag/release-dashing-20191018) |
46
+ | RCLNODEJS Version | Compatible ROS 2 Release |
47
+ | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
48
+ | [0.21.2 (current)](https://www.npmjs.com/package/rclnodejs/v/0.21.2) ([API](http://robotwebtools.org/rclnodejs/docs/0.21.0/index.html)) | [Humble Hawksbill](https://github.com/ros2/ros2/releases/tag/release-humble-20220523)<br>[Galactic Geochelone](https://github.com/ros2/ros2/releases/tag/release-galactic-20210716)<br>[Foxy Fitzroy](https://github.com/ros2/ros2/releases/tag/release-foxy-20201211)<br>[Eloquent Elusor](https://github.com/ros2/ros2/releases/tag/release-eloquent-20200124) |
49
+ | [0.10.3](https://github.com/RobotWebTools/rclnodejs/releases/tag/0.10.3) | [Dashing Diademata - Patch 4](https://github.com/ros2/ros2/releases/tag/release-dashing-20191018) |
50
50
 
51
51
  ## Documentation
52
52
 
package/binding.gyp CHANGED
@@ -8,7 +8,7 @@
8
8
  }
9
9
  },
10
10
  'variables': {
11
- 'ros_version': '<!(node scripts/ros_distro.js)'
11
+ 'ros_version': '<!(node scripts/ros_distro.js)',
12
12
  },
13
13
  'targets': [
14
14
  {
@@ -61,12 +61,36 @@
61
61
  'cflags_cc': [
62
62
  '-std=c++14'
63
63
  ],
64
- 'include_dirs': [
64
+ 'include_dirs':
65
+ [
65
66
  "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/ ') + '/include/')\")",
66
67
  ],
67
68
  'library_dirs': [
68
69
  "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/lib/ ') + '/lib/')\")",
69
70
  ],
71
+ 'conditions': [
72
+ [
73
+ 'ros_version > 2105', # Humble, Rolling, ...
74
+ {
75
+ 'include_dirs':
76
+ [
77
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/ ') + '/include/')\")",
78
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl/ ') + '/include/rcl')\")",
79
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcutils/ ') + '/include/rcutils/')\")",
80
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rmw/ ') + '/include/rmw/')\")",
81
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl_yaml_param_parser/ ') + '/include/rcl_yaml_param_parser/')\")",
82
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rosidl_typesupport_interface/ ') + '/include/rosidl_typesupport_interface/')\")",
83
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl_action/ ') + '/include/rcl_action/')\")",
84
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/action_msgs/ ') + '/include/action_msgs/')\")",
85
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/unique_identifier_msgs/ ') + '/include/unique_identifier_msgs/')\")",
86
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/builtin_interfaces/ ') + '/include/builtin_interfaces/')\")",
87
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rcl_lifecycle/ ') + '/include/rcl_lifecycle/')\")",
88
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/lifecycle_msgs/ ') + '/include/lifecycle_msgs/')\")",
89
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/:/g, '/include/rosidl_runtime_c/ ') + '/include/rosidl_runtime_c/')\")",
90
+ ],
91
+ }
92
+ ],
93
+ ],
70
94
  }
71
95
  ],
72
96
  [
@@ -80,7 +104,7 @@
80
104
  ],
81
105
  'include_dirs': [
82
106
  './src/third_party/dlfcn-win32/',
83
- "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '\\\include ').replace(/\\\/g, '/') + '/include')\")",
107
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include ').replace(/\\\/g, '/') + '/include')\")",
84
108
  ],
85
109
  'msvs_settings': {
86
110
  'VCCLCompilerTool': {
@@ -90,11 +114,34 @@
90
114
  'AdditionalDependencies': ['psapi.lib'],
91
115
  'AdditionalLibraryDirectories': ["<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '\\\lib ').replace(/\\\/g, '/') + '/lib')\")",],
92
116
  }
93
- }
117
+ },
118
+ 'conditions': [
119
+ [
120
+ 'ros_version > 2105', # Humble, Rolling, ... TODO - not tested due to broken setup_ros v3.3 action on windows
121
+ {
122
+ 'include_dirs':
123
+ [
124
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rcl ').replace(/\\\/g, '/') + '/include/rcl')\")",
125
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rcutils ').replace(/\\\/g, '/') + '/include/rcutils')\")",
126
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rmw ').replace(/\\\/g, '/') + '/include/rmw')\")",
127
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rcl_yaml_param_parser ').replace(/\\\/g, '/') + '/include/rcl_yaml_param_parser')\")",
128
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rosidl_runtime_c ').replace(/\\\/g, '/') + '/include/rosidl_runtime_c')\")",
129
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rosidl_typesupport_interface ').replace(/\\\/g, '/') + '/include/rosidl_typesupport_interface')\")",
130
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rcl_action ').replace(/\\\/g, '/') + '/include/rcl_action')\")",
131
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/action_msgs ').replace(/\\\/g, '/') + '/include/action_msgs')\")",
132
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/unique_identifier_msgs ').replace(/\\\/g, '/') + '/include/unique_identifier_msgs')\")",
133
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/builtin_interfaces ').replace(/\\\/g, '/') + '/include/builtin_interfaces')\")",
134
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/rcl_lifecycle ').replace(/\\\/g, '/') + '/include/rcl_lifecycle')\")",
135
+ "<!@(node -e \"console.log(process.env.AMENT_PREFIX_PATH.replace(/;/g, '/include/lifecycle_msgs ').replace(/\\\/g, '/') + '/include/lifecycle_msgs')\")",
136
+ ],
137
+ }
138
+ ]
139
+ ]
94
140
  }
95
141
  ],
96
142
  [
97
143
  'OS=="mac"',
144
+ # TODO - macos is no longer a tier-1 ROS platform and we have no binary ROS builds to test for Humble & Rolling
98
145
  {
99
146
  'defines': [
100
147
  'OS_MACOS'
package/index.js CHANGED
@@ -14,6 +14,7 @@
14
14
 
15
15
  'use strict';
16
16
 
17
+ const DistroUtils = require('./lib/distro.js');
17
18
  const { Clock, ROSClock } = require('./lib/clock.js');
18
19
  const ClockType = require('./lib/clock_type.js');
19
20
  const compareVersions = require('compare-versions');
@@ -104,6 +105,9 @@ let rcl = {
104
105
  */
105
106
  DEFAULT_NUMERIC_RANGE_TOLERANCE: DEFAULT_NUMERIC_RANGE_TOLERANCE,
106
107
 
108
+ /** {@link DistroUtils} */
109
+ DistroUtils: DistroUtils,
110
+
107
111
  /** {@link Duration} class */
108
112
  Duration: Duration,
109
113
 
package/lib/client.js CHANGED
@@ -28,7 +28,7 @@ class Client extends Entity {
28
28
  super(handle, typeClass, options);
29
29
  this._nodeHandle = nodeHandle;
30
30
  this._serviceName = serviceName;
31
- this._sequenceNumber = 0;
31
+ this._sequenceNumberToCallbackMap = new Map();
32
32
  }
33
33
 
34
34
  /**
@@ -58,18 +58,21 @@ class Client extends Entity {
58
58
  }
59
59
 
60
60
  let rawRequest = requestToSend.serialize();
61
- this._sequenceNumber = rclnodejs.sendRequest(this._handle, rawRequest);
61
+ let sequenceNumber = rclnodejs.sendRequest(this._handle, rawRequest);
62
62
  debug(`Client has sent a ${this._serviceName} request.`);
63
- this._callback = callback;
63
+ this._sequenceNumberToCallbackMap.set(sequenceNumber, callback);
64
64
  }
65
65
 
66
- get sequenceNumber() {
67
- return this._sequenceNumber;
68
- }
69
-
70
- processResponse(response) {
71
- debug(`Client has received ${this._serviceName} response from service.`);
72
- this._callback(response.toPlainObject(this.typedArrayEnabled));
66
+ processResponse(sequenceNumber, response) {
67
+ if (this._sequenceNumberToCallbackMap.has(sequenceNumber)) {
68
+ debug(`Client has received ${this._serviceName} response from service.`);
69
+ let callback = this._sequenceNumberToCallbackMap.get(sequenceNumber);
70
+ this._sequenceNumberToCallbackMap.delete(sequenceNumber);
71
+ callback(response.toPlainObject(this.typedArrayEnabled));
72
+ } else {
73
+ error(`Client has received an unexpected ${this._serviceName}
74
+ response with sequence number ${sequenceNumber}.`);
75
+ }
73
76
  }
74
77
 
75
78
  /**
package/lib/distro.js ADDED
@@ -0,0 +1,70 @@
1
+ // Copyright (c) 2022 Wayne Parrott. All rights reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ 'use strict';
16
+
17
+ /**
18
+ * enum style distribution identifiers
19
+ */
20
+ const DistroId = {
21
+ UNKNOWN: 0,
22
+ ELOQUENT: 1911,
23
+ FOXY: 2006,
24
+ GALACTIC: 2105,
25
+ HUMBLE: 2205,
26
+ ROLLING: 5000,
27
+ };
28
+
29
+ const DistroNameIdMap = new Map();
30
+ DistroNameIdMap.set('eloquent', DistroId.ELOQUENT);
31
+ DistroNameIdMap.set('foxy', DistroId.FOXY);
32
+ DistroNameIdMap.set('galactic', DistroId.GALACTIC);
33
+ DistroNameIdMap.set('humble', DistroId.HUMBLE);
34
+ DistroNameIdMap.set('rolling', DistroId.ROLLING);
35
+
36
+ const DistroUtils = {
37
+ DistroId: DistroId,
38
+
39
+ /**
40
+ * Get the rclnodejs distro ID for a ROS 2 distro name.
41
+ * @param {string|undefined} [distroName] - The ROS 2 short distro name, e.g., foxy, Defaults to the value of the ROS_DISTRO envar.
42
+ * @return {number} Return the rclnodejs distro identifier
43
+ */
44
+ getDistroId: function (distroName) {
45
+ const dname = distroName ? distroName : this.getDistroName();
46
+
47
+ return DistroNameIdMap.has(dname)
48
+ ? DistroNameIdMap.get(dname)
49
+ : DistroId.UNKNOWN;
50
+ },
51
+
52
+ /**
53
+ * Get the short ROS 2 distro name associated with a rclnodejs distro ID.
54
+ * @param {number|undefined} [distroId] - The rclnodejs distro identifier. Defaults to the value of the ROS_DISTRO envar.
55
+ * @return {string|undefined} Return the name of the ROS distribution or undefined if unable to identify the distro.
56
+ */
57
+ getDistroName: function (distroId) {
58
+ if (!distroId) {
59
+ return process.env.ROS_DISTRO;
60
+ }
61
+
62
+ return [...DistroNameIdMap].find(([key, val]) => val == distroId)[0];
63
+ },
64
+
65
+ getKnownDistroNames: function () {
66
+ return [...DistroNameIdMap.keys()];
67
+ },
68
+ };
69
+
70
+ module.exports = DistroUtils;
package/lib/node.js CHANGED
@@ -204,13 +204,12 @@ class Node extends rclnodejs.ShadowNode {
204
204
  this._runWithMessageType(
205
205
  client.typeClass.Response,
206
206
  (message, deserialize) => {
207
- let success = rclnodejs.rclTakeResponse(
207
+ let sequenceNumber = rclnodejs.rclTakeResponse(
208
208
  client.handle,
209
- client.sequenceNumber,
210
209
  message
211
210
  );
212
- if (success) {
213
- client.processResponse(deserialize());
211
+ if (sequenceNumber !== undefined) {
212
+ client.processResponse(sequenceNumber, deserialize());
214
213
  }
215
214
  }
216
215
  );
package/lib/parameter.js CHANGED
@@ -71,7 +71,7 @@ class Parameter {
71
71
  /**
72
72
  * Create a Parameter instance from an rlc_interfaces/msg/Parameter message.
73
73
  * @constructs
74
- * @param {rlc_interfaces/msg/Parameter} parameterMsg - The message to convert to a parameter.
74
+ * @param {rcl_interfaces/msg/Parameter} parameterMsg - The message to convert to a parameter.
75
75
  * @return {Parameter} - The new instance.
76
76
  */
77
77
  static fromParameterMessage(parameterMsg) {
@@ -89,25 +89,25 @@ class Parameter {
89
89
  value = parameterMsg.value.bool_array_value;
90
90
  break;
91
91
  case ParameterType.PARAMETER_BYTE_ARRAY:
92
- value = parameterMsg.value.byte_array_value;
92
+ value = Array.from(parameterMsg.value.byte_array_value);
93
93
  break;
94
94
  case ParameterType.PARAMETER_DOUBLE:
95
95
  value = parameterMsg.value.double_value;
96
96
  break;
97
97
  case ParameterType.PARAMETER_DOUBLE_ARRAY:
98
- value = parameterMsg.value.double_array_value;
98
+ value = Array.from(parameterMsg.value.double_array_value);
99
99
  break;
100
100
  case ParameterType.PARAMETER_INTEGER:
101
101
  value = parameterMsg.value.integer_value;
102
102
  break;
103
103
  case ParameterType.PARAMETER_INTEGER_ARRAY:
104
- value = parameterMsg.value.integer_array_value;
104
+ value = Array.from(parameterMsg.value.integer_array_value);
105
105
  break;
106
106
  case ParameterType.PARAMETER_STRING:
107
107
  value = parameterMsg.value.string_value;
108
108
  break;
109
109
  case ParameterType.PARAMETER_STRING_ARRAY:
110
- value = parameterMsg.value.string_array_value;
110
+ value = Array.from(parameterMsg.value.string_array_value);
111
111
  break;
112
112
  }
113
113
 
@@ -225,12 +225,10 @@ class Parameter {
225
225
  case ParameterType.PARAMETER_NOT_SET:
226
226
  break;
227
227
  case ParameterType.PARAMETER_BOOL:
228
- msg.bool_value = this.value ? 'true' : 'false';
228
+ msg.bool_value = this.value;
229
229
  break;
230
230
  case ParameterType.PARAMETER_BOOL_ARRAY:
231
- msg.bool_array_value = this.value.map((val) =>
232
- val ? 'true' : 'false'
233
- );
231
+ msg.bool_array_value = this.value;
234
232
  break;
235
233
  case ParameterType.PARAMETER_BYTE_ARRAY:
236
234
  msg.byte_array_value = this.value.map((val) => Math.trunc(val));
@@ -773,6 +771,7 @@ function validValue(value, type) {
773
771
  case ParameterType.PARAMETER_BYTE_ARRAY:
774
772
  case ParameterType.PARAMETER_INTEGER_ARRAY:
775
773
  case ParameterType.PARAMETER_DOUBLE_ARRAY:
774
+ case ParameterType.PARAMETER_STRING_ARRAY:
776
775
  const values = value;
777
776
  result = _validArray(values, type);
778
777
  break;
@@ -790,7 +789,7 @@ function _validArray(values, type) {
790
789
  if (type === ParameterType.PARAMETER_BOOL_ARRAY) {
791
790
  arrayElementType = ParameterType.PARAMETER_BOOL;
792
791
  } else if (type === ParameterType.PARAMETER_BYTE_ARRAY) {
793
- arrayElementType = ParameterType.PARAMETER_BYTE;
792
+ arrayElementType = ParameterType.PARAMETER_INTEGER;
794
793
  }
795
794
  if (type === ParameterType.PARAMETER_INTEGER_ARRAY) {
796
795
  arrayElementType = ParameterType.PARAMETER_INTEGER;
@@ -798,6 +797,9 @@ function _validArray(values, type) {
798
797
  if (type === ParameterType.PARAMETER_DOUBLE_ARRAY) {
799
798
  arrayElementType = ParameterType.PARAMETER_DOUBLE;
800
799
  }
800
+ if (type === ParameterType.PARAMETER_STRING_ARRAY) {
801
+ arrayElementType = ParameterType.PARAMETER_STRING;
802
+ }
801
803
 
802
804
  return values.reduce(
803
805
  (compatible, val) =>
@@ -813,7 +815,8 @@ function _isArrayParameterType(type) {
813
815
  type === ParameterType.PARAMETER_BOOL_ARRAY ||
814
816
  type === ParameterType.PARAMETER_BYTE_ARRAY ||
815
817
  type === ParameterType.PARAMETER_INTEGER_ARRAY ||
816
- type === ParameterType.PARAMETER_DOUBLE_ARRAY
818
+ type === ParameterType.PARAMETER_DOUBLE_ARRAY ||
819
+ type === ParameterType.PARAMETER_STRING_ARRAY
817
820
  );
818
821
  }
819
822
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rclnodejs",
3
- "version": "0.21.1",
3
+ "version": "0.21.2",
4
4
  "description": "ROS2.0 JavaScript client with Node.js",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -15,8 +15,8 @@
15
15
  "scripts": {
16
16
  "install": "node-gyp rebuild",
17
17
  "docs": "cd docs && make",
18
- "test": "node ./scripts/compile_tests.js && node --expose-gc ./scripts/run_test.js && npm run dtslint",
19
- "dtslint": "node ./scripts/generate_tsd.js && dtslint test/types",
18
+ "test": "node --expose-gc ./scripts/run_test.js && npm run dtslint",
19
+ "dtslint": "node scripts/generate_tsd.js && dtslint test/types",
20
20
  "lint": "eslint --max-warnings=0 --ext js,ts index.js types scripts lib example rosidl_gen rosidl_parser test benchmark/rclnodejs && node ./scripts/cpplint.js",
21
21
  "postinstall": "node scripts/generate_messages.js",
22
22
  "format": "clang-format -i -style=file ./src/*.cpp ./src/*.hpp && prettier --write \"{lib,rosidl_gen,rostsd_gen,rosidl_parser,types,example,test,scripts,benchmark}/**/*.{js,md,ts}\" ./*.{js,md,ts}"
@@ -43,7 +43,6 @@
43
43
  "clang-format": "^1.4.0",
44
44
  "commander": "^6.0.0",
45
45
  "deep-equal": "^1.1.1",
46
- "dtslint": "^4.2.1",
47
46
  "eslint": "^7.5.0",
48
47
  "eslint-config-prettier": "^6.11.0",
49
48
  "eslint-plugin-prettier": "^3.1.4",
@@ -66,6 +65,7 @@
66
65
  "compare-versions": "^3.6.0",
67
66
  "debug": "^4.1.1",
68
67
  "dot": "^1.1.3",
68
+ "dtslint": "^4.2.1",
69
69
  "fs-extra": "^10.0.0",
70
70
  "int64-napi": "^1.0.2",
71
71
  "is-close": "^1.3.3",
@@ -18,7 +18,7 @@ rclnodejs.init().then(() => {
18
18
 
19
19
  **Node.js**
20
20
 
21
- - [Node.js](https://nodejs.org/en/) version between 10.23 - 16.x.
21
+ - [Node.js](https://nodejs.org/en/) version between 10.23 - 17.x.
22
22
 
23
23
  **ROS 2 SDK**
24
24
 
@@ -43,10 +43,10 @@ npm i rclnodejs@x.y.z
43
43
 
44
44
  #### RCLNODEJS - ROS 2 Version Compatibility
45
45
 
46
- | RCLNODEJS Version | Compatible ROS 2 Release |
47
- | :-------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
48
- | [0.21.1 (current)](https://www.npmjs.com/package/rclnodejs/v/0.21.1) ([API](http://robotwebtools.org/rclnodejs/docs/0.21.0/index.html)) | [Galactic Geochelone](https://github.com/ros2/ros2/releases/tag/release-galactic-20210716) / [Foxy Fitzroy](https://github.com/ros2/ros2/releases/tag/release-foxy-20201211) / [Eloquent Elusor](https://github.com/ros2/ros2/releases/tag/release-eloquent-20200124) |
49
- | [0.10.3](https://github.com/RobotWebTools/rclnodejs/releases/tag/0.10.3) | [Dashing Diademata - Patch 4](https://github.com/ros2/ros2/releases/tag/release-dashing-20191018) |
46
+ | RCLNODEJS Version | Compatible ROS 2 Release |
47
+ | :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
48
+ | [0.21.2 (current)](https://www.npmjs.com/package/rclnodejs/v/0.21.2) ([API](http://robotwebtools.org/rclnodejs/docs/0.21.0/index.html)) | [Humble Hawksbill](https://github.com/ros2/ros2/releases/tag/release-humble-20220523)<br>[Galactic Geochelone](https://github.com/ros2/ros2/releases/tag/release-galactic-20210716)<br>[Foxy Fitzroy](https://github.com/ros2/ros2/releases/tag/release-foxy-20201211)<br>[Eloquent Elusor](https://github.com/ros2/ros2/releases/tag/release-eloquent-20200124) |
49
+ | [0.10.3](https://github.com/RobotWebTools/rclnodejs/releases/tag/0.10.3) | [Dashing Diademata - Patch 4](https://github.com/ros2/ros2/releases/tag/release-dashing-20191018) |
50
50
 
51
51
  ## Documentation
52
52
 
@@ -1,24 +1,22 @@
1
1
  'use strict';
2
2
 
3
- switch (process.env.ROS_DISTRO) {
4
- case 'eloquent':
5
- console.log('1911');
6
- process.exit(0);
7
- case 'foxy':
8
- console.log('2006');
9
- process.exit(0);
10
- case 'galactic':
11
- case 'rolling':
12
- console.log('2105');
13
- process.exit(0);
14
- case undefined:
15
- console.error(
16
- 'Unable to detect ROS, please make sure a supported version of ROS is sourced'
17
- );
18
- process.exit(1);
19
- default:
20
- console.error(
21
- `Unknown or unsupported ROS version "${process.env.ROS_DISTRO}"`
22
- );
23
- process.exit(1);
3
+ const DistroUtils = require('../lib/distro');
4
+
5
+ const distroName = DistroUtils.getDistroName();
6
+ const distroId = DistroUtils.getDistroId(distroName);
7
+
8
+ if (!distroName) {
9
+ console.error(
10
+ `Unable to detect ROS, please make sure a supported version of ROS is sourced.`
11
+ );
12
+ process.exit(1);
24
13
  }
14
+
15
+ if (distroId === DistroUtils.UNKNOWN_ID) {
16
+ console.error(`Unknown or unsupported ROS version "${distroName}"`);
17
+ process.exit(1);
18
+ }
19
+
20
+ // otherwise
21
+ console.log(distroId);
22
+ process.exit(0);
@@ -831,24 +831,21 @@ NAN_METHOD(RclTakeResponse) {
831
831
  RclHandle::Unwrap<RclHandle>(
832
832
  Nan::To<v8::Object>(info[0]).ToLocalChecked())
833
833
  ->ptr());
834
- int64_t sequence_number = Nan::To<int64_t>(info[1]).FromJust();
835
834
 
836
- rmw_request_id_t* header =
837
- reinterpret_cast<rmw_request_id_t*>(malloc(sizeof(rmw_request_id_t)));
838
- header->sequence_number = sequence_number;
835
+ rmw_service_info_t header;
839
836
 
840
837
  void* taken_response =
841
- node::Buffer::Data(Nan::To<v8::Object>(info[2]).ToLocalChecked());
842
- rcl_ret_t ret = rcl_take_response(client, header, taken_response);
843
- free(header);
838
+ node::Buffer::Data(Nan::To<v8::Object>(info[1]).ToLocalChecked());
839
+ rcl_ret_t ret = rcl_take_response_with_info(client, &header, taken_response);
840
+ int64_t sequence_number = header.request_id.sequence_number;
844
841
 
845
842
  if (ret == RCL_RET_OK) {
846
- info.GetReturnValue().Set(Nan::True());
843
+ info.GetReturnValue().Set(Nan::New((uint32_t)sequence_number));
847
844
  return;
848
845
  }
849
846
 
850
847
  rcl_reset_error();
851
- info.GetReturnValue().Set(Nan::False());
848
+ info.GetReturnValue().Set(Nan::Undefined());
852
849
  }
853
850
 
854
851
  NAN_METHOD(CreateService) {
package/types/base.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  /// <reference path="clock_type.d.ts" />
6
6
  /// <reference path="clock.d.ts" />
7
7
  /// <reference path="context.d.ts" />
8
+ /// <reference path="distro.d.ts" />
8
9
  /// <reference path="duration.d.ts" />
9
10
  /// <reference path="entity.d.ts" />
10
11
  /// <reference path="guard_condition.d.ts" />
@@ -0,0 +1,34 @@
1
+ declare module 'rclnodejs' {
2
+ namespace DistroUtils {
3
+ /**
4
+ * Valid ROS 2 distro short names
5
+ */
6
+ type DistroName = 'eloquent' | 'foxy' | 'galactic' | 'humble' | 'rolling';
7
+
8
+ /**
9
+ * rclnodejs distro ID numbers
10
+ */
11
+ enum DistroId {
12
+ UNKNOWN = 0,
13
+ ELOQUENT = 1911,
14
+ FOXY = 2006,
15
+ GALACTIC = 2105,
16
+ HUMBLE = 2205,
17
+ ROLLING = 5000,
18
+ }
19
+
20
+ /**
21
+ * Get the rclnodejs distro ID for a ROS 2 distro name.
22
+ * @param distroName - The ROS 2 short distro name, e.g., foxy, Defaults to the value of the ROS_DISTRO envar.
23
+ * @return The rclnodejs distro identifier
24
+ */
25
+ function getDistroId(distroName?: DistroName): DistroId;
26
+
27
+ /**
28
+ * Get the short ROS 2 distro name associated with a rclnodejs distro ID.
29
+ * @param distroId - The rclnodejs distro identifier. Defaults to the value of the ROS_DISTRO envar.
30
+ * @returns The name of the ROS distribution or undefined if unable to identify the distro.
31
+ */
32
+ function getDistroName(distroId?: DistroId): string | undefined;
33
+ }
34
+ }
@@ -1,15 +0,0 @@
1
- {
2
- "configurations": [
3
- {
4
- "name": "Linux",
5
- "includePath": [
6
- "${default}"
7
- ],
8
- "compilerPath": "/usr/bin/clang-10",
9
- "cStandard": "c11",
10
- "cppStandard": "c++14",
11
- "intelliSenseMode": "linux-clang-x64"
12
- }
13
- ],
14
- "version": 4
15
- }
@@ -1,124 +0,0 @@
1
- // Copyright (c) 2017 Intel Corporation. All rights reserved.
2
-
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
-
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
-
15
- 'use strict';
16
-
17
- /* eslint-disable */
18
- const fs = require('fs-extra');
19
- const os = require('os');
20
- const path = require('path');
21
- const child = require('child_process');
22
-
23
- var rootDir = path.dirname(__dirname);
24
- var testCppDir = path.join(rootDir, 'test', 'cpp');
25
-
26
- function getExecutable(input) {
27
- if (os.platform() === 'win32') return input + '.exe';
28
-
29
- return input;
30
- }
31
-
32
- var publisher = getExecutable('publisher_msg');
33
- var subscription = getExecutable('subscription_msg');
34
- var listener = getExecutable('listener');
35
- var client = getExecutable('add_two_ints_client');
36
-
37
- function getExecutablePath(input) {
38
- var releaseDir = '';
39
- if (os.platform() === 'win32') releaseDir = 'Release';
40
-
41
- return path.join(rootDir, 'build', 'cpp_nodes', releaseDir, input);
42
- }
43
-
44
- var publisherPath = getExecutablePath(publisher);
45
- var subscriptionPath = getExecutablePath(subscription);
46
- var listenerPath = getExecutablePath(listener);
47
- var clientPath = getExecutablePath(client);
48
-
49
- function copyFile(platform, srcFile, destFile) {
50
- if (!fs.existsSync(destFile)) {
51
- if (os.platform() === 'win32') {
52
- child.spawn('cmd.exe', ['/c', `copy ${srcFile} ${destFile}`]);
53
- } else {
54
- child.spawn('sh', ['-c', `cp ${srcFile} ${destFile}`]);
55
- }
56
- }
57
- }
58
-
59
- function copyAll(fileList, dest) {
60
- fileList.forEach((file) => {
61
- copyFile(os.platform(), file, path.join(dest, path.basename(file)));
62
- console.log(`cpp executables ${file} is copied to test/cpp.`);
63
- });
64
- }
65
-
66
- function copyPkgToRos2(pkgName) {
67
- let srcDir = path.join(rootDir, 'install', pkgName);
68
- let destDir = process.env.COLCON_PREFIX_PATH;
69
- if (os.platform() === 'win32') {
70
- child.spawn('cmd.exe', ['/c', `xcopy ${srcDir} ${destDir} /O /X /E /K`]);
71
- } else {
72
- child.spawn('sh', ['-c ', '"' + `cp -fr ${srcDir}/. ${destDir}` + '"'], {
73
- shell: true,
74
- });
75
- }
76
- }
77
-
78
- var subProcess = child.spawn('colcon', [
79
- 'build',
80
- '--event-handlers',
81
- 'console_cohesion+',
82
- '--base-paths',
83
- path.join(rootDir, 'test', 'rclnodejs_test_msgs'),
84
- ]);
85
- subProcess.on('close', (code) => {
86
- copyPkgToRos2('rclnodejs_test_msgs');
87
- });
88
- subProcess.stdout.on('data', (data) => {
89
- console.log(`${data}`);
90
- });
91
- subProcess.stderr.on('data', (data) => {
92
- console.log(`${data}`);
93
- });
94
-
95
- if (
96
- !fs.existsSync(publisherPath) &&
97
- !fs.existsSync(subscriptionPath) &&
98
- !fs.existsSync(listenerPath) &&
99
- !fs.existsSync(clientPath)
100
- ) {
101
- var compileProcess = child.spawn('colcon', [
102
- 'build',
103
- '--base-paths',
104
- testCppDir,
105
- ]);
106
- compileProcess.on('close', (code) => {
107
- copyAll(
108
- [publisherPath, subscriptionPath, listenerPath, clientPath],
109
- testCppDir
110
- );
111
- });
112
- compileProcess.stdout.on('data', (data) => {
113
- console.log(`${data}`);
114
- });
115
- compileProcess.stderr.on('data', (data) => {
116
- console.log(`${data}`);
117
- });
118
- } else {
119
- copyAll(
120
- [publisherPath, subscriptionPath, , listenerPath, clientPath],
121
- testCppDir
122
- );
123
- }
124
- /* eslint-enable */