rclnodejs 0.25.0 → 0.26.1

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/client.js CHANGED
@@ -50,13 +50,15 @@ class Client extends Entity {
50
50
  * @see {@link ResponseCallback}
51
51
  */
52
52
  sendRequest(request, callback) {
53
+ if (typeof callback !== 'function') {
54
+ throw new TypeError('Invalid argument');
55
+ }
56
+
53
57
  let requestToSend =
54
58
  request instanceof this._typeClass.Request
55
59
  ? request
56
60
  : new this._typeClass.Request(request);
57
- if (typeof callback !== 'function') {
58
- throw new TypeError('Invalid argument');
59
- }
61
+ requestToSend._willCheckConsistency = this._options.willCheckConsistency;
60
62
 
61
63
  let rawRequest = requestToSend.serialize();
62
64
  let sequenceNumber = rclnodejs.sendRequest(this._handle, rawRequest);
@@ -27,7 +27,7 @@ const Publisher = require('./publisher.js');
27
27
  */
28
28
  class LifecyclePublisher extends Publisher {
29
29
  constructor(handle, typeClass, topic, options) {
30
- super(handle, typeClass, options);
30
+ super(handle, typeClass, /*topic=*/'', options);
31
31
 
32
32
  this._enabled = false;
33
33
  this._loggger = Logging.getLogger('LifecyclePublisher');
package/lib/node.js CHANGED
@@ -502,6 +502,10 @@ class Node extends rclnodejs.ShadowNode {
502
502
  options = Object.assign(options, { isRaw: false });
503
503
  }
504
504
 
505
+ if (options.willCheckConsistency === undefined) {
506
+ options = Object.assign(options, { willCheckConsistency: false });
507
+ }
508
+
505
509
  return options;
506
510
  }
507
511
 
@@ -588,6 +592,7 @@ class Node extends rclnodejs.ShadowNode {
588
592
  * @param {object} options - The options argument used to parameterize the publisher.
589
593
  * @param {boolean} options.enableTypedArray - The topic will use TypedArray if necessary, default: true.
590
594
  * @param {QoS} options.qos - ROS Middleware "quality of service" settings for the publisher, default: QoS.profileDefault.
595
+ * @param {boolean} options.willCheckConsistency - Pulisher will check the consistancy of the message to be sent, default: false.
591
596
  * @return {Publisher} - An instance of Publisher.
592
597
  */
593
598
  createPublisher(typeClass, topic, options) {
@@ -690,6 +695,7 @@ class Node extends rclnodejs.ShadowNode {
690
695
  * @param {object} options - The options argument used to parameterize the client.
691
696
  * @param {boolean} options.enableTypedArray - The response will use TypedArray if necessary, default: true.
692
697
  * @param {QoS} options.qos - ROS Middleware "quality of service" settings for the client, default: QoS.profileDefault.
698
+ * @param {boolean} options.willCheckConsistency - Client will check the consistancy of the message to be sent, default: false.
693
699
  * @return {Client} - An instance of Client.
694
700
  */
695
701
  createClient(typeClass, serviceName, options) {
@@ -1690,6 +1696,7 @@ Node.getDefaultOptions = function () {
1690
1696
  isRaw: false,
1691
1697
  qos: QoS.profileDefault,
1692
1698
  contentFilter: undefined,
1699
+ willCheckConsistency: false
1693
1700
  };
1694
1701
  };
1695
1702
 
package/lib/publisher.js CHANGED
@@ -53,7 +53,7 @@ class Publisher extends Entity {
53
53
  message instanceof this._typeClass
54
54
  ? message
55
55
  : new this._typeClass(message);
56
-
56
+ messageToSend._willCheckConsistency = this._options.willCheckConsistency;
57
57
  let rawMessage = messageToSend.serialize();
58
58
  rclnodejs.publish(this._handle, rawMessage);
59
59
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rclnodejs",
3
- "version": "0.25.0",
3
+ "version": "0.26.1",
4
4
  "description": "ROS2.0 JavaScript client with Node.js",
5
5
  "main": "index.js",
6
6
  "types": "types/index.d.ts",
@@ -57,7 +57,6 @@
57
57
  "lint-staged": "^14.0.1",
58
58
  "mocha": "^10.2.0",
59
59
  "prettier": "^3.0.3",
60
- "rimraf": "^5.0.1",
61
60
  "sinon": "^15.2.0",
62
61
  "tree-kill": "^1.2.2",
63
62
  "typescript": "^4.9.3"
@@ -78,6 +77,7 @@
78
77
  "mkdirp": "^3.0.1",
79
78
  "mz": "^2.7.0",
80
79
  "nan": "^2.17.0",
80
+ "rimraf": "^5.0.1",
81
81
  "uuid": "^9.0.0",
82
82
  "walk": "^2.3.15"
83
83
  },
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rosidl-generator",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Generate JavaScript object from ROS IDL(.msg) files",
5
5
  "main": "index.js",
6
6
  "authors": [
@@ -92,6 +92,9 @@ async function generateServiceEventMsg(serviceInfo, dir) {
92
92
 
93
93
  async function generateServiceEventJSStruct(msgInfo, dir) {
94
94
  const spec = await parser.parseMessageFile(msgInfo.pkgName, msgInfo.filePath);
95
+ // Pass `msgInfo.subFolder` to the `spec`, because some .srv files of the
96
+ // package may not be put under srv/ folder, e.g., slam_toolbox.
97
+ spec.subFolder = msgInfo.subFolder;
95
98
 
96
99
  // Remove the `.msg` files generated in `generateServiceEventMsg()` to avoid
97
100
  // being found later.
@@ -198,7 +198,7 @@ function getModulePathByType(type, messageInfo) {
198
198
 
199
199
  /* We should use '__msg__' to require "service_msgs/msg/ServiceEventInfo.msg" for service event message. */
200
200
  if (messageInfo && messageInfo.isServiceEvent && (type.type !== 'ServiceEventInfo')) {
201
- return type.pkgName + '__srv__' + type.type + '.js';
201
+ return type.pkgName + `__${it.spec.subFolder}__` + type.type + '.js';
202
202
  }
203
203
  return type.pkgName + '__msg__' + type.type + '.js';
204
204
  }
@@ -269,8 +269,9 @@ const {{=refObjectArrayType}} = StructType({
269
269
 
270
270
  // Define the wrapper class.
271
271
  class {{=objectWrapper}} {
272
- constructor(other) {
272
+ constructor(other, willCheckConsistency = false) {
273
273
  this._wrapperFields = {};
274
+ this._willCheckConsistency = willCheckConsistency;
274
275
  {{~ it.spec.fields :field}}
275
276
  {{? field.type.isArray && field.type.isPrimitiveType && !isTypedArrayType(field.type)}}
276
277
  this._{{=field.name}}Array = [];
@@ -366,15 +367,13 @@ class {{=objectWrapper}} {
366
367
  }
367
368
 
368
369
  freeze(own = false, checkConsistency = false) {
369
- if (checkConsistency) {
370
370
  {{~ it.spec.fields :field}}
371
371
  {{? field.type.isPrimitiveType && !field.type.isArray}}
372
- if (!this._{{=field.name}}Intialized) {
372
+ if (checkConsistency && !this._{{=field.name}}Intialized) {
373
373
  throw new TypeError('Invalid argument: {{=field.name}} in {{=it.spec.msgName}}');
374
374
  }
375
375
  {{?}}
376
376
  {{~}}
377
- }
378
377
 
379
378
  {{~ it.spec.fields :field}}
380
379
  {{? field.type.isArray && field.type.isPrimitiveType && field.type.isFixedSizeArray}}
@@ -420,7 +419,7 @@ class {{=objectWrapper}} {
420
419
  }
421
420
 
422
421
  serialize() {
423
- this.freeze(false, true);
422
+ this.freeze(/*own=*/false, this._willCheckConsistency);
424
423
  return this._refObject.ref();
425
424
  }
426
425