rclnodejs 0.21.0 → 0.21.3

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.
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;
@@ -114,7 +114,7 @@ let interfaceLoader = {
114
114
  }
115
115
  }
116
116
  throw new Error(
117
- `The message required does not exist: ${packageName}, ${type}, ${messageName}`
117
+ `The message required does not exist: ${packageName}, ${type}, ${messageName} at ${generator.generatedRoot}`
118
118
  );
119
119
  },
120
120
  };
package/lib/node.js CHANGED
@@ -102,7 +102,7 @@ class Node extends rclnodejs.ShadowNode {
102
102
  this._parameterEventPublisher = null;
103
103
  this._setParametersCallbacks = [];
104
104
  this._logger = new Logging(rclnodejs.getNodeLoggerName(this.handle));
105
- this.spinning = false;
105
+ this._spinning = false;
106
106
 
107
107
  this._parameterEventPublisher = this.createPublisher(
108
108
  PARAMETER_EVENT_MSG_TYPE,
@@ -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
  );
@@ -375,6 +374,14 @@ class Node extends rclnodejs.ShadowNode {
375
374
  });
376
375
  }
377
376
 
377
+ /**
378
+ * Determine if this node is spinning.
379
+ * @returns {boolean} - true when spinning; otherwise returns false.
380
+ */
381
+ get spinning() {
382
+ return this._spinning;
383
+ }
384
+
378
385
  /**
379
386
  * Trigger the event loop to continuously check for and route.
380
387
  * incoming events.
@@ -388,7 +395,7 @@ class Node extends rclnodejs.ShadowNode {
388
395
  throw new Error('The node is already spinning.');
389
396
  }
390
397
  this.start(this.context.handle, timeout);
391
- this.spinning = true;
398
+ this._spinning = true;
392
399
  }
393
400
 
394
401
  /**
@@ -401,21 +408,21 @@ class Node extends rclnodejs.ShadowNode {
401
408
 
402
409
  /**
403
410
  * Terminate spinning - no further events will be received.
404
- * @returns {undfined}
411
+ * @returns {undefined}
405
412
  */
406
413
  stop() {
407
414
  super.stop();
408
- this.spinning = false;
415
+ this._spinning = false;
409
416
  }
410
417
 
411
418
  /**
412
419
  * Terminate spinning - no further events will be received.
413
- * @returns {undfined}
420
+ * @returns {undefined}
414
421
  * @deprecated since 0.18.0, Use stop().
415
422
  */
416
423
  stopSpinning() {
417
424
  super.stop();
418
- this.spinning = false;
425
+ this._spinning = false;
419
426
  }
420
427
 
421
428
  /**
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.0",
3
+ "version": "0.21.3",
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.0 (current)](https://www.npmjs.com/package/rclnodejs/v/0.21.0) ([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.3 (current)](https://www.npmjs.com/package/rclnodejs/v/0.21.3) ([API](http://robotwebtools.org/rclnodejs/docs/0.21.3/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) {
@@ -1330,6 +1327,7 @@ NAN_METHOD(CreateArrayBufferFromAddress) {
1330
1327
  memcpy(backing->Data(), addr, length);
1331
1328
  auto array_buffer =
1332
1329
  v8::ArrayBuffer::New(v8::Isolate::GetCurrent(), std::move(backing));
1330
+ free(addr);
1333
1331
  #endif
1334
1332
 
1335
1333
  info.GetReturnValue().Set(array_buffer);
@@ -77,12 +77,16 @@ declare module 'rclnodejs' {
77
77
 
78
78
  type ExecuteCallback<T extends TypeClass<ActionTypeClassName>> = (
79
79
  goalHandle: ServerGoalHandle<T>
80
- ) => ActionResult<T>;
81
- type GoalCallback = () => GoalResponse;
80
+ ) => Promise<ActionResult<T>> | ActionResult<T>;
81
+ type GoalCallback<T extends TypeClass<ActionTypeClassName>> = (
82
+ goalHandle: ServerGoalHandle<T>
83
+ ) => GoalResponse;
82
84
  type HandleAcceptedCallback<T extends TypeClass<ActionTypeClassName>> = (
83
85
  goalHandle: ServerGoalHandle<T>
84
86
  ) => void;
85
- type CancelCallback = () => CancelResponse;
87
+ type CancelCallback<T extends TypeClass<ActionTypeClassName>> = (
88
+ goalHandle?: ServerGoalHandle<T>
89
+ ) => Promise<CancelResponse> | CancelResponse;
86
90
 
87
91
  interface ActionServerOptions extends Options<ActionQoS> {
88
92
  /**
@@ -112,9 +116,9 @@ declare module 'rclnodejs' {
112
116
  typeClass: T,
113
117
  actionName: string,
114
118
  executeCallback: ExecuteCallback<T>,
115
- goalCallback?: GoalCallback,
119
+ goalCallback?: GoalCallback<T>,
116
120
  handleAcceptedCallback?: HandleAcceptedCallback<T>,
117
- cancelCallback?: CancelCallback,
121
+ cancelCallback?: CancelCallback<T>,
118
122
  options?: ActionServerOptions
119
123
  );
120
124
 
@@ -144,21 +148,21 @@ declare module 'rclnodejs' {
144
148
  *
145
149
  * @param goalCallback - Callback function, if not provided, then unregisters any previously registered callback.
146
150
  */
147
- registerGoalCallback(goalCallback?: GoalCallback): void;
151
+ registerGoalCallback(goalCallback?: GoalCallback<T>): void;
148
152
 
149
153
  /**
150
154
  * Register a callback for handling cancel requests.
151
155
  *
152
156
  * The purpose of the cancel callback is to decide if a request to cancel an on-going
153
157
  * (or queued) goal should be accepted or rejected.
154
- * The callback should take one parameter containing the cancel request and must return a
158
+ * The callback should take one parameter containing the cancel request ( a GoalHandle) and must return a
155
159
  * {@link CancelResponse} value.
156
160
  *
157
161
  * There can only be one cancel callback per {@link ActionServer}, therefore calling this
158
162
  * function will replace any previously registered callback.
159
163
  * @param cancelCallback - Callback function, if not provided, then unregisters any previously registered callback.
160
164
  */
161
- registerCancelCallback(cancelCallback?: CancelCallback): void;
165
+ registerCancelCallback(cancelCallback?: CancelCallback<T>): void;
162
166
 
163
167
  /**
164
168
  * Register a callback for executing action goals.
@@ -0,0 +1,58 @@
1
+ declare module 'rclnodejs' {
2
+ /**
3
+ * @class - Represents a unique identifier used by actions.
4
+ * @ignore
5
+ */
6
+
7
+ export class ActionUuid {
8
+ /**
9
+ * Creates a new instance of ActionUuid.
10
+ * @param bytes - The bytes to create the UUID from.
11
+ * A new random UUID will be created, if not provided.
12
+ */
13
+ constructor(bytes?: Uint8Array);
14
+
15
+ /**
16
+ * Creates a new {@link ActionUuid} from the given bytes.
17
+ * @param bytes - The bytes to create the UUID from.
18
+ * @returns The new UUID.
19
+ */
20
+ static fromBytes(byte: Uint8Array): ActionUuid;
21
+
22
+ /**
23
+ * Creates a new random {@link ActionUuid}.
24
+ * @returns The new UUID.
25
+ */
26
+ static random(): ActionUuid;
27
+
28
+ /**
29
+ * Gets the bytes from the UUID.
30
+ */
31
+ get bytes(): Uint8Array;
32
+
33
+ /**
34
+ * Returns the UUID as a string.
35
+ * @returns String representation of the UUID.
36
+ */
37
+ toString(): string;
38
+
39
+ /**
40
+ * Create an instance from a ROS2 UUID message
41
+ * @param msg - The ROS2 UUID message
42
+ * @returns The new instance.
43
+ */
44
+ static fromMessage(msg: unique_identifier_msgs.msg.UUID): ActionUuid;
45
+
46
+ /**
47
+ * Create a ROS2 UUID message from this instance.
48
+ * @returns The new ROS2 UUID message
49
+ */
50
+ toMessage(): unique_identifier_msgs.msg.UUID;
51
+
52
+ /**
53
+ * Create a ROS2 UUID message with random uuid data
54
+ * @returns The new instance.
55
+ */
56
+ static randomMessage(): unique_identifier_msgs.msg.UUID;
57
+ }
58
+ }
package/types/base.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  /* eslint-disable spaced-comment */
2
2
  /// <reference path="action_client.d.ts" />
3
3
  /// <reference path="action_server.d.ts" />
4
+ /// <reference path="action_uuid.d.ts" />
4
5
  /// <reference path="client.d.ts" />
5
6
  /// <reference path="clock_type.d.ts" />
6
7
  /// <reference path="clock.d.ts" />
7
8
  /// <reference path="context.d.ts" />
9
+ /// <reference path="distro.d.ts" />
8
10
  /// <reference path="duration.d.ts" />
9
11
  /// <reference path="entity.d.ts" />
10
12
  /// <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
+ }
package/types/node.d.ts CHANGED
@@ -182,6 +182,13 @@ declare module 'rclnodejs' {
182
182
  */
183
183
  options(): NodeOptions;
184
184
 
185
+ /**
186
+ * Determine if this node is spinning.
187
+ *
188
+ * @returns true when spinning; otherwise returns false.
189
+ */
190
+ get spinning(): boolean;
191
+
185
192
  /**
186
193
  * Trigger the event loop to continuously check for and route.
187
194
  * incoming events.
@@ -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
- }