rclnodejs 0.30.0 → 0.32.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/README.md +1 -1
- package/eslint.config.mjs +65 -0
- package/lib/action/client.js +1 -1
- package/lib/action/server.js +5 -3
- package/lib/clock.js +2 -2
- package/lib/clock_type.js +0 -2
- package/lib/distro.js +1 -1
- package/lib/duration.js +22 -35
- package/lib/interface_loader.js +1 -2
- package/lib/lifecycle.js +0 -5
- package/lib/lifecycle_publisher.js +1 -1
- package/lib/node.js +9 -20
- package/lib/parameter.js +6 -9
- package/lib/parameter_service.js +1 -2
- package/lib/publisher.js +1 -1
- package/lib/qos.js +0 -2
- package/lib/rate.js +1 -2
- package/lib/rmw.js +12 -0
- package/lib/time.js +39 -50
- package/lib/time_source.js +1 -2
- package/lib/timer.js +5 -5
- package/package.json +20 -23
- package/rosidl_gen/action_msgs.js +0 -1
- package/rosidl_gen/filter.js +14 -1
- package/rosidl_gen/generator.json +1 -1
- package/rosidl_gen/index.js +0 -1
- package/rosidl_gen/message_translator.js +2 -9
- package/rosidl_gen/packages.js +1 -3
- package/rosidl_gen/primitive_types.js +0 -4
- package/rosidl_gen/templates/message.dot +4 -0
- package/rostsd_gen/index.js +0 -3
- package/scripts/cpplint.js +3 -4
- package/scripts/generate_messages.js +1 -1
- package/scripts/npmjs-readme.md +1 -1
- package/scripts/ros_distro.js +12 -0
- package/scripts/run_test.js +0 -2
- package/src/executor.hpp +3 -3
- package/src/handle_manager.hpp +3 -3
- package/src/macros.hpp +3 -3
- package/src/rcl_action_bindings.hpp +3 -3
- package/src/rcl_bindings.cpp +47 -111
- package/src/rcl_bindings.hpp +3 -3
- package/src/rcl_handle.hpp +3 -3
- package/src/rcl_lifecycle_bindings.hpp +3 -3
- package/src/rcl_utilities.hpp +3 -3
- package/src/shadow_node.hpp +3 -3
- package/types/action_client.d.ts +0 -1
- package/types/action_server.d.ts +0 -1
- package/types/base.d.ts +27 -28
- package/types/duration.d.ts +3 -4
- package/types/index.d.ts +1 -2
- package/types/lifecycle.d.ts +1 -3
- package/types/node.d.ts +1 -2
- package/types/parameter.d.ts +0 -2
- package/types/publisher.d.ts +0 -1
- package/types/time.d.ts +4 -14
- package/types/timer.d.ts +6 -6
package/README.md
CHANGED
|
@@ -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 [v0.
|
|
48
|
+
| latest version (currently [v0.32.0](https://github.com/RobotWebTools/rclnodejs/tree/0.32.0)) | [Humble](https://github.com/RobotWebTools/rclnodejs/tree/humble-hawksbill)<br>[Jazzy](https://github.com/RobotWebTools/rclnodejs/tree/jazzy) |
|
|
49
49
|
|
|
50
50
|
## Documentation
|
|
51
51
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import typescriptEslint from "@typescript-eslint/eslint-plugin";
|
|
2
|
+
import prettier from "eslint-plugin-prettier";
|
|
3
|
+
import globals from "globals";
|
|
4
|
+
import tsParser from "@typescript-eslint/parser";
|
|
5
|
+
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
|
|
6
|
+
import js from "@eslint/js";
|
|
7
|
+
|
|
8
|
+
export default [
|
|
9
|
+
{
|
|
10
|
+
ignores: [
|
|
11
|
+
"eslint.config.mjs",
|
|
12
|
+
"types/interfaces.d.ts",
|
|
13
|
+
"test/types/index.test-d.ts",
|
|
14
|
+
"**/generated/",
|
|
15
|
+
"**/scripts/",
|
|
16
|
+
"**/benchmark/",
|
|
17
|
+
"**/docs/",
|
|
18
|
+
"**/electron_demo/",
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
...js.configs.recommended,
|
|
23
|
+
files: ["lib/**/*.js", "index.js"],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
rules: {
|
|
27
|
+
'no-dupe-class-members': 'off',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
plugins: {
|
|
32
|
+
"@typescript-eslint": typescriptEslint,
|
|
33
|
+
},
|
|
34
|
+
languageOptions: {
|
|
35
|
+
globals: {
|
|
36
|
+
...globals.node,
|
|
37
|
+
},
|
|
38
|
+
parser: tsParser,
|
|
39
|
+
ecmaVersion: "latest",
|
|
40
|
+
sourceType: "module",
|
|
41
|
+
},
|
|
42
|
+
files: ['types/*.d.ts'],
|
|
43
|
+
rules: {
|
|
44
|
+
...typescriptEslint.configs.recommended.rules,
|
|
45
|
+
"@typescript-eslint/no-explicit-any": "off",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
plugins: {
|
|
50
|
+
prettier,
|
|
51
|
+
},
|
|
52
|
+
languageOptions: {
|
|
53
|
+
globals: {
|
|
54
|
+
...globals.node,
|
|
55
|
+
},
|
|
56
|
+
ecmaVersion: "latest",
|
|
57
|
+
sourceType: "commonjs",
|
|
58
|
+
},
|
|
59
|
+
files: ["lib/**/*.js", "rosidl_parser/**/*.js", "rosidl_gen/**/*.js",
|
|
60
|
+
"rostsd_gen/**/*.js", "test/**/*.js", "example/**/*.js", "index.js"],
|
|
61
|
+
rules: {
|
|
62
|
+
...eslintPluginPrettierRecommended.rules,
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
];
|
package/lib/action/client.js
CHANGED
|
@@ -172,7 +172,7 @@ class ActionClient extends Entity {
|
|
|
172
172
|
goalHandle.status = status;
|
|
173
173
|
|
|
174
174
|
// Remove done handles from the list
|
|
175
|
-
|
|
175
|
+
|
|
176
176
|
if (
|
|
177
177
|
status === ActionInterfaces.GoalStatus.STATUS_SUCCEEDED ||
|
|
178
178
|
status === ActionInterfaces.GoalStatus.STATUS_CANCELED ||
|
package/lib/action/server.js
CHANGED
|
@@ -266,10 +266,12 @@ class ActionServer extends Entity {
|
|
|
266
266
|
let goalHandle;
|
|
267
267
|
if (accepted) {
|
|
268
268
|
// Stamp time of acceptance
|
|
269
|
-
const
|
|
269
|
+
const { seconds, nanoseconds } = this._node
|
|
270
|
+
.getClock()
|
|
271
|
+
.now().secondsAndNanoseconds;
|
|
270
272
|
goalInfo.stamp = {
|
|
271
|
-
sec:
|
|
272
|
-
nanosec:
|
|
273
|
+
sec: Number(seconds),
|
|
274
|
+
nanosec: Number(nanoseconds),
|
|
273
275
|
};
|
|
274
276
|
|
|
275
277
|
try {
|
package/lib/clock.js
CHANGED
|
@@ -52,8 +52,8 @@ class Clock {
|
|
|
52
52
|
* @return {Time} Return the current time.
|
|
53
53
|
*/
|
|
54
54
|
now() {
|
|
55
|
-
|
|
56
|
-
return new Time(
|
|
55
|
+
const nowInNanosec = rclnodejs.clockGetNow(this._handle);
|
|
56
|
+
return new Time(0n, nowInNanosec, this._clockType);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
package/lib/clock_type.js
CHANGED
package/lib/distro.js
CHANGED
package/lib/duration.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
17
|
const rclnodejs = require('bindings')('rclnodejs');
|
|
18
|
-
const
|
|
18
|
+
const S_TO_NS = 10n ** 9n;
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @class - Class representing a Duration in ROS
|
|
@@ -24,51 +24,38 @@ const int64 = require('int64-napi');
|
|
|
24
24
|
class Duration {
|
|
25
25
|
/**
|
|
26
26
|
* Create a Duration.
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
27
|
+
* @param {bigint} [seconds=0] - The second part of the duration.
|
|
28
|
+
* @param {bigint} [nanoseconds=0] - The nanosecond part of the duration.
|
|
29
29
|
*/
|
|
30
|
-
constructor(seconds =
|
|
31
|
-
if (typeof seconds !== '
|
|
30
|
+
constructor(seconds = 0n, nanoseconds = 0n) {
|
|
31
|
+
if (typeof seconds !== 'bigint') {
|
|
32
32
|
throw new TypeError('Invalid argument of seconds');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
if (typeof nanoseconds !== '
|
|
35
|
+
if (typeof nanoseconds !== 'bigint') {
|
|
36
36
|
throw new TypeError('Invalid argument of nanoseconds');
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
if (typeof nanoseconds === 'string' && nanoseconds.startsWith('-')) {
|
|
46
|
-
nanoInt64 = int64.negative(nanoInt64);
|
|
39
|
+
const total = seconds * S_TO_NS + nanoseconds;
|
|
40
|
+
if (total >= 2n ** 63n) {
|
|
41
|
+
throw new RangeError(
|
|
42
|
+
'Total nanoseconds value is too large to store in C time point.'
|
|
43
|
+
);
|
|
47
44
|
}
|
|
48
|
-
|
|
49
|
-
this.
|
|
45
|
+
|
|
46
|
+
this._nanoseconds = total;
|
|
47
|
+
this._handle = rclnodejs.createDuration(this._nanoseconds);
|
|
50
48
|
}
|
|
51
49
|
|
|
52
50
|
/**
|
|
53
51
|
* Get the nanosecond part of the Duration.
|
|
54
52
|
* @name Duration#get:nanoseconds
|
|
55
53
|
* @function
|
|
56
|
-
* @return {
|
|
54
|
+
* @return {bigint} - value in nanosecond.
|
|
57
55
|
*/
|
|
58
56
|
|
|
59
57
|
get nanoseconds() {
|
|
60
|
-
|
|
61
|
-
let nano;
|
|
62
|
-
|
|
63
|
-
if (nanoStr.startsWith('-')) {
|
|
64
|
-
nano = int64.negative(int64.from(nanoStr));
|
|
65
|
-
} else {
|
|
66
|
-
nano = int64.from(nanoStr);
|
|
67
|
-
}
|
|
68
|
-
if (Number.isFinite(nano.toNumber())) {
|
|
69
|
-
return nano.toNumber();
|
|
70
|
-
}
|
|
71
|
-
return nano.toString();
|
|
58
|
+
return rclnodejs.getDurationNanoseconds(this._handle);
|
|
72
59
|
}
|
|
73
60
|
|
|
74
61
|
/**
|
|
@@ -78,7 +65,7 @@ class Duration {
|
|
|
78
65
|
*/
|
|
79
66
|
eq(other) {
|
|
80
67
|
if (other instanceof Duration) {
|
|
81
|
-
return this._nanoseconds
|
|
68
|
+
return this._nanoseconds === other.nanoseconds;
|
|
82
69
|
}
|
|
83
70
|
throw new TypeError(
|
|
84
71
|
`Can't compare duration with object of type: ${other.constructor.name}`
|
|
@@ -92,7 +79,7 @@ class Duration {
|
|
|
92
79
|
*/
|
|
93
80
|
ne(other) {
|
|
94
81
|
if (other instanceof Duration) {
|
|
95
|
-
return this._nanoseconds
|
|
82
|
+
return this._nanoseconds !== other.nanoseconds;
|
|
96
83
|
}
|
|
97
84
|
throw new TypeError('Invalid argument');
|
|
98
85
|
}
|
|
@@ -104,7 +91,7 @@ class Duration {
|
|
|
104
91
|
*/
|
|
105
92
|
lt(other) {
|
|
106
93
|
if (other instanceof Duration) {
|
|
107
|
-
return this._nanoseconds
|
|
94
|
+
return this._nanoseconds < other.nanoseconds;
|
|
108
95
|
}
|
|
109
96
|
throw new TypeError('Invalid argument');
|
|
110
97
|
}
|
|
@@ -116,7 +103,7 @@ class Duration {
|
|
|
116
103
|
*/
|
|
117
104
|
lte(other) {
|
|
118
105
|
if (other instanceof Duration) {
|
|
119
|
-
return this._nanoseconds
|
|
106
|
+
return this._nanoseconds <= other.nanoseconds;
|
|
120
107
|
}
|
|
121
108
|
throw new TypeError('Invalid argument');
|
|
122
109
|
}
|
|
@@ -128,7 +115,7 @@ class Duration {
|
|
|
128
115
|
*/
|
|
129
116
|
gt(other) {
|
|
130
117
|
if (other instanceof Duration) {
|
|
131
|
-
return this._nanoseconds
|
|
118
|
+
return this._nanoseconds > other.nanoseconds;
|
|
132
119
|
}
|
|
133
120
|
throw new TypeError('Invalid argument');
|
|
134
121
|
}
|
|
@@ -140,7 +127,7 @@ class Duration {
|
|
|
140
127
|
*/
|
|
141
128
|
gte(other) {
|
|
142
129
|
if (other instanceof Duration) {
|
|
143
|
-
return this._nanoseconds
|
|
130
|
+
return this._nanoseconds >= other.nanoseconds;
|
|
144
131
|
}
|
|
145
132
|
throw new TypeError('Invalid argument');
|
|
146
133
|
}
|
package/lib/interface_loader.js
CHANGED
|
@@ -59,7 +59,6 @@ let interfaceLoader = {
|
|
|
59
59
|
// Suppose the name is a package, and traverse the path to collect the IDL files.
|
|
60
60
|
let packagePath = path.join(generator.generatedRoot, name);
|
|
61
61
|
|
|
62
|
-
// eslint-disable-next-line
|
|
63
62
|
let interfaces = fs.readdirSync(packagePath);
|
|
64
63
|
if (interfaces.length > 0) {
|
|
65
64
|
return this.loadInterfaceByPath(packagePath, interfaces);
|
|
@@ -108,7 +107,7 @@ let interfaceLoader = {
|
|
|
108
107
|
packageName,
|
|
109
108
|
packageName + '__' + type + '__' + messageName + '.js'
|
|
110
109
|
);
|
|
111
|
-
|
|
110
|
+
|
|
112
111
|
if (fs.existsSync(filePath)) {
|
|
113
112
|
return require(filePath);
|
|
114
113
|
}
|
package/lib/lifecycle.js
CHANGED
|
@@ -588,8 +588,6 @@ class LifecycleNode extends Node {
|
|
|
588
588
|
* @throws {Error} If transition is invalid for the current state.
|
|
589
589
|
*/
|
|
590
590
|
shutdown(callbackReturnValue) {
|
|
591
|
-
let state = this.currentState;
|
|
592
|
-
|
|
593
591
|
return this._changeState(SHUTDOWN_TRANSITION_LABEL, callbackReturnValue);
|
|
594
592
|
}
|
|
595
593
|
|
|
@@ -603,7 +601,6 @@ class LifecycleNode extends Node {
|
|
|
603
601
|
_onGetState(request, response) {
|
|
604
602
|
let result = response.template;
|
|
605
603
|
|
|
606
|
-
// eslint-disable-next-line camelcase
|
|
607
604
|
result.current_state = this.currentState;
|
|
608
605
|
|
|
609
606
|
response.send(result);
|
|
@@ -619,7 +616,6 @@ class LifecycleNode extends Node {
|
|
|
619
616
|
_onGetAvailableStates(request, response) {
|
|
620
617
|
let result = response.template;
|
|
621
618
|
|
|
622
|
-
// eslint-disable-next-line camelcase
|
|
623
619
|
result.available_states = this.availableStates;
|
|
624
620
|
|
|
625
621
|
response.send(result);
|
|
@@ -634,7 +630,6 @@ class LifecycleNode extends Node {
|
|
|
634
630
|
_onGetAvailableTransitions(request, response) {
|
|
635
631
|
let result = response.template;
|
|
636
632
|
|
|
637
|
-
// eslint-disable-next-line camelcase
|
|
638
633
|
result.available_transitions = this.availableTransitions;
|
|
639
634
|
|
|
640
635
|
response.send(result);
|
|
@@ -37,7 +37,7 @@ class LifecyclePublisher extends Publisher {
|
|
|
37
37
|
* Publish a message only when activated; otherwise do nothing (nop);
|
|
38
38
|
*
|
|
39
39
|
* @param {object|Buffer} message - The message to be sent, could be kind of JavaScript message generated from .msg
|
|
40
|
-
*
|
|
40
|
+
* or be a Buffer for a raw message.
|
|
41
41
|
* @returns {undefined}
|
|
42
42
|
*/
|
|
43
43
|
publish(message) {
|
package/lib/node.js
CHANGED
|
@@ -507,7 +507,7 @@ class Node extends rclnodejs.ShadowNode {
|
|
|
507
507
|
|
|
508
508
|
/**
|
|
509
509
|
* Create a Timer.
|
|
510
|
-
* @param {
|
|
510
|
+
* @param {bigint} period - The number representing period in nanoseconds.
|
|
511
511
|
* @param {function} callback - The callback to be called when timeout.
|
|
512
512
|
* @param {Clock} [clock] - The clock which the timer gets time from.
|
|
513
513
|
* @return {Timer} - An instance of Timer.
|
|
@@ -519,22 +519,11 @@ class Node extends rclnodejs.ShadowNode {
|
|
|
519
519
|
clock = arguments[3];
|
|
520
520
|
}
|
|
521
521
|
|
|
522
|
-
if (typeof period !== '
|
|
522
|
+
if (typeof period !== 'bigint' || typeof callback !== 'function') {
|
|
523
523
|
throw new TypeError('Invalid argument');
|
|
524
524
|
}
|
|
525
525
|
|
|
526
|
-
// The period unit is millisecond in JavaScript side. When being passed to the
|
|
527
|
-
// C++ side, the value will be converted to nanosecond, which goes into a uint64_t
|
|
528
|
-
// with maxmium value of 2^64-1. So the maxmium is UINT64_MAX in ns, that's 0x10c6f7a0b5ed in ms.
|
|
529
|
-
const MAX_TIMER_PERIOD_IN_MILLISECOND = 0x10c6f7a0b5ed;
|
|
530
|
-
if (period > 0x10c6f7a0b5ed || period < 0) {
|
|
531
|
-
throw new RangeError(
|
|
532
|
-
`Parameter must be between 0.0 and ${MAX_TIMER_PERIOD_IN_MILLISECOND}`
|
|
533
|
-
);
|
|
534
|
-
}
|
|
535
|
-
|
|
536
526
|
const timerClock = clock || this._clock;
|
|
537
|
-
|
|
538
527
|
let timerHandle = rclnodejs.createTimer(
|
|
539
528
|
timerClock.handle,
|
|
540
529
|
this.context.handle,
|
|
@@ -573,7 +562,7 @@ class Node extends rclnodejs.ShadowNode {
|
|
|
573
562
|
}
|
|
574
563
|
|
|
575
564
|
const period = Math.round(1000 / hz);
|
|
576
|
-
const timer = this._rateTimerServer.createTimer(period);
|
|
565
|
+
const timer = this._rateTimerServer.createTimer(BigInt(period) * 1000000n);
|
|
577
566
|
const rate = new Rates.Rate(hz, timer);
|
|
578
567
|
|
|
579
568
|
return rate;
|
|
@@ -1480,10 +1469,10 @@ class Node extends rclnodejs.ShadowNode {
|
|
|
1480
1469
|
PARAMETER_EVENT_MSG_TYPE
|
|
1481
1470
|
))();
|
|
1482
1471
|
|
|
1483
|
-
const
|
|
1472
|
+
const { seconds, nanoseconds } = this._clock.now().secondsAndNanoseconds;
|
|
1484
1473
|
parameterEvent.stamp = {
|
|
1485
|
-
sec:
|
|
1486
|
-
nanosec:
|
|
1474
|
+
sec: Number(seconds),
|
|
1475
|
+
nanosec: Number(nanoseconds),
|
|
1487
1476
|
};
|
|
1488
1477
|
|
|
1489
1478
|
parameterEvent.node =
|
|
@@ -1507,7 +1496,7 @@ class Node extends rclnodejs.ShadowNode {
|
|
|
1507
1496
|
);
|
|
1508
1497
|
}
|
|
1509
1498
|
|
|
1510
|
-
//
|
|
1499
|
+
// Publish ParameterEvent.
|
|
1511
1500
|
this._parameterEventPublisher.publish(parameterEvent);
|
|
1512
1501
|
|
|
1513
1502
|
return {
|
|
@@ -1560,7 +1549,7 @@ class Node extends rclnodejs.ShadowNode {
|
|
|
1560
1549
|
// detect invalid parameter
|
|
1561
1550
|
try {
|
|
1562
1551
|
parameter.validate();
|
|
1563
|
-
} catch
|
|
1552
|
+
} catch {
|
|
1564
1553
|
return {
|
|
1565
1554
|
successful: false,
|
|
1566
1555
|
reason: `Invalid ${parameter.name}`,
|
|
@@ -1588,7 +1577,7 @@ class Node extends rclnodejs.ShadowNode {
|
|
|
1588
1577
|
if (parameter.type != ParameterType.PARAMETER_NOT_SET) {
|
|
1589
1578
|
try {
|
|
1590
1579
|
descriptor.validateParameter(parameter);
|
|
1591
|
-
} catch
|
|
1580
|
+
} catch {
|
|
1592
1581
|
return {
|
|
1593
1582
|
successful: false,
|
|
1594
1583
|
reason: `Parameter ${parameter.name} does not readonly`,
|
package/lib/parameter.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
/* eslint-disable camelcase */
|
|
2
|
-
|
|
3
1
|
// Copyright (c) 2020 Wayne Parrott. All rights reserved.
|
|
4
2
|
//
|
|
5
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -22,7 +20,6 @@
|
|
|
22
20
|
'use strict';
|
|
23
21
|
|
|
24
22
|
const IsClose = require('is-close');
|
|
25
|
-
const rclnodejs = require('bindings')('rclnodejs');
|
|
26
23
|
|
|
27
24
|
/**
|
|
28
25
|
* The plus/minus tolerance for determining number equivalence.
|
|
@@ -274,7 +271,6 @@ class ParameterDescriptor {
|
|
|
274
271
|
static fromParameter(parameter) {
|
|
275
272
|
const name = parameter.name;
|
|
276
273
|
const type = parameter.type;
|
|
277
|
-
const value = parameter.value;
|
|
278
274
|
return new ParameterDescriptor(name, type, 'Created from parameter.');
|
|
279
275
|
}
|
|
280
276
|
|
|
@@ -387,7 +383,7 @@ class ParameterDescriptor {
|
|
|
387
383
|
return;
|
|
388
384
|
}
|
|
389
385
|
if (!(range instanceof Range)) {
|
|
390
|
-
throw
|
|
386
|
+
throw TypeError('Expected instance of Range.');
|
|
391
387
|
}
|
|
392
388
|
if (!range.isValidType(this.type)) {
|
|
393
389
|
throw TypeError('Incompatible Range');
|
|
@@ -443,14 +439,14 @@ class ParameterDescriptor {
|
|
|
443
439
|
// ensure parameter is valid
|
|
444
440
|
try {
|
|
445
441
|
parameter.validate();
|
|
446
|
-
} catch
|
|
442
|
+
} catch {
|
|
447
443
|
throw new TypeError('Parameter is invalid');
|
|
448
444
|
}
|
|
449
445
|
|
|
450
446
|
// ensure this descriptor is valid
|
|
451
447
|
try {
|
|
452
448
|
this.validate();
|
|
453
|
-
} catch
|
|
449
|
+
} catch {
|
|
454
450
|
throw new Error('Descriptor is invalid.');
|
|
455
451
|
}
|
|
456
452
|
|
|
@@ -567,6 +563,7 @@ class Range {
|
|
|
567
563
|
* @param {ParameterType} parameterType - The parameter type to test.
|
|
568
564
|
* @return {boolean} - True if parameterType is compatible; otherwise return false.
|
|
569
565
|
*/
|
|
566
|
+
// eslint-disable-next-line no-unused-vars
|
|
570
567
|
isValidType(parameterType) {
|
|
571
568
|
return false;
|
|
572
569
|
}
|
|
@@ -702,6 +699,7 @@ class IntegerRange extends Range {
|
|
|
702
699
|
* @param {any} value - The value to infer it's ParameterType
|
|
703
700
|
* @returns {ParameterType} - The ParameterType that best scribes the value.
|
|
704
701
|
*/
|
|
702
|
+
// eslint-disable-next-line no-unused-vars
|
|
705
703
|
function parameterTypeFromValue(value) {
|
|
706
704
|
if (!value) return ParameterType.PARAMETER_NOT_SET;
|
|
707
705
|
if (typeof value === 'boolean') return ParameterType.PARAMETER_BOOL;
|
|
@@ -778,8 +776,7 @@ function validValue(value, type) {
|
|
|
778
776
|
case ParameterType.PARAMETER_INTEGER_ARRAY:
|
|
779
777
|
case ParameterType.PARAMETER_DOUBLE_ARRAY:
|
|
780
778
|
case ParameterType.PARAMETER_STRING_ARRAY:
|
|
781
|
-
|
|
782
|
-
result = _validArray(values, type);
|
|
779
|
+
result = _validArray(value, type);
|
|
783
780
|
break;
|
|
784
781
|
default:
|
|
785
782
|
result = false;
|
package/lib/parameter_service.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable max-depth */
|
|
2
1
|
// Copyright (c) 2020 Wayne Parrott. All rights reserved.
|
|
3
2
|
//
|
|
4
3
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -15,7 +14,6 @@
|
|
|
15
14
|
|
|
16
15
|
'use strict';
|
|
17
16
|
|
|
18
|
-
const rclnodejs = require('bindings')('rclnodejs');
|
|
19
17
|
const { Parameter, PARAMETER_SEPARATOR } = require('./parameter.js');
|
|
20
18
|
|
|
21
19
|
/**
|
|
@@ -27,6 +25,7 @@ const { Parameter, PARAMETER_SEPARATOR } = require('./parameter.js');
|
|
|
27
25
|
* rcl_interfaces/srv/GetParameters
|
|
28
26
|
* rcl_interfaces/srv/SetParameters
|
|
29
27
|
* rcl_interfaces/srv/SetParametersAtomically
|
|
28
|
+
* rcl_interfaces/srv/GetParameterTypes
|
|
30
29
|
*
|
|
31
30
|
* Call start() to begin receiving client request.
|
|
32
31
|
* All service requests are forwarded to the node this service works for.
|
package/lib/publisher.js
CHANGED
|
@@ -38,7 +38,7 @@ class Publisher extends Entity {
|
|
|
38
38
|
/**
|
|
39
39
|
* Publish a message
|
|
40
40
|
* @param {object|Buffer} message - The message to be sent, could be kind of JavaScript message generated from .msg
|
|
41
|
-
*
|
|
41
|
+
* or be a Buffer for a raw message.
|
|
42
42
|
* @return {undefined}
|
|
43
43
|
*/
|
|
44
44
|
publish(message) {
|
package/lib/qos.js
CHANGED
package/lib/rate.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//
|
|
2
1
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
2
|
// you may not use this file except in compliance with the License.
|
|
4
3
|
// You may obtain a copy of the License at
|
|
@@ -166,7 +165,7 @@ class RateTimerServer {
|
|
|
166
165
|
/**
|
|
167
166
|
* Create a new timer instance with callback set to NOP.
|
|
168
167
|
*
|
|
169
|
-
* @param {
|
|
168
|
+
* @param {bigint} period - The period in nanoseconds.
|
|
170
169
|
* @returns {Timer} - The new timer instance.
|
|
171
170
|
*/
|
|
172
171
|
createTimer(period) {
|
package/lib/rmw.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
2
|
+
// you may not use this file except in compliance with the License.
|
|
3
|
+
// You may obtain a copy of the License at
|
|
4
|
+
//
|
|
5
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
//
|
|
7
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
8
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
9
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
10
|
+
// See the License for the specific language governing permissions and
|
|
11
|
+
// limitations under the License.
|
|
12
|
+
|
|
1
13
|
'use strict';
|
|
2
14
|
|
|
3
15
|
const DistroUtils = require('./distro');
|