rclnodejs 0.24.0 → 0.26.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.
- package/lib/client.js +6 -4
- package/lib/lifecycle_publisher.js +1 -1
- package/lib/node.js +7 -0
- package/lib/publisher.js +1 -1
- package/lib/service.js +1 -2
- package/package.json +2 -2
- package/rosidl_gen/generator.json +1 -1
- package/rosidl_gen/templates/message.dot +4 -5
- package/src/rcl_bindings.cpp +22 -11
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
|
-
|
|
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);
|
|
@@ -128,7 +130,7 @@ class Client extends Entity {
|
|
|
128
130
|
* @type {string}
|
|
129
131
|
*/
|
|
130
132
|
get serviceName() {
|
|
131
|
-
return this.
|
|
133
|
+
return rclnodejs.getClientServiceName(this._handle);
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
/**
|
|
@@ -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/lib/service.js
CHANGED
|
@@ -112,8 +112,7 @@ class Service extends Entity {
|
|
|
112
112
|
* @type {string}
|
|
113
113
|
*/
|
|
114
114
|
get serviceName() {
|
|
115
|
-
|
|
116
|
-
return fullServiceName.split('/').pop();
|
|
115
|
+
return rclnodejs.getServiceServiceName(this._handle);
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rclnodejs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
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
|
},
|
|
@@ -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,
|
|
422
|
+
this.freeze(/*own=*/false, this._willCheckConsistency);
|
|
424
423
|
return this._refObject.ref();
|
|
425
424
|
}
|
|
426
425
|
|
package/src/rcl_bindings.cpp
CHANGED
|
@@ -1107,16 +1107,6 @@ NAN_METHOD(RclTakeRequest) {
|
|
|
1107
1107
|
info.GetReturnValue().Set(Nan::Undefined());
|
|
1108
1108
|
}
|
|
1109
1109
|
|
|
1110
|
-
NAN_METHOD(GetServiceName) {
|
|
1111
|
-
rcl_service_t* service = reinterpret_cast<rcl_service_t*>(
|
|
1112
|
-
RclHandle::Unwrap<RclHandle>(
|
|
1113
|
-
Nan::To<v8::Object>(info[0]).ToLocalChecked())
|
|
1114
|
-
->ptr());
|
|
1115
|
-
|
|
1116
|
-
const char* name = rcl_service_get_service_name(service);
|
|
1117
|
-
info.GetReturnValue().Set(Nan::New(name).ToLocalChecked());
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
1110
|
NAN_METHOD(SendResponse) {
|
|
1121
1111
|
rcl_service_t* service = reinterpret_cast<rcl_service_t*>(
|
|
1122
1112
|
RclHandle::Unwrap<RclHandle>(
|
|
@@ -2017,6 +2007,26 @@ NAN_METHOD(RclTakeRaw) {
|
|
|
2017
2007
|
"Failed to deallocate message buffer");
|
|
2018
2008
|
}
|
|
2019
2009
|
|
|
2010
|
+
NAN_METHOD(GetClientServiceName) {
|
|
2011
|
+
rcl_client_t* client = reinterpret_cast<rcl_client_t*>(
|
|
2012
|
+
RclHandle::Unwrap<RclHandle>(
|
|
2013
|
+
Nan::To<v8::Object>(info[0]).ToLocalChecked())
|
|
2014
|
+
->ptr());
|
|
2015
|
+
|
|
2016
|
+
const char* service_name = rcl_client_get_service_name(client);
|
|
2017
|
+
info.GetReturnValue().Set(Nan::New(service_name).ToLocalChecked());
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
NAN_METHOD(GetServiceServiceName) {
|
|
2021
|
+
rcl_service_t* service = reinterpret_cast<rcl_service_t*>(
|
|
2022
|
+
RclHandle::Unwrap<RclHandle>(
|
|
2023
|
+
Nan::To<v8::Object>(info[0]).ToLocalChecked())
|
|
2024
|
+
->ptr());
|
|
2025
|
+
|
|
2026
|
+
const char* service_name = rcl_service_get_service_name(service);
|
|
2027
|
+
info.GetReturnValue().Set(Nan::New(service_name).ToLocalChecked());
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2020
2030
|
std::vector<BindingMethod> binding_methods = {
|
|
2021
2031
|
{"init", Init},
|
|
2022
2032
|
{"createNode", CreateNode},
|
|
@@ -2055,7 +2065,6 @@ std::vector<BindingMethod> binding_methods = {
|
|
|
2055
2065
|
{"rclTakeResponse", RclTakeResponse},
|
|
2056
2066
|
{"sendRequest", SendRequest},
|
|
2057
2067
|
{"createService", CreateService},
|
|
2058
|
-
{"getServiceName", GetServiceName},
|
|
2059
2068
|
{"rclTakeRequest", RclTakeRequest},
|
|
2060
2069
|
{"sendResponse", SendResponse},
|
|
2061
2070
|
{"shutdown", Shutdown},
|
|
@@ -2088,6 +2097,8 @@ std::vector<BindingMethod> binding_methods = {
|
|
|
2088
2097
|
{"serviceServerIsAvailable", ServiceServerIsAvailable},
|
|
2089
2098
|
{"publishRawMessage", PublishRawMessage},
|
|
2090
2099
|
{"rclTakeRaw", RclTakeRaw},
|
|
2100
|
+
{"getClientServiceName", GetClientServiceName},
|
|
2101
|
+
{"getServiceServiceName", GetServiceServiceName},
|
|
2091
2102
|
{"", nullptr}
|
|
2092
2103
|
#if ROS_VERSION > 2205 // 2205 == Humble
|
|
2093
2104
|
,
|