rclnodejs 1.1.0 → 1.3.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 (44) hide show
  1. package/README.md +4 -4
  2. package/binding.gyp +5 -0
  3. package/index.js +26 -3
  4. package/lib/context.js +4 -2
  5. package/lib/event_handler.js +474 -0
  6. package/lib/lifecycle.js +9 -0
  7. package/lib/lifecycle_publisher.js +2 -2
  8. package/lib/node.js +163 -28
  9. package/lib/publisher.js +31 -4
  10. package/lib/serialization.js +60 -0
  11. package/lib/subscription.js +48 -4
  12. package/lib/type_description_service.js +27 -1
  13. package/package.json +1 -1
  14. package/rosidl_gen/templates/message.dot +1 -1
  15. package/scripts/npmjs-readme.md +4 -4
  16. package/src/addon.cpp +4 -0
  17. package/src/executor.cpp +3 -4
  18. package/src/handle_manager.cpp +13 -2
  19. package/src/handle_manager.h +4 -1
  20. package/src/macros.h +17 -1
  21. package/src/rcl_action_client_bindings.cpp +3 -2
  22. package/src/rcl_action_goal_bindings.cpp +3 -2
  23. package/src/rcl_action_server_bindings.cpp +7 -5
  24. package/src/rcl_client_bindings.cpp +4 -3
  25. package/src/rcl_context_bindings.cpp +29 -19
  26. package/src/rcl_event_handle_bindings.cpp +294 -0
  27. package/src/rcl_event_handle_bindings.h +26 -0
  28. package/src/rcl_guard_condition_bindings.cpp +3 -2
  29. package/src/rcl_lifecycle_bindings.cpp +18 -4
  30. package/src/rcl_node_bindings.cpp +111 -3
  31. package/src/rcl_publisher_bindings.cpp +4 -3
  32. package/src/rcl_serialization_bindings.cpp +116 -0
  33. package/src/rcl_serialization_bindings.h +26 -0
  34. package/src/rcl_service_bindings.cpp +4 -3
  35. package/src/rcl_subscription_bindings.cpp +3 -2
  36. package/src/rcl_time_point_bindings.cpp +3 -2
  37. package/src/rcl_timer_bindings.cpp +8 -6
  38. package/src/rcl_utilities.cpp +31 -0
  39. package/src/rcl_utilities.h +7 -0
  40. package/tsconfig.json +2 -2
  41. package/types/context.d.ts +3 -2
  42. package/types/index.d.ts +26 -1
  43. package/types/lifecycle.d.ts +7 -0
  44. package/types/node.d.ts +60 -10
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # rclnodejs ![GitHub Workflow Status](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-build-and-test.yml/badge.svg?branch=jazzy)
1
+ # rclnodejs [![Linux](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-x64-build-and-test.yml/badge.svg?branch=develop)](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-x64-build-and-test.yml?query=branch%3Adevelop)[![Linux](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-arm64-build-and-test.yml/badge.svg?branch=develop)](https://github.com/RobotWebTools/rclnodejs/actions/workflows/linux-arm64-build-and-test.yml?query=branch%3Adevelop)
2
2
 
3
3
  `rclnodejs` is a Node.js client for the Robot Operating System (ROS 2). It provides a simple and easy JavaScript API for ROS 2 programming. TypeScript declarations are included to support use of rclnodejs in TypeScript projects.
4
4
 
@@ -22,8 +22,8 @@ rclnodejs.init().then(() => {
22
22
 
23
23
  **ROS 2 SDK**
24
24
 
25
- - See the ROS 2 SDK [Installation Guide](https://docs.ros.org/en/jazzy/Installation.html) for details.
26
- - **DON'T FORGET TO [SOURCE THE ROS 2 STARTUP FILES](https://docs.ros.org/en/jazzy/Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.html#source-the-setup-files)**
25
+ - See the ROS 2 SDK [Installation Guide](https://docs.ros.org/en/kilted/Installation.html) for details.
26
+ - **DON'T FORGET TO [SOURCE THE ROS 2 STARTUP FILES](https://docs.ros.org/en/kilted/Tutorials/Beginner-CLI-Tools/Configuring-ROS2-Environment.htmls)**
27
27
 
28
28
  ## Install rclnodejs
29
29
 
@@ -45,7 +45,7 @@ npm i rclnodejs@x.y.z
45
45
 
46
46
  | RCLNODEJS Version | Compatible ROS 2 LTS |
47
47
  | :----------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
48
- | latest version (currently [v1.1.0](https://github.com/RobotWebTools/rclnodejs/tree/1.1.0)) | [Kilted](https://github.com/RobotWebTools/rclnodejs/tree/kilted)<br>[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy)<br>[Humble](https://github.com/RobotWebTools/rclnodejs/tree/humble-hawksbill) |
48
+ | latest version (currently [v1.3.0](https://github.com/RobotWebTools/rclnodejs/tree/1.3.0)) | [Kilted](https://github.com/RobotWebTools/rclnodejs/tree/kilted)<br>[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy)<br>[Humble](https://github.com/RobotWebTools/rclnodejs/tree/humble-hawksbill) |
49
49
 
50
50
  ## Documentation
51
51
 
package/binding.gyp CHANGED
@@ -35,6 +35,7 @@
35
35
  './src/rcl_names_bindings.cpp',
36
36
  './src/rcl_node_bindings.cpp',
37
37
  './src/rcl_publisher_bindings.cpp',
38
+ './src/rcl_serialization_bindings.cpp',
38
39
  './src/rcl_service_bindings.cpp',
39
40
  './src/rcl_subscription_bindings.cpp',
40
41
  './src/rcl_time_point_bindings.cpp',
@@ -120,6 +121,9 @@
120
121
  'include_dirs': [
121
122
  './src/third_party/dlfcn-win32/',
122
123
  ],
124
+ 'libraries': [
125
+ '-lrmw_fastrtps_cpp',
126
+ ],
123
127
  'msvs_settings': {
124
128
  'VCCLCompilerTool': {
125
129
  'ExceptionHandling': '2', # /EHsc
@@ -170,6 +174,7 @@
170
174
  # After Humble, e.g., Jazzy, Kilted.
171
175
  'ros_version > 2205', {
172
176
  'sources': [
177
+ './src/rcl_event_handle_bindings.cpp',
173
178
  './src/rcl_type_description_service_bindings.cpp',
174
179
  ]
175
180
  }
package/index.js CHANGED
@@ -53,6 +53,10 @@ const {
53
53
  getActionNamesAndTypes,
54
54
  } = require('./lib/action/graph.js');
55
55
  const ServiceIntrospectionStates = require('./lib/service_introspection.js');
56
+ const {
57
+ serializeMessage,
58
+ deserializeMessage,
59
+ } = require('./lib/serialization.js');
56
60
 
57
61
  /**
58
62
  * Get the version of the generator that was used for the currently present interfaces.
@@ -183,12 +187,22 @@ let rcl = {
183
187
  /** {@link getActionNamesAndTypes} function */
184
188
  getActionNamesAndTypes: getActionNamesAndTypes,
185
189
 
190
+ /** {@link serializeMessage} function */
191
+ serializeMessage: serializeMessage,
192
+
193
+ /** {@link deserializeMessage} function */
194
+ deserializeMessage: deserializeMessage,
195
+
186
196
  /**
187
197
  * Create and initialize a node.
188
198
  * @param {string} nodeName - The name used to register in ROS.
189
199
  * @param {string} [namespace=''] - The namespace used in ROS.
190
200
  * @param {Context} [context=Context.defaultContext()] - The context to create the node in.
191
201
  * @param {NodeOptions} [options=NodeOptions.defaultOptions] - The options to configure the new node behavior.
202
+ * @param {Array} [args=[]] - The arguments to pass to the node.
203
+ * @param {boolean} [useGlobalArguments=true] - If true, the node will use the global arguments
204
+ * from the context, otherwise it will only use the arguments
205
+ * passed in the args parameter.
192
206
  * @return {Node} A new instance of the specified node.
193
207
  * @throws {Error} If the given context is not registered.
194
208
  * @deprecated since 0.18.0, Use new Node constructor.
@@ -197,9 +211,18 @@ let rcl = {
197
211
  nodeName,
198
212
  namespace = '',
199
213
  context = Context.defaultContext(),
200
- options = NodeOptions.defaultOptions
214
+ options = NodeOptions.defaultOptions,
215
+ args = [],
216
+ useGlobalArguments = true
201
217
  ) {
202
- return new this.Node(nodeName, namespace, context, options);
218
+ return new this.Node(
219
+ nodeName,
220
+ namespace,
221
+ context,
222
+ options,
223
+ args,
224
+ useGlobalArguments
225
+ );
203
226
  },
204
227
 
205
228
  /**
@@ -255,7 +278,7 @@ let rcl = {
255
278
  throw new TypeError('argv elements must be strings (and not null).');
256
279
  }
257
280
 
258
- rclnodejs.init(context.handle, argv);
281
+ rclnodejs.init(context.handle, argv, context._domainId);
259
282
 
260
283
  if (_rosVersionChecked) {
261
284
  // no further processing required
package/lib/context.js CHANGED
@@ -63,11 +63,13 @@ class Context {
63
63
  * Call rcl.init(context) to initialize this context state for
64
64
  * use in creating nodes, etc.
65
65
  * @constructor
66
+ * @param {bigint} - Optional, The domain ID of this context.
66
67
  */
67
- constructor() {
68
+ constructor(domainId) {
68
69
  this._handle = rclnodejs.createContext();
69
70
  this._isShutdown = false;
70
71
  this._nodes = [];
72
+ this._domainId = domainId;
71
73
  Context._instances.push(this);
72
74
  }
73
75
 
@@ -222,7 +224,7 @@ class Context {
222
224
 
223
225
  /**
224
226
  * Get the domain ID of this context.
225
- * @returns {Number} domain ID of this context
227
+ * @returns {bigint} domain ID of this context
226
228
  */
227
229
  get domainId() {
228
230
  return rclnodejs.getDomainId(this.handle);
@@ -0,0 +1,474 @@
1
+ // Copyright (c) 2025, The Robot Web Tools Contributors
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 rclnodejs = require('bindings')('rclnodejs');
18
+ const DistroUtils = require('./distro.js');
19
+ const Entity = require('./entity.js');
20
+
21
+ /**
22
+ * Enumeration for PublisherEventCallbacks event types.
23
+ * @enum {number}
24
+ */
25
+ const PublisherEventType = {
26
+ /** @member {number} */
27
+ PUBLISHER_OFFERED_DEADLINE_MISSED: 0,
28
+ /** @member {number} */
29
+ PUBLISHER_LIVELINESS_LOST: 1,
30
+ /** @member {number} */
31
+ PUBLISHER_OFFERED_INCOMPATIBLE_QOS: 2,
32
+ /** @member {number} */
33
+ PUBLISHER_INCOMPATIBLE_TYPE: 3,
34
+ /** @member {number} */
35
+ PUBLISHER_MATCHED: 4,
36
+ };
37
+
38
+ /**
39
+ * Enumeration for SubscriptionEventCallbacks event types.
40
+ * @enum {number}
41
+ */
42
+ const SubscriptionEventType = {
43
+ /** @member {number} */
44
+ SUBSCRIPTION_REQUESTED_DEADLINE_MISSED: 0,
45
+ /** @member {number} */
46
+ SUBSCRIPTION_LIVELINESS_CHANGED: 1,
47
+ /** @member {number} */
48
+ SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS: 2,
49
+ /** @member {number} */
50
+ SUBSCRIPTION_MESSAGE_LOST: 3,
51
+ /** @member {number} */
52
+ SUBSCRIPTION_INCOMPATIBLE_TYPE: 4,
53
+ /** @member {number} */
54
+ SUBSCRIPTION_MATCHED: 5,
55
+ };
56
+
57
+ class EventHandler extends Entity {
58
+ constructor(handle, callback, eventType, eventTypeName) {
59
+ super(handle, null, null);
60
+ this._callback = callback;
61
+ this._eventType = eventType;
62
+ this._eventTypeName = eventTypeName;
63
+ }
64
+
65
+ takeData() {
66
+ const data = rclnodejs.takeEvent(this._handle, {
67
+ [this._eventTypeName]: this._eventType,
68
+ });
69
+ if (this._callback) {
70
+ this._callback(data);
71
+ }
72
+ }
73
+ }
74
+
75
+ /**
76
+ * @class - Class representing a ROS 2 PublisherEventCallbacks
77
+ * @hideconstructor
78
+ */
79
+ class PublisherEventCallbacks {
80
+ constructor() {
81
+ if (DistroUtils.getDistroId() < DistroUtils.getDistroId('jazzy')) {
82
+ throw new Error(
83
+ 'PublisherEventCallbacks is only available in ROS 2 Jazzy and later.'
84
+ );
85
+ }
86
+ this._deadline = null;
87
+ this._incompatible_qos = null;
88
+ this._liveliness = null;
89
+ this._incompatible_type = null;
90
+ this._matched = null;
91
+ this._eventHandlers = [];
92
+ }
93
+
94
+ /**
95
+ * Set deadline missed callback.
96
+ * @param {function} callback - The callback function to be called.
97
+ */
98
+ set deadline(callback) {
99
+ this._deadline = callback;
100
+ }
101
+
102
+ /**
103
+ * Get deadline missed callback.
104
+ * @return {function} - The callback function.
105
+ */
106
+ get deadline() {
107
+ return this._deadline;
108
+ }
109
+
110
+ /**
111
+ * Set incompatible QoS callback.
112
+ * @param {function} callback - The callback function to be called.
113
+ */
114
+ set incompatibleQos(callback) {
115
+ this._incompatible_qos = callback;
116
+ }
117
+
118
+ /**
119
+ * Get incompatible QoS callback.
120
+ * @return {function} - The callback function.
121
+ */
122
+ get incompatibleQos() {
123
+ return this._incompatible_qos;
124
+ }
125
+
126
+ /**
127
+ * Set liveliness lost callback.
128
+ * @param {function} callback - The callback function to be called.
129
+ */
130
+ set liveliness(callback) {
131
+ this._liveliness = callback;
132
+ }
133
+
134
+ /**
135
+ * Get liveliness lost callback.
136
+ * @return {function} - The callback function.
137
+ */
138
+ get liveliness() {
139
+ return this._liveliness;
140
+ }
141
+
142
+ /**
143
+ * Set incompatible type callback.
144
+ * @param {function} callback - The callback function to be called.
145
+ */
146
+ set incompatibleType(callback) {
147
+ this._incompatible_type = callback;
148
+ }
149
+
150
+ /**
151
+ * Get incompatible type callback.
152
+ * @return {function} - The callback function.
153
+ */
154
+ get incompatibleType() {
155
+ return this._incompatible_type;
156
+ }
157
+
158
+ /**
159
+ * Set matched callback.
160
+ * @param {function} callback - The callback function to be called.
161
+ */
162
+ set matched(callback) {
163
+ this._matched = callback;
164
+ }
165
+
166
+ /**
167
+ * Get matched callback.
168
+ * @return {function} - The callback function.
169
+ */
170
+ get matched() {
171
+ return this._matched;
172
+ }
173
+
174
+ createEventHandlers(publisherHandle) {
175
+ if (this._deadline) {
176
+ const deadlineHandle = rclnodejs.createPublisherEventHandle(
177
+ publisherHandle,
178
+ PublisherEventType.PUBLISHER_OFFERED_DEADLINE_MISSED
179
+ );
180
+ this._eventHandlers.push(
181
+ new EventHandler(
182
+ deadlineHandle,
183
+ this._deadline,
184
+ PublisherEventType.PUBLISHER_OFFERED_DEADLINE_MISSED,
185
+ 'publisher_event_type'
186
+ )
187
+ );
188
+ }
189
+
190
+ if (this._incompatible_qos) {
191
+ const incompatibleQosHandle = rclnodejs.createPublisherEventHandle(
192
+ publisherHandle,
193
+ PublisherEventType.PUBLISHER_OFFERED_INCOMPATIBLE_QOS
194
+ );
195
+ this._eventHandlers.push(
196
+ new EventHandler(
197
+ incompatibleQosHandle,
198
+ this._incompatible_qos,
199
+ PublisherEventType.PUBLISHER_OFFERED_INCOMPATIBLE_QOS,
200
+ 'publisher_event_type'
201
+ )
202
+ );
203
+ }
204
+
205
+ if (this._liveliness) {
206
+ const livelinessHandle = rclnodejs.createPublisherEventHandle(
207
+ publisherHandle,
208
+ PublisherEventType.PUBLISHER_LIVELINESS_LOST
209
+ );
210
+ this._eventHandlers.push(
211
+ new EventHandler(
212
+ livelinessHandle,
213
+ this._liveliness,
214
+ PublisherEventType.PUBLISHER_LIVELINESS_LOST,
215
+ 'publisher_event_type'
216
+ )
217
+ );
218
+ }
219
+
220
+ if (this._incompatible_type) {
221
+ const incompatibleTypeHandle = rclnodejs.createPublisherEventHandle(
222
+ publisherHandle,
223
+ PublisherEventType.PUBLISHER_INCOMPATIBLE_TYPE
224
+ );
225
+ this._eventHandlers.push(
226
+ new EventHandler(
227
+ incompatibleTypeHandle,
228
+ this._incompatible_type,
229
+ PublisherEventType.PUBLISHER_INCOMPATIBLE_TYPE,
230
+ 'publisher_event_type'
231
+ )
232
+ );
233
+ }
234
+
235
+ if (this._matched) {
236
+ const matchedHandle = rclnodejs.createPublisherEventHandle(
237
+ publisherHandle,
238
+ PublisherEventType.PUBLISHER_MATCHED
239
+ );
240
+ this._eventHandlers.push(
241
+ new EventHandler(
242
+ matchedHandle,
243
+ this._matched,
244
+ PublisherEventType.PUBLISHER_MATCHED,
245
+ 'publisher_event_type'
246
+ )
247
+ );
248
+ }
249
+
250
+ return this._eventHandlers;
251
+ }
252
+
253
+ get eventHandlers() {
254
+ return this._eventHandlers;
255
+ }
256
+ }
257
+
258
+ /**
259
+ * @class - Class representing a ROS 2 SubscriptionEventCallbacks
260
+ * @hideconstructor
261
+ */
262
+ class SubscriptionEventCallbacks {
263
+ constructor() {
264
+ if (DistroUtils.getDistroId() < DistroUtils.getDistroId('jazzy')) {
265
+ throw new Error(
266
+ 'SubscriptionEventCallbacks is only available in ROS 2 Jazzy and later.'
267
+ );
268
+ }
269
+ this._deadline = null;
270
+ this._incompatible_qos = null;
271
+ this._liveliness = null;
272
+ this._message_lost = null;
273
+ this._incompatible_type = null;
274
+ this._matched = null;
275
+ this._eventHandlers = [];
276
+ }
277
+
278
+ /**
279
+ * Set the callback for deadline missed event.
280
+ * @param {function} callback - The callback function to be called.
281
+ */
282
+ set deadline(callback) {
283
+ this._deadline = callback;
284
+ }
285
+
286
+ /**
287
+ * Get the callback for deadline missed event.
288
+ * @return {function} - The callback function.
289
+ */
290
+ get deadline() {
291
+ return this._deadline;
292
+ }
293
+
294
+ /**
295
+ * Set the callback for incompatible QoS event.
296
+ * @param {function} callback - The callback function to be called.
297
+ */
298
+ set incompatibleQos(callback) {
299
+ this._incompatible_qos = callback;
300
+ }
301
+
302
+ /**
303
+ * Get the callback for incompatible QoS event.
304
+ * @return {function} - The callback function.
305
+ */
306
+ get incompatibleQos() {
307
+ return this._incompatible_qos;
308
+ }
309
+
310
+ /**
311
+ * Set the callback for liveliness changed event.
312
+ * @param {function} callback - The callback function to be called.
313
+ */
314
+ set liveliness(callback) {
315
+ this._liveliness = callback;
316
+ }
317
+
318
+ /**
319
+ * Get the callback for liveliness changed event.
320
+ * @return {function} - The callback function.
321
+ */
322
+ get liveliness() {
323
+ return this._liveliness;
324
+ }
325
+
326
+ /**
327
+ * Set the callback for message lost event.
328
+ * @param {function} callback - The callback function to be called.
329
+ */
330
+ set messageLost(callback) {
331
+ this._message_lost = callback;
332
+ }
333
+
334
+ /**
335
+ * Get the callback for message lost event.
336
+ * @return {function} - The callback function.
337
+ */
338
+ get messageLost() {
339
+ return this._message_lost;
340
+ }
341
+
342
+ /**
343
+ * Set the callback for incompatible type event.
344
+ * @param {function} callback - The callback function to be called.
345
+ */
346
+ set incompatibleType(callback) {
347
+ this._incompatible_type = callback;
348
+ }
349
+
350
+ /**
351
+ * Get the callback for incompatible type event.
352
+ * @return {function} - The callback function.
353
+ */
354
+ get incompatibleType() {
355
+ return this._incompatible_type;
356
+ }
357
+
358
+ /**
359
+ * Set the callback for matched event.
360
+ * @param {function} callback - The callback function to be called.
361
+ */
362
+ set matched(callback) {
363
+ this._matched = callback;
364
+ }
365
+
366
+ /**
367
+ * Get the callback for matched event.
368
+ * @return {function} - The callback function.
369
+ */
370
+ get matched() {
371
+ return this._matched;
372
+ }
373
+
374
+ createEventHandlers(subscriptionHandle) {
375
+ if (this._deadline) {
376
+ const deadlineHandle = rclnodejs.createSubscriptionEventHandle(
377
+ subscriptionHandle,
378
+ SubscriptionEventType.SUBSCRIPTION_REQUESTED_DEADLINE_MISSED
379
+ );
380
+ this._eventHandlers.push(
381
+ new EventHandler(
382
+ deadlineHandle,
383
+ this._deadline,
384
+ SubscriptionEventType.SUBSCRIPTION_REQUESTED_DEADLINE_MISSED,
385
+ 'subscription_event_type'
386
+ )
387
+ );
388
+ }
389
+
390
+ if (this._incompatible_qos) {
391
+ const incompatibleQosHandle = rclnodejs.createSubscriptionEventHandle(
392
+ subscriptionHandle,
393
+ SubscriptionEventType.SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS
394
+ );
395
+ this._eventHandlers.push(
396
+ new EventHandler(
397
+ incompatibleQosHandle,
398
+ this._incompatible_qos,
399
+ SubscriptionEventType.SUBSCRIPTION_REQUESTED_INCOMPATIBLE_QOS,
400
+ 'subscription_event_type'
401
+ )
402
+ );
403
+ }
404
+
405
+ if (this._liveliness) {
406
+ const livelinessHandle = rclnodejs.createSubscriptionEventHandle(
407
+ subscriptionHandle,
408
+ SubscriptionEventType.SUBSCRIPTION_LIVELINESS_CHANGED
409
+ );
410
+ this._eventHandlers.push(
411
+ new EventHandler(
412
+ livelinessHandle,
413
+ this._liveliness,
414
+ SubscriptionEventType.SUBSCRIPTION_LIVELINESS_CHANGED,
415
+ 'subscription_event_type'
416
+ )
417
+ );
418
+ }
419
+
420
+ if (this._message_lost) {
421
+ const messageLostHandle = rclnodejs.createSubscriptionEventHandle(
422
+ subscriptionHandle,
423
+ SubscriptionEventType.SUBSCRIPTION_MESSAGE_LOST
424
+ );
425
+ this._eventHandlers.push(
426
+ new EventHandler(
427
+ messageLostHandle,
428
+ this._message_lost,
429
+ SubscriptionEventType.SUBSCRIPTION_MESSAGE_LOST,
430
+ 'subscription_event_type'
431
+ )
432
+ );
433
+ }
434
+
435
+ if (this._incompatible_type) {
436
+ const incompatibleTypeHandle = rclnodejs.createSubscriptionEventHandle(
437
+ subscriptionHandle,
438
+ SubscriptionEventType.SUBSCRIPTION_INCOMPATIBLE_TYPE
439
+ );
440
+ this._eventHandlers.push(
441
+ new EventHandler(
442
+ incompatibleTypeHandle,
443
+ this._incompatible_type,
444
+ SubscriptionEventType.SUBSCRIPTION_INCOMPATIBLE_TYPE,
445
+ 'subscription_event_type'
446
+ )
447
+ );
448
+ }
449
+
450
+ if (this._matched) {
451
+ const matchedHandle = rclnodejs.createSubscriptionEventHandle(
452
+ subscriptionHandle,
453
+ SubscriptionEventType.SUBSCRIPTION_MATCHED
454
+ );
455
+ this._eventHandlers.push(
456
+ new EventHandler(
457
+ matchedHandle,
458
+ this._matched,
459
+ SubscriptionEventType.SUBSCRIPTION_MATCHED,
460
+ 'subscription_event_type'
461
+ )
462
+ );
463
+ }
464
+
465
+ return this._eventHandlers;
466
+ }
467
+ }
468
+
469
+ module.exports = {
470
+ PublisherEventCallbacks,
471
+ PublisherEventType,
472
+ SubscriptionEventCallbacks,
473
+ SubscriptionEventType,
474
+ };
package/lib/lifecycle.js CHANGED
@@ -600,6 +600,15 @@ class LifecycleNode extends Node {
600
600
  return rclnodejs.isInitialized(this._stateMachineHandle);
601
601
  }
602
602
 
603
+ /**
604
+ * Log the state machine data.
605
+ *
606
+ * @returns {undefined} void.
607
+ */
608
+ print() {
609
+ rclnodejs.print(this._stateMachineHandle);
610
+ }
611
+
603
612
  /**
604
613
  * The GetState service handler.
605
614
  * @param {Object} request - The GetState service request.
@@ -93,10 +93,10 @@ class LifecyclePublisher extends Publisher {
93
93
  this.deactivate();
94
94
  }
95
95
 
96
- static createPublisher(nodeHandle, typeClass, topic, options) {
96
+ static createPublisher(node, typeClass, topic, options) {
97
97
  let type = typeClass.type();
98
98
  let handle = rclnodejs.createPublisher(
99
- nodeHandle,
99
+ node.handle,
100
100
  type.pkgName,
101
101
  type.subFolder,
102
102
  type.interfaceName,