rclnodejs 1.9.0-alpha.0 → 2.0.0-beta.0

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.
Files changed (108) hide show
  1. package/.prettierignore +4 -0
  2. package/README.md +2 -2
  3. package/binding.gyp +6 -5
  4. package/index.js +10 -0
  5. package/lib/action/client.js +5 -4
  6. package/lib/action/server_goal_handle.js +26 -1
  7. package/lib/action/uuid.js +1 -1
  8. package/lib/client.js +0 -45
  9. package/lib/distro.js +11 -4
  10. package/lib/interface_loader.js +1 -1
  11. package/lib/message_introspector.js +1 -29
  12. package/lib/message_serialization.js +2 -2
  13. package/lib/native_loader.js +21 -9
  14. package/lib/node.js +209 -12
  15. package/lib/parameter_event_handler.js +98 -0
  16. package/lib/prebuilds.js +47 -0
  17. package/lib/qos_overriding_options.js +358 -0
  18. package/lib/rmw.js +6 -1
  19. package/lib/subscription.js +2 -2
  20. package/lib/timer.js +1 -1
  21. package/package.json +11 -6
  22. package/prebuilds/linux-arm64/humble-jammy-arm64-electron-rclnodejs.node +0 -0
  23. package/prebuilds/linux-arm64/humble-jammy-arm64-node-rclnodejs.node +0 -0
  24. package/prebuilds/linux-arm64/jazzy-noble-arm64-electron-rclnodejs.node +0 -0
  25. package/prebuilds/linux-arm64/jazzy-noble-arm64-node-rclnodejs.node +0 -0
  26. package/prebuilds/linux-arm64/kilted-noble-arm64-electron-rclnodejs.node +0 -0
  27. package/prebuilds/linux-arm64/kilted-noble-arm64-node-rclnodejs.node +0 -0
  28. package/prebuilds/linux-arm64/lyrical-resolute-arm64-electron-rclnodejs.node +0 -0
  29. package/prebuilds/linux-arm64/lyrical-resolute-arm64-node-rclnodejs.node +0 -0
  30. package/prebuilds/linux-x64/humble-jammy-x64-electron-rclnodejs.node +0 -0
  31. package/prebuilds/linux-x64/humble-jammy-x64-node-rclnodejs.node +0 -0
  32. package/prebuilds/linux-x64/jazzy-noble-x64-electron-rclnodejs.node +0 -0
  33. package/prebuilds/linux-x64/jazzy-noble-x64-node-rclnodejs.node +0 -0
  34. package/prebuilds/linux-x64/kilted-noble-x64-electron-rclnodejs.node +0 -0
  35. package/prebuilds/linux-x64/kilted-noble-x64-node-rclnodejs.node +0 -0
  36. package/prebuilds/linux-x64/lyrical-resolute-x64-electron-rclnodejs.node +0 -0
  37. package/prebuilds/linux-x64/lyrical-resolute-x64-node-rclnodejs.node +0 -0
  38. package/rosidl_gen/packages.js +4 -4
  39. package/rosidl_gen/templates/message-template.js +20 -6
  40. package/rosocket/README.md +152 -0
  41. package/rosocket/cli.js +168 -0
  42. package/rosocket/index.js +245 -0
  43. package/scripts/install.js +14 -3
  44. package/scripts/tag_prebuilds.js +26 -9
  45. package/src/rcl_action_client_bindings.cpp +4 -4
  46. package/src/rcl_graph_bindings.cpp +8 -8
  47. package/src/rcl_lifecycle_bindings.cpp +1 -1
  48. package/src/rcl_subscription_bindings.cpp +2 -2
  49. package/src/rcl_timer_bindings.cpp +21 -2
  50. package/src/rcl_utilities.cpp +4 -4
  51. package/src/rcl_utilities.h +2 -2
  52. package/types/distro.d.ts +15 -1
  53. package/types/node.d.ts +69 -5
  54. package/types/parameter_event_handler.d.ts +11 -0
  55. package/types/qos.d.ts +55 -0
  56. package/types/timer.d.ts +3 -2
  57. package/prebuilds/linux-arm64/humble-jammy-arm64-rclnodejs.node +0 -0
  58. package/prebuilds/linux-arm64/jazzy-noble-arm64-rclnodejs.node +0 -0
  59. package/prebuilds/linux-arm64/kilted-noble-arm64-rclnodejs.node +0 -0
  60. package/prebuilds/linux-x64/humble-jammy-x64-rclnodejs.node +0 -0
  61. package/prebuilds/linux-x64/jazzy-noble-x64-rclnodejs.node +0 -0
  62. package/prebuilds/linux-x64/kilted-noble-x64-rclnodejs.node +0 -0
  63. package/tools/jsdoc/Makefile +0 -5
  64. package/tools/jsdoc/README.md +0 -96
  65. package/tools/jsdoc/build-index.js +0 -610
  66. package/tools/jsdoc/publish.js +0 -854
  67. package/tools/jsdoc/regenerate-published-docs.js +0 -605
  68. package/tools/jsdoc/static/fonts/OpenSans-Bold-webfont.eot +0 -0
  69. package/tools/jsdoc/static/fonts/OpenSans-Bold-webfont.svg +0 -1830
  70. package/tools/jsdoc/static/fonts/OpenSans-Bold-webfont.woff +0 -0
  71. package/tools/jsdoc/static/fonts/OpenSans-BoldItalic-webfont.eot +0 -0
  72. package/tools/jsdoc/static/fonts/OpenSans-BoldItalic-webfont.svg +0 -1830
  73. package/tools/jsdoc/static/fonts/OpenSans-BoldItalic-webfont.woff +0 -0
  74. package/tools/jsdoc/static/fonts/OpenSans-Italic-webfont.eot +0 -0
  75. package/tools/jsdoc/static/fonts/OpenSans-Italic-webfont.svg +0 -1830
  76. package/tools/jsdoc/static/fonts/OpenSans-Italic-webfont.woff +0 -0
  77. package/tools/jsdoc/static/fonts/OpenSans-Light-webfont.eot +0 -0
  78. package/tools/jsdoc/static/fonts/OpenSans-Light-webfont.svg +0 -1831
  79. package/tools/jsdoc/static/fonts/OpenSans-Light-webfont.woff +0 -0
  80. package/tools/jsdoc/static/fonts/OpenSans-LightItalic-webfont.eot +0 -0
  81. package/tools/jsdoc/static/fonts/OpenSans-LightItalic-webfont.svg +0 -1835
  82. package/tools/jsdoc/static/fonts/OpenSans-LightItalic-webfont.woff +0 -0
  83. package/tools/jsdoc/static/fonts/OpenSans-Regular-webfont.eot +0 -0
  84. package/tools/jsdoc/static/fonts/OpenSans-Regular-webfont.svg +0 -1831
  85. package/tools/jsdoc/static/fonts/OpenSans-Regular-webfont.woff +0 -0
  86. package/tools/jsdoc/static/scripts/linenumber.js +0 -25
  87. package/tools/jsdoc/static/scripts/prettify/Apache-License-2.0.txt +0 -202
  88. package/tools/jsdoc/static/scripts/prettify/lang-css.js +0 -36
  89. package/tools/jsdoc/static/scripts/prettify/prettify.js +0 -738
  90. package/tools/jsdoc/static/styles/jsdoc-default.css +0 -1012
  91. package/tools/jsdoc/static/styles/prettify-jsdoc.css +0 -111
  92. package/tools/jsdoc/static/styles/prettify-tomorrow.css +0 -132
  93. package/tools/jsdoc/tmpl/augments.tmpl +0 -10
  94. package/tools/jsdoc/tmpl/container.tmpl +0 -193
  95. package/tools/jsdoc/tmpl/details.tmpl +0 -143
  96. package/tools/jsdoc/tmpl/example.tmpl +0 -2
  97. package/tools/jsdoc/tmpl/examples.tmpl +0 -13
  98. package/tools/jsdoc/tmpl/exceptions.tmpl +0 -17
  99. package/tools/jsdoc/tmpl/layout.tmpl +0 -83
  100. package/tools/jsdoc/tmpl/mainpage.tmpl +0 -163
  101. package/tools/jsdoc/tmpl/members.tmpl +0 -43
  102. package/tools/jsdoc/tmpl/method.tmpl +0 -124
  103. package/tools/jsdoc/tmpl/params.tmpl +0 -133
  104. package/tools/jsdoc/tmpl/properties.tmpl +0 -110
  105. package/tools/jsdoc/tmpl/returns.tmpl +0 -12
  106. package/tools/jsdoc/tmpl/source.tmpl +0 -8
  107. package/tools/jsdoc/tmpl/tutorial.tmpl +0 -19
  108. package/tools/jsdoc/tmpl/type.tmpl +0 -7
@@ -0,0 +1,358 @@
1
+ // Copyright (c) 2026 The Robot Web Tools Contributors. 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
+ const QoS = require('./qos.js');
18
+ const {
19
+ Parameter,
20
+ ParameterType,
21
+ ParameterDescriptor,
22
+ } = require('./parameter.js');
23
+
24
+ /**
25
+ * Enum of overridable QoS policy kinds.
26
+ * Each value corresponds to a QoS property on the {@link QoS} class.
27
+ * @enum {number}
28
+ */
29
+ const QoSPolicyKind = Object.freeze({
30
+ HISTORY: 1,
31
+ DEPTH: 2,
32
+ RELIABILITY: 3,
33
+ DURABILITY: 4,
34
+ LIVELINESS: 5,
35
+ AVOID_ROS_NAMESPACE_CONVENTIONS: 6,
36
+ });
37
+
38
+ // Maps QoSPolicyKind -> { qosProp, paramKey, paramType, toParam, fromParam }
39
+ const POLICY_MAP = {
40
+ [QoSPolicyKind.HISTORY]: {
41
+ qosProp: 'history',
42
+ paramKey: 'history',
43
+ enumObj: QoS.HistoryPolicy,
44
+ paramType: ParameterType.PARAMETER_STRING,
45
+ toParam: (val, enumObj) => _enumToString(val, enumObj),
46
+ fromParam: (val, enumObj) => _stringToEnum(val, enumObj),
47
+ },
48
+ [QoSPolicyKind.DEPTH]: {
49
+ qosProp: 'depth',
50
+ paramKey: 'depth',
51
+ paramType: ParameterType.PARAMETER_INTEGER,
52
+ toParam: (val) => BigInt(val),
53
+ fromParam: (val) => Number(val),
54
+ },
55
+ [QoSPolicyKind.RELIABILITY]: {
56
+ qosProp: 'reliability',
57
+ paramKey: 'reliability',
58
+ enumObj: QoS.ReliabilityPolicy,
59
+ paramType: ParameterType.PARAMETER_STRING,
60
+ toParam: (val, enumObj) => _enumToString(val, enumObj),
61
+ fromParam: (val, enumObj) => _stringToEnum(val, enumObj),
62
+ },
63
+ [QoSPolicyKind.DURABILITY]: {
64
+ qosProp: 'durability',
65
+ paramKey: 'durability',
66
+ enumObj: QoS.DurabilityPolicy,
67
+ paramType: ParameterType.PARAMETER_STRING,
68
+ toParam: (val, enumObj) => _enumToString(val, enumObj),
69
+ fromParam: (val, enumObj) => _stringToEnum(val, enumObj),
70
+ },
71
+ [QoSPolicyKind.LIVELINESS]: {
72
+ qosProp: 'liveliness',
73
+ paramKey: 'liveliness',
74
+ enumObj: QoS.LivelinessPolicy,
75
+ paramType: ParameterType.PARAMETER_STRING,
76
+ toParam: (val, enumObj) => _enumToString(val, enumObj),
77
+ fromParam: (val, enumObj) => _stringToEnum(val, enumObj),
78
+ },
79
+ [QoSPolicyKind.AVOID_ROS_NAMESPACE_CONVENTIONS]: {
80
+ qosProp: 'avoidRosNameSpaceConventions',
81
+ paramKey: 'avoid_ros_namespace_conventions',
82
+ paramType: ParameterType.PARAMETER_BOOL,
83
+ toParam: (val) => val,
84
+ fromParam: (val) => Boolean(val),
85
+ },
86
+ };
87
+
88
+ /**
89
+ * Convert a numeric enum value to a lowercase string name.
90
+ * @param {number} val - enum numeric value
91
+ * @param {Object} enumObj - the enum object (e.g. QoS.HistoryPolicy)
92
+ * @returns {string}
93
+ */
94
+ function _enumToString(val, enumObj) {
95
+ for (const [key, v] of Object.entries(enumObj)) {
96
+ if (v === val) {
97
+ // Strip the RMW prefix: "RMW_QOS_POLICY_HISTORY_KEEP_LAST" -> "keep_last"
98
+ const parts = key.split('_');
99
+ // Find the index after the policy name (HISTORY, RELIABILITY, etc.)
100
+ // Pattern: RMW_QOS_POLICY_<POLICY>_<VALUE>
101
+ const policyNames = [
102
+ 'HISTORY',
103
+ 'RELIABILITY',
104
+ 'DURABILITY',
105
+ 'LIVELINESS',
106
+ ];
107
+ let valueStart = 4; // default: skip RMW_QOS_POLICY_<X>_
108
+ for (let i = 3; i < parts.length; i++) {
109
+ if (policyNames.includes(parts[i])) {
110
+ valueStart = i + 1;
111
+ break;
112
+ }
113
+ }
114
+ return parts.slice(valueStart).join('_').toLowerCase();
115
+ }
116
+ }
117
+ return String(val);
118
+ }
119
+
120
+ /**
121
+ * Convert a lowercase string back to a numeric enum value.
122
+ * @param {string} str - the string value (e.g. "keep_last")
123
+ * @param {Object} enumObj - the enum object
124
+ * @returns {number}
125
+ */
126
+ function _stringToEnum(str, enumObj) {
127
+ const upper = str.toUpperCase();
128
+ for (const [key, val] of Object.entries(enumObj)) {
129
+ if (key.endsWith('_' + upper)) {
130
+ return val;
131
+ }
132
+ }
133
+ throw new Error(`Unknown QoS policy value: "${str}"`);
134
+ }
135
+
136
+ /**
137
+ * Options for overriding QoS policies via ROS parameters.
138
+ *
139
+ * When passed to `createPublisher()` or `createSubscription()`, the node
140
+ * will declare read-only parameters for each specified policy kind. These
141
+ * parameters can be set via command-line arguments, launch files, or
142
+ * parameter files to override the QoS profile at startup.
143
+ *
144
+ * Parameter naming convention:
145
+ * `qos_overrides.<topic>.<publisher|subscription>[_<entityId>].<policy>`
146
+ *
147
+ * @example
148
+ * // Override history, depth, and reliability via parameters
149
+ * const sub = node.createSubscription(
150
+ * 'std_msgs/msg/String', '/chatter',
151
+ * { qos: rclnodejs.QoS.profileDefault,
152
+ * qosOverridingOptions: QoSOverridingOptions.withDefaultPolicies() },
153
+ * (msg) => console.log(msg.data)
154
+ * );
155
+ * // Now you can override via CLI:
156
+ * // --ros-args -p "qos_overrides./chatter.subscription.depth:=20"
157
+ */
158
+ class QoSOverridingOptions {
159
+ /**
160
+ * @param {Array<QoSPolicyKind>} policyKinds - Which QoS policies to expose as parameters.
161
+ * @param {Object} [opts]
162
+ * @param {function} [opts.callback] - Optional validation callback. Receives the
163
+ * final QoS profile after overrides are applied. Should return
164
+ * `{successful: true}` or `{successful: false, reason: '...'}`.
165
+ * @param {string} [opts.entityId] - Optional suffix to disambiguate multiple
166
+ * publishers/subscriptions on the same topic.
167
+ */
168
+ constructor(policyKinds, opts = {}) {
169
+ this._policyKinds = Array.from(policyKinds);
170
+ this._callback = opts.callback || null;
171
+ this._entityId = opts.entityId || null;
172
+ }
173
+
174
+ get policyKinds() {
175
+ return this._policyKinds;
176
+ }
177
+
178
+ get callback() {
179
+ return this._callback;
180
+ }
181
+
182
+ get entityId() {
183
+ return this._entityId;
184
+ }
185
+
186
+ /**
187
+ * Create options that override history, depth, and reliability —
188
+ * the most commonly tuned policies.
189
+ * @param {Object} [opts]
190
+ * @param {function} [opts.callback] - Validation callback.
191
+ * @param {string} [opts.entityId] - Entity disambiguation suffix.
192
+ * @returns {QoSOverridingOptions}
193
+ */
194
+ static withDefaultPolicies(opts = {}) {
195
+ return new QoSOverridingOptions(
196
+ [QoSPolicyKind.HISTORY, QoSPolicyKind.DEPTH, QoSPolicyKind.RELIABILITY],
197
+ opts
198
+ );
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Resolve QoS profile string to a mutable QoS object.
204
+ * If already a QoS instance, return as-is.
205
+ * @param {QoS|string} qos
206
+ * @returns {QoS}
207
+ */
208
+ function _resolveQoS(qos) {
209
+ if (qos instanceof QoS) {
210
+ return qos;
211
+ }
212
+ // Plain object with QoS fields — construct a QoS from its properties
213
+ if (typeof qos === 'object' && qos !== null && !Array.isArray(qos)) {
214
+ return new QoS(
215
+ qos.history,
216
+ qos.depth,
217
+ qos.reliability,
218
+ qos.durability,
219
+ qos.liveliness,
220
+ qos.avoidRosNameSpaceConventions
221
+ );
222
+ }
223
+ // Profile string: create a QoS with the corresponding defaults
224
+ // Values must match the rmw_qos_profile_* definitions in rmw/types.h
225
+ switch (qos) {
226
+ case QoS.profileDefault:
227
+ return new QoS(
228
+ QoS.HistoryPolicy.RMW_QOS_POLICY_HISTORY_KEEP_LAST,
229
+ 10,
230
+ QoS.ReliabilityPolicy.RMW_QOS_POLICY_RELIABILITY_RELIABLE,
231
+ QoS.DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_VOLATILE
232
+ );
233
+ case QoS.profileSystemDefault:
234
+ return new QoS(
235
+ QoS.HistoryPolicy.RMW_QOS_POLICY_HISTORY_SYSTEM_DEFAULT,
236
+ 0,
237
+ QoS.ReliabilityPolicy.RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT,
238
+ QoS.DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT,
239
+ QoS.LivelinessPolicy.RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT
240
+ );
241
+ case QoS.profileSensorData:
242
+ return new QoS(
243
+ QoS.HistoryPolicy.RMW_QOS_POLICY_HISTORY_KEEP_LAST,
244
+ 5,
245
+ QoS.ReliabilityPolicy.RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT,
246
+ QoS.DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_VOLATILE
247
+ );
248
+ case QoS.profileServicesDefault:
249
+ return new QoS(
250
+ QoS.HistoryPolicy.RMW_QOS_POLICY_HISTORY_KEEP_LAST,
251
+ 10,
252
+ QoS.ReliabilityPolicy.RMW_QOS_POLICY_RELIABILITY_RELIABLE,
253
+ QoS.DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_VOLATILE
254
+ );
255
+ case QoS.profileParameters:
256
+ return new QoS(
257
+ QoS.HistoryPolicy.RMW_QOS_POLICY_HISTORY_KEEP_LAST,
258
+ 1000,
259
+ QoS.ReliabilityPolicy.RMW_QOS_POLICY_RELIABILITY_RELIABLE,
260
+ QoS.DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_VOLATILE
261
+ );
262
+ case QoS.profileParameterEvents:
263
+ return new QoS(
264
+ QoS.HistoryPolicy.RMW_QOS_POLICY_HISTORY_KEEP_LAST,
265
+ 1000,
266
+ QoS.ReliabilityPolicy.RMW_QOS_POLICY_RELIABILITY_RELIABLE,
267
+ QoS.DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_VOLATILE
268
+ );
269
+ case QoS.profileActionStatusDefault:
270
+ return new QoS(
271
+ QoS.HistoryPolicy.RMW_QOS_POLICY_HISTORY_KEEP_LAST,
272
+ 1,
273
+ QoS.ReliabilityPolicy.RMW_QOS_POLICY_RELIABILITY_RELIABLE,
274
+ QoS.DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL
275
+ );
276
+ default:
277
+ return new QoS(
278
+ QoS.HistoryPolicy.RMW_QOS_POLICY_HISTORY_KEEP_LAST,
279
+ 10,
280
+ QoS.ReliabilityPolicy.RMW_QOS_POLICY_RELIABILITY_RELIABLE,
281
+ QoS.DurabilityPolicy.RMW_QOS_POLICY_DURABILITY_VOLATILE
282
+ );
283
+ }
284
+ }
285
+
286
+ /**
287
+ * Declare QoS override parameters on the node and apply any overrides
288
+ * to the QoS profile in-place.
289
+ *
290
+ * @param {'publisher'|'subscription'} entityType
291
+ * @param {Node} node
292
+ * @param {string} topic - Fully resolved topic name.
293
+ * @param {QoS} qos - Mutable QoS object (will be modified in-place).
294
+ * @param {QoSOverridingOptions} options
295
+ */
296
+ function declareQosParameters(entityType, node, topic, qos, options) {
297
+ if (!options || options.policyKinds.length === 0) {
298
+ return;
299
+ }
300
+
301
+ const idSuffix = options.entityId ? `_${options.entityId}` : '';
302
+ const namePrefix = `qos_overrides.${topic}.${entityType}${idSuffix}`;
303
+
304
+ for (const policyKind of options.policyKinds) {
305
+ const mapping = POLICY_MAP[policyKind];
306
+ if (!mapping) {
307
+ continue;
308
+ }
309
+
310
+ const paramName = `${namePrefix}.${mapping.paramKey}`;
311
+ const currentValue = qos[mapping.qosProp];
312
+ const paramValue = mapping.toParam(currentValue, mapping.enumObj);
313
+
314
+ const descriptor = new ParameterDescriptor(
315
+ paramName,
316
+ mapping.paramType,
317
+ `QoS override for ${mapping.qosProp}`,
318
+ true // readOnly
319
+ );
320
+
321
+ let param;
322
+ try {
323
+ param = node.declareParameter(
324
+ new Parameter(paramName, mapping.paramType, paramValue),
325
+ descriptor
326
+ );
327
+ } catch (e) {
328
+ // Already declared (e.g. multiple entities on same topic) — reuse
329
+ if (node.hasParameter(paramName)) {
330
+ param = node.getParameter(paramName);
331
+ } else {
332
+ throw e;
333
+ }
334
+ }
335
+
336
+ // Apply the (possibly overridden) parameter value back to QoS
337
+ if (param && param.value !== paramValue) {
338
+ qos[mapping.qosProp] = mapping.fromParam(param.value, mapping.enumObj);
339
+ }
340
+ }
341
+
342
+ // Run validation callback if provided
343
+ if (options.callback) {
344
+ const result = options.callback(qos);
345
+ if (result && !result.successful) {
346
+ throw new Error(
347
+ `QoS override validation failed: ${result.reason || 'unknown reason'}`
348
+ );
349
+ }
350
+ }
351
+ }
352
+
353
+ module.exports = {
354
+ QoSPolicyKind,
355
+ QoSOverridingOptions,
356
+ declareQosParameters,
357
+ _resolveQoS,
358
+ };
package/lib/rmw.js CHANGED
@@ -19,6 +19,7 @@ const RMWNames = {
19
19
  CONNEXT: 'rmw_connext_cpp',
20
20
  CYCLONEDDS: 'rmw_cyclonedds_cpp',
21
21
  GURUMDDS: 'rmw_gurumdds_cpp',
22
+ ZENOH: 'rmw_zenoh_cpp',
22
23
  };
23
24
 
24
25
  const DefaultRosRMWNameMap = new Map();
@@ -26,6 +27,9 @@ DefaultRosRMWNameMap.set('eloquent', RMWNames.FASTRTPS);
26
27
  DefaultRosRMWNameMap.set('foxy', RMWNames.FASTRTPS);
27
28
  DefaultRosRMWNameMap.set('galactic', RMWNames.CYCLONEDDS);
28
29
  DefaultRosRMWNameMap.set('humble', RMWNames.FASTRTPS);
30
+ DefaultRosRMWNameMap.set('iron', RMWNames.FASTRTPS);
31
+ DefaultRosRMWNameMap.set('jazzy', RMWNames.FASTRTPS);
32
+ DefaultRosRMWNameMap.set('kilted', RMWNames.FASTRTPS);
29
33
  DefaultRosRMWNameMap.set('rolling', RMWNames.FASTRTPS);
30
34
 
31
35
  const RMWUtils = {
@@ -34,7 +38,8 @@ const RMWUtils = {
34
38
  getRMWName: function () {
35
39
  return process.env.RMW_IMPLEMENTATION
36
40
  ? process.env.RMW_IMPLEMENTATION
37
- : DefaultRosRMWNameMap.get(DistroUtils.getDistroName());
41
+ : DefaultRosRMWNameMap.get(DistroUtils.getDistroName()) ||
42
+ RMWNames.FASTRTPS;
38
43
  },
39
44
  };
40
45
 
@@ -147,11 +147,11 @@ class Subscription extends Entity {
147
147
 
148
148
  /**
149
149
  * Check if content filtering is supported for this subscription.
150
- * Requires ROS 2 Rolling or later.
150
+ * Requires ROS 2 Lyrical or later.
151
151
  * @returns {boolean} True if the subscription instance supports content filtering; otherwise false.
152
152
  */
153
153
  isContentFilterSupported() {
154
- if (DistroUtils.getDistroId() < DistroUtils.DistroId.ROLLING) {
154
+ if (DistroUtils.getDistroId() < DistroUtils.DistroId.LYRICAL) {
155
155
  return false;
156
156
  }
157
157
  return rclnodejs.isContentFilterSupported(this.handle);
package/lib/timer.js CHANGED
@@ -150,7 +150,7 @@ class Timer {
150
150
 
151
151
  /**
152
152
  * Call a timer and starts counting again, retrieves actual and expected call time.
153
- * @return {object} - The timer information.
153
+ * @return {{expectedCallTime: bigint, actualCallTime: bigint}} - The timer information.
154
154
  */
155
155
  callTimerWithInfo() {
156
156
  if (DistroUtils.getDistroId() <= DistroUtils.getDistroId('humble')) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rclnodejs",
3
- "version": "1.9.0-alpha.0",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "ROS2.0 JavaScript client with Node.js",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -34,10 +34,14 @@
34
34
  "format": "clang-format -i -style=file ./src/*.cpp ./src/*.h && npx --yes prettier --write \"{lib,rosidl_gen,rostsd_gen,rosidl_parser,types,example,test,scripts,benchmark,rostsd_gen}/**/*.{js,md,ts}\" ./*.{js,md,ts}",
35
35
  "prepare": "husky",
36
36
  "coverage": "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
37
- "prebuild": "prebuildify --napi --strip --target 16.20.2 --target electron@23.0.0 && node scripts/tag_prebuilds.js"
37
+ "prebuild:node": "prebuildify --napi --strip --name node --target 20.20.2",
38
+ "prebuild:electron": "prebuildify --napi --strip --name electron --target electron@34.0.0",
39
+ "prebuild": "npm run prebuild:node && npm run prebuild:electron && node scripts/tag_prebuilds.js",
40
+ "rosocket": "node ./rosocket/cli.js"
38
41
  },
39
42
  "bin": {
40
- "generate-ros-messages": "./scripts/generate_messages.js"
43
+ "generate-ros-messages": "./scripts/generate_messages.js",
44
+ "rosocket": "./rosocket/cli.js"
41
45
  },
42
46
  "authors": [
43
47
  "Minggang Wang <minggangw@gmail.com>",
@@ -67,7 +71,7 @@
67
71
  "jsdoc": "^4.0.4",
68
72
  "lint-staged": "^16.2.0",
69
73
  "mocha": "^11.0.2",
70
- "node-gyp": "^12.1.0",
74
+ "node-gyp": "^12.2.0",
71
75
  "nyc": "^18.0.0",
72
76
  "prebuildify": "^6.0.1",
73
77
  "rimraf": "^6.0.1",
@@ -84,7 +88,8 @@
84
88
  "json-bigint": "^1.0.0",
85
89
  "node-addon-api": "^8.3.1",
86
90
  "rxjs": "^7.8.1",
87
- "walk": "^2.3.15"
91
+ "walk": "^2.3.15",
92
+ "ws": "^8.18.0"
88
93
  },
89
94
  "husky": {
90
95
  "hooks": {
@@ -103,6 +108,6 @@
103
108
  "directory": "test/types"
104
109
  },
105
110
  "engines": {
106
- "node": ">= 16.13.0"
111
+ "node": ">= 20.20.2"
107
112
  }
108
113
  }
@@ -29,7 +29,7 @@ const serviceMsgPath = path.join(generatedRoot, 'srv_msg');
29
29
 
30
30
  function getPackageName(filePath, amentExecuted) {
31
31
  if (os.type() === 'Windows_NT') {
32
- filePath = filePath.replace(/\\/g, '/');
32
+ filePath = filePath.replaceAll('\\', '/');
33
33
  }
34
34
 
35
35
  if (amentExecuted) {
@@ -41,14 +41,14 @@ function getPackageName(filePath, amentExecuted) {
41
41
 
42
42
  // If |packageName| equals to the file's extension, e.g. msg/srv, one level
43
43
  // up directory will be used as the package name.
44
- return packageName === path.parse(filePath).ext.substr(1)
44
+ return packageName === path.parse(filePath).ext.substring(1)
45
45
  ? folders.pop()
46
46
  : packageName;
47
47
  }
48
48
 
49
49
  function getSubFolder(filePath, amentExecuted) {
50
50
  if (os.type() === 'Windows_NT') {
51
- filePath = filePath.replace(/\\/g, '/');
51
+ filePath = filePath.replaceAll('\\', '/');
52
52
  }
53
53
 
54
54
  if (amentExecuted) {
@@ -61,7 +61,7 @@ function getSubFolder(filePath, amentExecuted) {
61
61
  }
62
62
  // If the |amentExecuted| equals to false, the file's extension will be assigned as
63
63
  // the name of sub folder.
64
- return path.parse(filePath).ext.substr(1);
64
+ return path.parse(filePath).ext.substring(1);
65
65
  }
66
66
 
67
67
  function grabInterfaceInfo(filePath, amentExecuted) {
@@ -156,15 +156,15 @@ const typedArrayType = [
156
156
  ];
157
157
 
158
158
  function isPrimitivePackage(baseType) {
159
- return primitiveBaseType.indexOf(baseType.type) !== -1;
159
+ return primitiveBaseType.includes(baseType.type);
160
160
  }
161
161
 
162
162
  function isTypedArrayType(type) {
163
- return typedArrayType.indexOf(type.type.toLowerCase()) !== -1;
163
+ return typedArrayType.includes(type.type.toLowerCase());
164
164
  }
165
165
 
166
166
  function isBigInt(type) {
167
- return ['int64', 'uint64'].indexOf(type.type.toLowerCase()) !== -1;
167
+ return ['int64', 'uint64'].includes(type.type.toLowerCase());
168
168
  }
169
169
 
170
170
  function getWrapperNameByType(type) {
@@ -265,6 +265,14 @@ function generateMessage(data) {
265
265
  const currentTypedArray = getTypedArrayName(spec.baseType);
266
266
  const currentTypedArrayElementType = getTypedArrayElementName(spec.baseType);
267
267
 
268
+ // ROS 2 Rolling (ros2/rosidl#941) added is_rosidl_buffer / owns_rosidl_buffer
269
+ // to every primitive sequence struct. Lyrical inherits the same ABI change.
270
+ // Emit the extra fields only for primitive-package types on Lyrical+.
271
+ const DistroUtils = require('../../lib/distro.js');
272
+ const needsRosidlBufferFields =
273
+ isPrimitivePackage(spec.baseType) &&
274
+ DistroUtils.getDistroId() >= DistroUtils.DistroId.LYRICAL;
275
+
268
276
  // Track required modules
269
277
  let existedModules = [];
270
278
  function shouldRequire(baseType, fieldType) {
@@ -275,7 +283,7 @@ function generateMessage(data) {
275
283
  !fieldType.isPrimitiveType ||
276
284
  fieldType.type === 'string');
277
285
 
278
- if (shouldReq && existedModules.indexOf(requiredModule) === -1) {
286
+ if (shouldReq && !existedModules.includes(requiredModule)) {
279
287
  existedModules.push(requiredModule);
280
288
  return true;
281
289
  } else {
@@ -347,7 +355,13 @@ ${
347
355
  : ` data: ${refArrayType},`
348
356
  }
349
357
  size: ref.types.size_t,
350
- capacity: ref.types.size_t
358
+ capacity: ref.types.size_t,
359
+ ${
360
+ needsRosidlBufferFields
361
+ ? ` is_rosidl_buffer: ref.types.bool,
362
+ owns_rosidl_buffer: ref.types.bool,`
363
+ : ''
364
+ }
351
365
  });
352
366
 
353
367
  ${generateWrapperClass()}
@@ -678,7 +692,7 @@ ${spec.fields
678
692
 
679
693
  hasMember(name) {
680
694
  let memberNames = ${extractMemberNames(spec.fields)};
681
- return memberNames.indexOf(name) !== -1;
695
+ return memberNames.includes(name);
682
696
  }
683
697
  }`;
684
698
  }