rclnodejs 0.27.1 → 0.27.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/README.md +2 -2
- package/lib/action/client.js +2 -2
- 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/rostsd_gen/index.js +2 -1
- package/scripts/npmjs-readme.md +2 -2
- package/src/rcl_action_bindings.cpp +1 -0
- package/src/rcl_bindings.cpp +8 -0
- package/types/action_client.d.ts +1 -1
- package/types/interfaces.d.ts +11 -0
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/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/rostsd_gen/index.js
CHANGED
|
@@ -361,8 +361,9 @@ function isInternalActionMsgInterface(rosMsgInterface) {
|
|
|
361
361
|
function isInternalServiceEventMsgInterface(rosMsgInterface) {
|
|
362
362
|
let name = rosMsgInterface.type().interfaceName;
|
|
363
363
|
let subFolder = rosMsgInterface.type().subFolder;
|
|
364
|
+
// Some package puts .srv files under srvs/, e.g., slam_toolbox.
|
|
364
365
|
return (
|
|
365
|
-
(subFolder == 'srv' || subFolder == 'action')
|
|
366
|
+
(subFolder == 'srv' || subFolder == 'srvs' || subFolder == 'action')
|
|
366
367
|
&& name.endsWith('_Event')
|
|
367
368
|
);
|
|
368
369
|
}
|
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/src/rcl_bindings.cpp
CHANGED
|
@@ -325,11 +325,19 @@ NAN_METHOD(CreateTimer) {
|
|
|
325
325
|
reinterpret_cast<rcl_timer_t*>(malloc(sizeof(rcl_timer_t)));
|
|
326
326
|
*timer = rcl_get_zero_initialized_timer();
|
|
327
327
|
|
|
328
|
+
#if ROS_VERSION > 2205 // After humble.
|
|
329
|
+
THROW_ERROR_IF_NOT_EQUAL(
|
|
330
|
+
RCL_RET_OK,
|
|
331
|
+
rcl_timer_init2(timer, clock, context, RCL_MS_TO_NS(period_ms), nullptr,
|
|
332
|
+
rcl_get_default_allocator(), /*autostart=*/true),
|
|
333
|
+
rcl_get_error_string().str);
|
|
334
|
+
#else
|
|
328
335
|
THROW_ERROR_IF_NOT_EQUAL(
|
|
329
336
|
RCL_RET_OK,
|
|
330
337
|
rcl_timer_init(timer, clock, context, RCL_MS_TO_NS(period_ms), nullptr,
|
|
331
338
|
rcl_get_default_allocator()),
|
|
332
339
|
rcl_get_error_string().str);
|
|
340
|
+
#endif
|
|
333
341
|
|
|
334
342
|
auto js_obj = RclHandle::NewInstance(timer, clock_handle, [](void* ptr) {
|
|
335
343
|
rcl_timer_t* timer = reinterpret_cast<rcl_timer_t*>(ptr);
|
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.
|
package/types/interfaces.d.ts
CHANGED
|
@@ -832,6 +832,15 @@ declare module 'rclnodejs' {
|
|
|
832
832
|
export interface Vector3StampedConstructor {
|
|
833
833
|
new(other?: Vector3Stamped): Vector3Stamped;
|
|
834
834
|
}
|
|
835
|
+
export interface VelocityStamped {
|
|
836
|
+
header: std_msgs.msg.Header;
|
|
837
|
+
body_frame_id: string;
|
|
838
|
+
reference_frame_id: string;
|
|
839
|
+
velocity: geometry_msgs.msg.Twist;
|
|
840
|
+
}
|
|
841
|
+
export interface VelocityStampedConstructor {
|
|
842
|
+
new(other?: VelocityStamped): VelocityStamped;
|
|
843
|
+
}
|
|
835
844
|
export interface Wrench {
|
|
836
845
|
force: geometry_msgs.msg.Vector3;
|
|
837
846
|
torque: geometry_msgs.msg.Vector3;
|
|
@@ -3743,6 +3752,7 @@ declare module 'rclnodejs' {
|
|
|
3743
3752
|
'geometry_msgs/msg/TwistWithCovarianceStamped': geometry_msgs.msg.TwistWithCovarianceStamped,
|
|
3744
3753
|
'geometry_msgs/msg/Vector3': geometry_msgs.msg.Vector3,
|
|
3745
3754
|
'geometry_msgs/msg/Vector3Stamped': geometry_msgs.msg.Vector3Stamped,
|
|
3755
|
+
'geometry_msgs/msg/VelocityStamped': geometry_msgs.msg.VelocityStamped,
|
|
3746
3756
|
'geometry_msgs/msg/Wrench': geometry_msgs.msg.Wrench,
|
|
3747
3757
|
'geometry_msgs/msg/WrenchStamped': geometry_msgs.msg.WrenchStamped,
|
|
3748
3758
|
'lifecycle_msgs/msg/State': lifecycle_msgs.msg.State,
|
|
@@ -4120,6 +4130,7 @@ declare module 'rclnodejs' {
|
|
|
4120
4130
|
'geometry_msgs/msg/TwistWithCovarianceStamped': geometry_msgs.msg.TwistWithCovarianceStampedConstructor,
|
|
4121
4131
|
'geometry_msgs/msg/Vector3': geometry_msgs.msg.Vector3Constructor,
|
|
4122
4132
|
'geometry_msgs/msg/Vector3Stamped': geometry_msgs.msg.Vector3StampedConstructor,
|
|
4133
|
+
'geometry_msgs/msg/VelocityStamped': geometry_msgs.msg.VelocityStampedConstructor,
|
|
4123
4134
|
'geometry_msgs/msg/Wrench': geometry_msgs.msg.WrenchConstructor,
|
|
4124
4135
|
'geometry_msgs/msg/WrenchStamped': geometry_msgs.msg.WrenchStampedConstructor,
|
|
4125
4136
|
'lifecycle_msgs/msg/State': lifecycle_msgs.msg.StateConstructor,
|