rclnodejs 0.27.0 → 0.27.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.
- package/README.md +2 -2
- package/lib/action/client.js +2 -2
- package/lib/client.js +1 -1
- package/package.json +1 -1
- package/rosidl_gen/generator.json +1 -1
- package/rosidl_gen/message_translator.js +4 -1
- package/rosidl_gen/templates/message.dot +46 -9
- package/scripts/npmjs-readme.md +2 -2
- package/types/action_client.d.ts +1 -1
package/README.md
CHANGED
|
@@ -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://
|
|
26
|
-
- **DON'T FORGET TO [SOURCE THE ROS 2 STARTUP FILES](https://
|
|
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)**
|
|
27
27
|
|
|
28
28
|
## Install rclnodejs
|
|
29
29
|
|
package/lib/action/client.js
CHANGED
|
@@ -191,7 +191,7 @@ class ActionClient extends Entity {
|
|
|
191
191
|
* Send a goal and wait for the goal ACK asynchronously.
|
|
192
192
|
*
|
|
193
193
|
* Return a Promise object that is resolved with a ClientGoalHandle when receipt of the goal
|
|
194
|
-
* is acknowledged by an action server, see client state transition https://
|
|
194
|
+
* is acknowledged by an action server, see client state transition https://docs.ros.org/en/jazzy/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.html
|
|
195
195
|
*
|
|
196
196
|
* @param {object} goal - The goal request.
|
|
197
197
|
* @param {function} feedbackCallback - Callback function for feedback associated with the goal.
|
|
@@ -307,7 +307,7 @@ class ActionClient extends Entity {
|
|
|
307
307
|
/**
|
|
308
308
|
* Get the result of an active goal asynchronously.
|
|
309
309
|
*
|
|
310
|
-
* Return a Promise object that is resolved with result, see client state transition https://
|
|
310
|
+
* Return a Promise object that is resolved with result, see client state transition https://docs.ros.org/en/jazzy/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.html
|
|
311
311
|
*
|
|
312
312
|
* @ignore
|
|
313
313
|
* @param {ClientGoalHandle} goalHandle - Handle to the goal to cancel.
|
package/lib/client.js
CHANGED
|
@@ -73,7 +73,7 @@ class Client extends Entity {
|
|
|
73
73
|
this._sequenceNumberToCallbackMap.delete(sequenceNumber);
|
|
74
74
|
callback(response.toPlainObject(this.typedArrayEnabled));
|
|
75
75
|
} else {
|
|
76
|
-
|
|
76
|
+
debug(
|
|
77
77
|
`Client has received an unexpected ${this._serviceName} with sequence number ${sequenceNumber}.`
|
|
78
78
|
);
|
|
79
79
|
}
|
package/package.json
CHANGED
|
@@ -145,10 +145,13 @@ function toPlainObject(message, enableTypedArray = true) {
|
|
|
145
145
|
obj[name] = Array.from(message[name]);
|
|
146
146
|
} else {
|
|
147
147
|
// Direct assignment
|
|
148
|
-
//
|
|
148
|
+
// Note: TypedArray also falls into this branch if |enableTypedArray| is true
|
|
149
149
|
// TODO(Kenny): make sure Int64 & Uint64 type can be copied here
|
|
150
150
|
obj[name] = message[name];
|
|
151
151
|
}
|
|
152
|
+
} else if (def.fields[i].type.isArray && def.fields[i].type.type === 'Constants') {
|
|
153
|
+
// For a constants array, because its field is empty we just return an empty array here.
|
|
154
|
+
obj[name] = [];
|
|
152
155
|
} else {
|
|
153
156
|
// Proceed further
|
|
154
157
|
obj[name] = toPlainObject(message[name], enableTypedArray);
|
|
@@ -330,6 +330,11 @@ class {{=objectWrapper}} {
|
|
|
330
330
|
{{? field.default_value !== null && field.type.isPrimitiveType && isTypedArrayType(field.type)}}
|
|
331
331
|
this._wrapperFields.{{=field.name}}.fill({{=getTypedArrayName(field.type)}}.from({{=JSON.stringify(field.default_value)}}));
|
|
332
332
|
{{?}}
|
|
333
|
+
{{? field.type.type === 'string' && field.type.isFixedSizeArray}}
|
|
334
|
+
for (let i = 0; i < {{=field.type.arraySize}}; i++) {
|
|
335
|
+
primitiveTypes.initString(this._refObject.{{=field.name}}[i]);
|
|
336
|
+
}
|
|
337
|
+
{{?}}
|
|
333
338
|
{{?? !field.type.isPrimitiveType || (field.type.type === 'string' && it.spec.msgName !== 'String')}}
|
|
334
339
|
this._wrapperFields.{{=field.name}} = new {{=getWrapperNameByType(field.type)}}();
|
|
335
340
|
{{?? it.spec.msgName === 'String'}}
|
|
@@ -376,10 +381,26 @@ class {{=objectWrapper}} {
|
|
|
376
381
|
{{~}}
|
|
377
382
|
|
|
378
383
|
{{~ it.spec.fields :field}}
|
|
379
|
-
{{? field.type.isArray && field.type.isPrimitiveType && field.type.isFixedSizeArray}}
|
|
380
|
-
|
|
381
|
-
|
|
384
|
+
{{? field.type.isArray && field.type.isPrimitiveType && !isTypedArrayType(field.type) && field.type.isFixedSizeArray }}
|
|
385
|
+
{{? field.type.type === 'string'}}
|
|
386
|
+
for (let i = 0; i < {{=field.type.arraySize}}; i++) {
|
|
387
|
+
if (own) {
|
|
388
|
+
primitiveTypes.initString(this._refObject.{{=field.name}}[i].ref(), own);
|
|
389
|
+
} else {
|
|
390
|
+
if (this._{{=field.name}}Array.length === {{=field.type.arraySize}}) {
|
|
391
|
+
const value = this._{{=field.name}}Array[i];
|
|
392
|
+
this._refObject.{{=field.name}}[i].data = value;
|
|
393
|
+
this._refObject.{{=field.name}}[i].size = Buffer.byteLength(value);
|
|
394
|
+
this._refObject.{{=field.name}}[i].capacity = Buffer.byteLength(value) + 1;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
382
397
|
}
|
|
398
|
+
// For non-typed array like int64/uint64/bool.
|
|
399
|
+
{{?? true}}
|
|
400
|
+
this._refObject.{{=field.name}} = this._{{=field.name}}Array;
|
|
401
|
+
{{?}}
|
|
402
|
+
{{?? field.type.isArray && field.type.isPrimitiveType && isTypedArrayType(field.type) && field.type.isFixedSizeArray}}
|
|
403
|
+
this._refObject.{{=field.name}} = Array.from(this._wrapperFields.{{=field.name}}.data);
|
|
383
404
|
{{?? field.type.isArray && field.type.isPrimitiveType && !isTypedArrayType(field.type)}}
|
|
384
405
|
if (!own) {
|
|
385
406
|
this._wrapperFields.{{=field.name}}.fill(this._{{=field.name}}Array);
|
|
@@ -391,9 +412,11 @@ class {{=objectWrapper}} {
|
|
|
391
412
|
this._refObject.{{=field.name}} = this._wrapperFields.{{=field.name}}.refObject;
|
|
392
413
|
}
|
|
393
414
|
{{?? field.type.isArray && !field.type.isPrimitiveType && field.type.isFixedSizeArray}}
|
|
394
|
-
for (let i = 0; i <
|
|
395
|
-
|
|
396
|
-
|
|
415
|
+
for (let i = 0; i < {{=field.type.arraySize}}; i++) {
|
|
416
|
+
if (this._wrapperFields.{{=field.name}}.data[i]) {
|
|
417
|
+
this._wrapperFields.{{=field.name}}.data[i].freeze(own, checkConsistency);
|
|
418
|
+
this._refObject.{{=field.name}}[i] = this._wrapperFields.{{=field.name}}.data[i].refObject;
|
|
419
|
+
}
|
|
397
420
|
}
|
|
398
421
|
{{?? !field.type.isPrimitiveType || field.type.isArray}}
|
|
399
422
|
this._wrapperFields.{{=field.name}}.freeze(own, checkConsistency);
|
|
@@ -429,9 +452,17 @@ class {{=objectWrapper}} {
|
|
|
429
452
|
this._{{=field.name}}Intialized = true;
|
|
430
453
|
{{?}}
|
|
431
454
|
|
|
432
|
-
{{? field.type.isArray && field.type.isPrimitiveType && field.type.isFixedSizeArray}}
|
|
433
|
-
this._refObject.{{=field.name}} = refObject.{{=field.name}};
|
|
455
|
+
{{? field.type.isArray && field.type.isPrimitiveType && field.type.isFixedSizeArray && isTypedArrayType(field.type)}}
|
|
434
456
|
this._wrapperFields.{{=field.name}}.fill(refObject.{{=field.name}}.toArray());
|
|
457
|
+
{{?? field.type.isArray && field.type.isPrimitiveType && field.type.isFixedSizeArray && !isTypedArrayType(field.type)}}
|
|
458
|
+
{{? field.type.type === 'string' }}
|
|
459
|
+
for (let index = 0; index < {{=field.type.arraySize}}; index++) {
|
|
460
|
+
this._{{=field.name}}Array[index] = refObject.{{=field.name}}[index].data;
|
|
461
|
+
}
|
|
462
|
+
// For non-typed array like int64/uint64/bool.
|
|
463
|
+
{{?? true}}
|
|
464
|
+
this._{{=field.name}}Array = refObject.{{=field.name}}.toArray();
|
|
465
|
+
{{?}}
|
|
435
466
|
{{?? field.type.isArray && field.type.isPrimitiveType && !isTypedArrayType(field.type)}}
|
|
436
467
|
refObject.{{=field.name}}.data.length = refObject.{{=field.name}}.size;
|
|
437
468
|
for (let index = 0; index < refObject.{{=field.name}}.size; index++) {
|
|
@@ -472,6 +503,10 @@ class {{=objectWrapper}} {
|
|
|
472
503
|
for (let i = 0; i < {{=field.type.arraySize}}; i++) {
|
|
473
504
|
{{=getWrapperNameByType(field.type)}}.freeStruct(refObject.{{=field.name}}[i]);
|
|
474
505
|
}
|
|
506
|
+
{{?? field.type.isArray && field.type.type === 'string' && field.type.isFixedSizeArray}}
|
|
507
|
+
for (let i = 0; i < {{=field.type.arraySize}}; i++) {
|
|
508
|
+
{{=getWrapperNameByType(field.type)}}.freeStruct(refObject.{{=field.name}}[i]);
|
|
509
|
+
}
|
|
475
510
|
{{?? !field.type.isPrimitiveType || (field.type.type === 'string' && it.spec.msgName !== 'String')}}
|
|
476
511
|
{{=getWrapperNameByType(field.type)}}.freeStruct(refObject.{{=field.name}});
|
|
477
512
|
{{?? it.spec.msgName === 'String'}}
|
|
@@ -502,7 +537,9 @@ class {{=objectWrapper}} {
|
|
|
502
537
|
|
|
503
538
|
{{~ it.spec.fields :field}}
|
|
504
539
|
get {{=field.name}}() {
|
|
505
|
-
{{? field.type.isArray &&
|
|
540
|
+
{{? field.type.isArray && field.type.type === 'Constants'}}
|
|
541
|
+
return [];
|
|
542
|
+
{{?? field.type.isArray && isTypedArrayType(field.type)}}
|
|
506
543
|
return this._wrapperFields['{{=field.name}}'].data;
|
|
507
544
|
{{?? field.type.isArray && field.type.isPrimitiveType}}
|
|
508
545
|
return this._{{=field.name}}Array;
|
package/scripts/npmjs-readme.md
CHANGED
|
@@ -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://
|
|
26
|
-
- **DON'T FORGET TO [SOURCE THE ROS 2 STARTUP FILES](https://
|
|
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)**
|
|
27
27
|
|
|
28
28
|
## Install rclnodejs
|
|
29
29
|
|
package/types/action_client.d.ts
CHANGED
|
@@ -139,7 +139,7 @@ declare module 'rclnodejs' {
|
|
|
139
139
|
* Send a goal and wait for the goal ACK asynchronously.
|
|
140
140
|
*
|
|
141
141
|
* Return a Promise object that is resolved with a ClientGoalHandle when receipt of the goal
|
|
142
|
-
* is acknowledged by an action server, see client state transition https://
|
|
142
|
+
* is acknowledged by an action server, see client state transition https://docs.ros.org/en/jazzy/Tutorials/Beginner-CLI-Tools/Understanding-ROS2-Actions/Understanding-ROS2-Actions.html
|
|
143
143
|
*
|
|
144
144
|
* @param goal - The goal request.
|
|
145
145
|
* @param feedbackCallback - Callback function for feedback associated with the goal.
|