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/lib/time.js
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
const rclnodejs = require('bindings')('rclnodejs');
|
|
18
18
|
const Duration = require('./duration.js');
|
|
19
19
|
const ClockType = require('./clock_type.js');
|
|
20
|
-
const
|
|
20
|
+
const S_TO_NS = 10n ** 9n;
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
* @class - Class representing a Time in ROS
|
|
@@ -26,16 +26,20 @@ const int64 = require('int64-napi');
|
|
|
26
26
|
class Time {
|
|
27
27
|
/**
|
|
28
28
|
* Create a Time.
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
29
|
+
* @param {bigint} [seconds=0] - The second part of the time.
|
|
30
|
+
* @param {bigint} [nanoseconds=0] - The nanosecond part of the time.
|
|
31
31
|
* @param {ClockType} [clockType=Clock.ClockType.SYSTEM_TIME] - The clock type.
|
|
32
32
|
*/
|
|
33
|
-
constructor(
|
|
34
|
-
|
|
33
|
+
constructor(
|
|
34
|
+
seconds = 0n,
|
|
35
|
+
nanoseconds = 0n,
|
|
36
|
+
clockType = ClockType.SYSTEM_TIME
|
|
37
|
+
) {
|
|
38
|
+
if (typeof seconds !== 'bigint') {
|
|
35
39
|
throw new TypeError('Invalid argument of seconds');
|
|
36
40
|
}
|
|
37
41
|
|
|
38
|
-
if (typeof nanoseconds !== '
|
|
42
|
+
if (typeof nanoseconds !== 'bigint') {
|
|
39
43
|
throw new TypeError('Invalid argument of nanoseconds');
|
|
40
44
|
}
|
|
41
45
|
|
|
@@ -43,25 +47,22 @@ class Time {
|
|
|
43
47
|
throw new TypeError('Invalid argument of clockType');
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
if (
|
|
47
|
-
int64.lt(seconds, 0) ||
|
|
48
|
-
(typeof seconds === 'string' && seconds.startsWith('-'))
|
|
49
|
-
) {
|
|
50
|
+
if (seconds < 0n) {
|
|
50
51
|
throw new RangeError('seconds value must not be negative');
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
if (
|
|
54
|
-
int64.lt(nanoseconds, 0) ||
|
|
55
|
-
(typeof nanoseconds === 'string' && nanoseconds.startsWith('-'))
|
|
56
|
-
) {
|
|
54
|
+
if (nanoseconds < 0n) {
|
|
57
55
|
throw new RangeError('nanoseconds value must not be negative');
|
|
58
56
|
}
|
|
59
57
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
58
|
+
const total = seconds * S_TO_NS + nanoseconds;
|
|
59
|
+
if (total >= 2n ** 63n) {
|
|
60
|
+
throw new RangeError(
|
|
61
|
+
'Total nanoseconds value is too large to store in C time point.'
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
this._nanoseconds = total;
|
|
65
|
+
this._handle = rclnodejs.createTimePoint(this._nanoseconds, clockType);
|
|
65
66
|
this._clockType = clockType;
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -80,22 +81,11 @@ class Time {
|
|
|
80
81
|
* Get the nanosecond part of the time.
|
|
81
82
|
* @name Time#get:nanoseconds
|
|
82
83
|
* @function
|
|
83
|
-
* @return {
|
|
84
|
+
* @return {bigint} - value in nanosecond.
|
|
84
85
|
*/
|
|
85
86
|
|
|
86
87
|
get nanoseconds() {
|
|
87
|
-
|
|
88
|
-
let nano;
|
|
89
|
-
|
|
90
|
-
if (str.startsWith('-')) {
|
|
91
|
-
nano = int64.negative(int64.from(str));
|
|
92
|
-
} else {
|
|
93
|
-
nano = int64.from(str);
|
|
94
|
-
}
|
|
95
|
-
if (Number.isFinite(nano.toNumber())) {
|
|
96
|
-
return nano.toNumber();
|
|
97
|
-
}
|
|
98
|
-
return nano.toString();
|
|
88
|
+
return rclnodejs.getNanoseconds(this._handle);
|
|
99
89
|
}
|
|
100
90
|
|
|
101
91
|
/**
|
|
@@ -106,9 +96,11 @@ class Time {
|
|
|
106
96
|
*/
|
|
107
97
|
|
|
108
98
|
get secondsAndNanoseconds() {
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
99
|
+
const nanoseconds = this._nanoseconds;
|
|
100
|
+
return {
|
|
101
|
+
seconds: nanoseconds / S_TO_NS,
|
|
102
|
+
nanoseconds: nanoseconds % S_TO_NS,
|
|
103
|
+
};
|
|
112
104
|
}
|
|
113
105
|
|
|
114
106
|
/**
|
|
@@ -119,8 +111,8 @@ class Time {
|
|
|
119
111
|
add(other) {
|
|
120
112
|
if (other instanceof Duration) {
|
|
121
113
|
return new Time(
|
|
122
|
-
|
|
123
|
-
|
|
114
|
+
0n,
|
|
115
|
+
this._nanoseconds + other.nanoseconds,
|
|
124
116
|
this._clockType
|
|
125
117
|
);
|
|
126
118
|
}
|
|
@@ -137,14 +129,11 @@ class Time {
|
|
|
137
129
|
if (other._clockType !== this._clockType) {
|
|
138
130
|
throw new TypeError("Can't subtract times with different clock types");
|
|
139
131
|
}
|
|
140
|
-
return new Duration(
|
|
141
|
-
0,
|
|
142
|
-
int64.subtract(this._nanoseconds, other._nanoseconds).toString()
|
|
143
|
-
);
|
|
132
|
+
return new Duration(0n, this._nanoseconds - other._nanoseconds);
|
|
144
133
|
} else if (other instanceof Duration) {
|
|
145
134
|
return new Time(
|
|
146
|
-
|
|
147
|
-
|
|
135
|
+
0n,
|
|
136
|
+
this._nanoseconds - other._nanoseconds,
|
|
148
137
|
this._clockType
|
|
149
138
|
);
|
|
150
139
|
}
|
|
@@ -161,7 +150,7 @@ class Time {
|
|
|
161
150
|
if (other._clockType !== this._clockType) {
|
|
162
151
|
throw new TypeError("Can't compare times with different clock types");
|
|
163
152
|
}
|
|
164
|
-
return this._nanoseconds
|
|
153
|
+
return this._nanoseconds === other.nanoseconds;
|
|
165
154
|
}
|
|
166
155
|
throw new TypeError('Invalid argument');
|
|
167
156
|
}
|
|
@@ -176,7 +165,7 @@ class Time {
|
|
|
176
165
|
if (other._clockType !== this._clockType) {
|
|
177
166
|
throw new TypeError("Can't compare times with different clock types");
|
|
178
167
|
}
|
|
179
|
-
return this._nanoseconds
|
|
168
|
+
return this._nanoseconds !== other.nanoseconds;
|
|
180
169
|
}
|
|
181
170
|
}
|
|
182
171
|
|
|
@@ -190,7 +179,7 @@ class Time {
|
|
|
190
179
|
if (other._clockType !== this._clockType) {
|
|
191
180
|
throw new TypeError("Can't compare times with different clock types");
|
|
192
181
|
}
|
|
193
|
-
return this._nanoseconds
|
|
182
|
+
return this._nanoseconds < other.nanoseconds;
|
|
194
183
|
}
|
|
195
184
|
throw new TypeError('Invalid argument');
|
|
196
185
|
}
|
|
@@ -205,7 +194,7 @@ class Time {
|
|
|
205
194
|
if (other._clockType !== this._clockType) {
|
|
206
195
|
throw new TypeError("Can't compare times with different clock types");
|
|
207
196
|
}
|
|
208
|
-
return this._nanoseconds
|
|
197
|
+
return this._nanoseconds <= other.nanoseconds;
|
|
209
198
|
}
|
|
210
199
|
throw new TypeError('Invalid argument');
|
|
211
200
|
}
|
|
@@ -220,7 +209,7 @@ class Time {
|
|
|
220
209
|
if (other._clockType !== this._clockType) {
|
|
221
210
|
throw new TypeError("Can't compare times with different clock types");
|
|
222
211
|
}
|
|
223
|
-
return this._nanoseconds
|
|
212
|
+
return this._nanoseconds > other.nanoseconds;
|
|
224
213
|
}
|
|
225
214
|
throw new TypeError('Invalid argument');
|
|
226
215
|
}
|
|
@@ -235,7 +224,7 @@ class Time {
|
|
|
235
224
|
if (other._clockType !== this._clockType) {
|
|
236
225
|
throw new TypeError("Can't compare times with different clock types");
|
|
237
226
|
}
|
|
238
|
-
return this._nanoseconds
|
|
227
|
+
return this._nanoseconds >= other.nanoseconds;
|
|
239
228
|
}
|
|
240
229
|
throw new TypeError('Invalid argument');
|
|
241
230
|
}
|
|
@@ -261,7 +250,7 @@ class Time {
|
|
|
261
250
|
* @return {Time} Return the created Time object.
|
|
262
251
|
*/
|
|
263
252
|
static fromMsg(msg, clockType = ClockType.ROS_TIME) {
|
|
264
|
-
return new Time(msg.sec, msg.nanosec, clockType);
|
|
253
|
+
return new Time(BigInt(msg.sec), BigInt(msg.nanosec), clockType);
|
|
265
254
|
}
|
|
266
255
|
}
|
|
267
256
|
|
package/lib/time_source.js
CHANGED
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
const rclnodejs = require('bindings')('rclnodejs');
|
|
18
18
|
const { Clock, ROSClock } = require('./clock.js');
|
|
19
19
|
const { ClockType } = Clock;
|
|
20
|
-
const Node = require('./node.js');
|
|
21
20
|
const { Parameter, ParameterType } = require('./parameter.js');
|
|
22
21
|
const Time = require('./time.js');
|
|
23
22
|
|
|
@@ -37,7 +36,7 @@ class TimeSource {
|
|
|
37
36
|
this._node = node;
|
|
38
37
|
this._associatedClocks = [];
|
|
39
38
|
this._clockSubscription = undefined;
|
|
40
|
-
this._lastTimeSet = new Time(
|
|
39
|
+
this._lastTimeSet = new Time(0n, 0n, ClockType.ROS_TIME);
|
|
41
40
|
this._isRosTimeActive = false;
|
|
42
41
|
|
|
43
42
|
if (this._node) {
|
package/lib/timer.js
CHANGED
|
@@ -29,7 +29,7 @@ class Timer {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
* @type {
|
|
32
|
+
* @type {bigint} - The period of the timer in nanoseconds.
|
|
33
33
|
*/
|
|
34
34
|
get period() {
|
|
35
35
|
return this._period;
|
|
@@ -73,18 +73,18 @@ class Timer {
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Get the interval since the last call of this timer.
|
|
76
|
-
* @return {
|
|
76
|
+
* @return {bigint} - the interval value in nanoseconds.
|
|
77
77
|
*/
|
|
78
78
|
timeSinceLastCall() {
|
|
79
|
-
return
|
|
79
|
+
return rclnodejs.timerGetTimeSinceLastCall(this._handle);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* Get the interval until the next call will happen.
|
|
84
|
-
* @return {
|
|
84
|
+
* @return {bigint} - the interval value in nanoseconds.
|
|
85
85
|
*/
|
|
86
86
|
timeUntilNextCall() {
|
|
87
|
-
return
|
|
87
|
+
return rclnodejs.timerGetTimeUntilNextCall(this._handle);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rclnodejs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "ROS2.0 JavaScript client with Node.js",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -17,15 +17,14 @@
|
|
|
17
17
|
"build:dev": "node-gyp -j 16 build --debug",
|
|
18
18
|
"rebuild": "npm run clean && node-gyp -j 16 rebuild",
|
|
19
19
|
"rebuild:dev": "npm run clean && node-gyp -j 16 rebuild --debug",
|
|
20
|
-
"generate-messages": "node scripts/generate_messages.js",
|
|
21
|
-
"generate-messages:dev": "node scripts/generate_messages.js --debug",
|
|
20
|
+
"generate-messages": "node scripts/generate_messages.js && node scripts/generate_tsd.js",
|
|
21
|
+
"generate-messages:dev": "node scripts/generate_messages.js --debug && node scripts/generate_tsd.js",
|
|
22
22
|
"clean": "node-gyp clean && rimraf ./generated",
|
|
23
23
|
"install": "npm run rebuild",
|
|
24
24
|
"postinstall": "npm run generate-messages",
|
|
25
25
|
"docs": "cd docs && make",
|
|
26
|
-
"test": "node --expose-gc ./scripts/run_test.js &&
|
|
27
|
-
"
|
|
28
|
-
"lint": "eslint --max-warnings=0 --ext js,ts index.js types scripts lib example rosidl_gen rosidl_parser test benchmark/rclnodejs && node ./scripts/cpplint.js",
|
|
26
|
+
"test": "node --expose-gc ./scripts/run_test.js && npx tsd",
|
|
27
|
+
"lint": "eslint && node ./scripts/cpplint.js",
|
|
29
28
|
"format": "clang-format -i -style=file ./src/*.cpp ./src/*.hpp && prettier --write \"{lib,rosidl_gen,rostsd_gen,rosidl_parser,types,example,test,scripts,benchmark}/**/*.{js,md,ts}\" ./*.{js,md,ts}",
|
|
30
29
|
"prepare": "husky"
|
|
31
30
|
},
|
|
@@ -43,48 +42,43 @@
|
|
|
43
42
|
"type": "git",
|
|
44
43
|
"url": "git+https://github.com/RobotWebTools/rclnodejs.git"
|
|
45
44
|
},
|
|
46
|
-
"//": "Pin deep-equal to ^1.1.1",
|
|
47
45
|
"devDependencies": {
|
|
48
|
-
"@
|
|
46
|
+
"@eslint/js": "^10.0.0",
|
|
47
|
+
"@types/node": "^22.13.9",
|
|
49
48
|
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
|
50
49
|
"@typescript-eslint/parser": "^8.18.0",
|
|
51
|
-
"babel-eslint": "^10.1.0",
|
|
52
50
|
"clang-format": "^1.8.0",
|
|
53
51
|
"commander": "^13.1.0",
|
|
54
|
-
"deep-equal": "^
|
|
52
|
+
"deep-equal": "^2.2.3",
|
|
55
53
|
"eslint": "^9.16.0",
|
|
56
|
-
"eslint-config-prettier": "^10.0.
|
|
54
|
+
"eslint-config-prettier": "^10.0.2",
|
|
57
55
|
"eslint-plugin-prettier": "^5.2.1",
|
|
56
|
+
"globals": "^16.0.0",
|
|
58
57
|
"husky": "^9.1.7",
|
|
59
58
|
"jsdoc": "^4.0.4",
|
|
60
59
|
"lint-staged": "^15.2.10",
|
|
61
60
|
"mocha": "^11.0.2",
|
|
61
|
+
"rimraf": "^6.0.1",
|
|
62
62
|
"sinon": "^19.0.2",
|
|
63
63
|
"tree-kill": "^1.2.2",
|
|
64
|
-
"
|
|
64
|
+
"tsd": "^0.31.2",
|
|
65
|
+
"typescript": "^5.7.2",
|
|
66
|
+
"uuid": "^11.0.3"
|
|
65
67
|
},
|
|
66
|
-
"//": "Pin int64-napi to ^1.0.2",
|
|
67
68
|
"dependencies": {
|
|
68
69
|
"@rclnodejs/ref-array-di": "^1.2.2",
|
|
69
70
|
"@rclnodejs/ref-napi": "^4.0.0",
|
|
70
71
|
"@rclnodejs/ref-struct-di": "^1.1.1",
|
|
71
|
-
"array.prototype.flat": "^1.3.2",
|
|
72
72
|
"bindings": "^1.5.0",
|
|
73
73
|
"compare-versions": "^6.1.1",
|
|
74
74
|
"debug": "^4.4.0",
|
|
75
75
|
"dot": "^1.1.3",
|
|
76
|
-
"dtslint": "^4.2.1",
|
|
77
76
|
"fs-extra": "^11.2.0",
|
|
78
|
-
"json-bigint": "^1.0.0",
|
|
79
|
-
"int64-napi": "^1.0.2",
|
|
80
77
|
"is-close": "^1.3.3",
|
|
81
|
-
"
|
|
82
|
-
"mz": "^2.7.0",
|
|
78
|
+
"json-bigint": "^1.0.0",
|
|
83
79
|
"nan": "^2.22.0",
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"walk": "^2.3.15",
|
|
87
|
-
"prettier": "^3.4.2"
|
|
80
|
+
"prettier": "^3.4.2",
|
|
81
|
+
"walk": "^2.3.15"
|
|
88
82
|
},
|
|
89
83
|
"husky": {
|
|
90
84
|
"hooks": {
|
|
@@ -99,6 +93,9 @@
|
|
|
99
93
|
"clang-format -i -style=file"
|
|
100
94
|
]
|
|
101
95
|
},
|
|
96
|
+
"tsd": {
|
|
97
|
+
"directory": "test/types"
|
|
98
|
+
},
|
|
102
99
|
"engines": {
|
|
103
100
|
"node": ">= 16.13.0"
|
|
104
101
|
}
|
package/rosidl_gen/filter.js
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
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
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
1
15
|
const fs = require('fs');
|
|
2
16
|
const path = require('path');
|
|
3
17
|
const os = require('os');
|
|
@@ -73,7 +87,6 @@ const RosPackageFilters = {
|
|
|
73
87
|
|
|
74
88
|
if (!fs.existsSync(blocklistPath)) return;
|
|
75
89
|
|
|
76
|
-
// eslint-disable-next-line
|
|
77
90
|
let blocklistData = JSON.parse(fs.readFileSync(blocklistPath, 'utf8'));
|
|
78
91
|
|
|
79
92
|
let filters = blocklistData.map((pkgFilterData) => {
|
package/rosidl_gen/index.js
CHANGED
|
@@ -14,10 +14,6 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
-
/* eslint-disable max-depth */
|
|
18
|
-
|
|
19
|
-
const debug = require('debug')('rclnodejs:message_translator');
|
|
20
|
-
|
|
21
17
|
function isTypedArray(value) {
|
|
22
18
|
return ArrayBuffer.isView(value) && !(value instanceof DataView);
|
|
23
19
|
}
|
|
@@ -39,7 +35,6 @@ function copyMsgObject(msg, obj) {
|
|
|
39
35
|
// It's an array
|
|
40
36
|
if (typeof obj[i][0] === 'object') {
|
|
41
37
|
// It's an array of objects: converting to ROS message objects
|
|
42
|
-
|
|
43
38
|
// 1. Extract the element-type first
|
|
44
39
|
// 2. Build the array by translate every elements
|
|
45
40
|
let msgArray = [];
|
|
@@ -66,8 +61,7 @@ function copyMsgObject(msg, obj) {
|
|
|
66
61
|
function verifyMessage(message, obj) {
|
|
67
62
|
if (message.constructor.isROSArray) {
|
|
68
63
|
// It's a ROS message array
|
|
69
|
-
//
|
|
70
|
-
|
|
64
|
+
// Note: there won't be any JavaScript array in message.
|
|
71
65
|
if (!Array.isArray(obj)) {
|
|
72
66
|
return false;
|
|
73
67
|
}
|
|
@@ -131,13 +125,12 @@ function toPlainObject(message, enableTypedArray = true) {
|
|
|
131
125
|
|
|
132
126
|
if (message.constructor.isROSArray) {
|
|
133
127
|
// It's a ROS message array
|
|
134
|
-
//
|
|
128
|
+
// Note: there won't be any JavaScript array in message.
|
|
135
129
|
let array = [];
|
|
136
130
|
message.data.forEach((e) => {
|
|
137
131
|
array.push(toPlainObject(e, enableTypedArray)); // Translate every elements
|
|
138
132
|
});
|
|
139
133
|
return array;
|
|
140
|
-
// eslint-disable-next-line no-else-return
|
|
141
134
|
} else {
|
|
142
135
|
// It's a ROS message
|
|
143
136
|
const def = message.constructor.ROSMessageDef;
|
package/rosidl_gen/packages.js
CHANGED
|
@@ -20,7 +20,6 @@ const readline = require('readline');
|
|
|
20
20
|
const path = require('path');
|
|
21
21
|
const walk = require('walk');
|
|
22
22
|
const os = require('os');
|
|
23
|
-
const flat = require('array.prototype.flat');
|
|
24
23
|
const pkgFilters = require('../rosidl_gen/filter.js');
|
|
25
24
|
|
|
26
25
|
const fsp = fs.promises;
|
|
@@ -193,8 +192,7 @@ async function findAmentPackagesInDirectory(dir) {
|
|
|
193
192
|
pkgs.map((pkg) => getPackageDefinitionsFiles(pkg, dir))
|
|
194
193
|
);
|
|
195
194
|
|
|
196
|
-
|
|
197
|
-
const rosFiles = Array.prototype.flat ? files.flat() : flat(files);
|
|
195
|
+
const rosFiles = files.flat();
|
|
198
196
|
const pkgMap = new Map();
|
|
199
197
|
await Promise.all(
|
|
200
198
|
rosFiles.map((filePath) => addInterfaceInfos(filePath, dir, pkgMap))
|
|
@@ -18,8 +18,6 @@ const ref = require('@rclnodejs/ref-napi');
|
|
|
18
18
|
const StructType = require('@rclnodejs/ref-struct-di')(ref);
|
|
19
19
|
const rclnodejs = require('bindings')('rclnodejs');
|
|
20
20
|
|
|
21
|
-
/* eslint-disable camelcase */
|
|
22
|
-
|
|
23
21
|
const StringRefStruct = StructType({
|
|
24
22
|
data: ref.types.CString,
|
|
25
23
|
size: ref.types.size_t,
|
|
@@ -65,5 +63,3 @@ module.exports = {
|
|
|
65
63
|
wstring: StringRefStruct,
|
|
66
64
|
initString: initString,
|
|
67
65
|
};
|
|
68
|
-
|
|
69
|
-
/* eslint-enable camelcase */
|
|
@@ -824,6 +824,10 @@ class {{=arrayWrapper}} {
|
|
|
824
824
|
get classType() {
|
|
825
825
|
return {{=arrayWrapper}};
|
|
826
826
|
}
|
|
827
|
+
|
|
828
|
+
toPlainObject(enableTypedArray) {
|
|
829
|
+
return translator.toPlainObject(this, enableTypedArray);
|
|
830
|
+
}
|
|
827
831
|
}
|
|
828
832
|
|
|
829
833
|
{{? it.spec.constants != undefined && it.spec.constants.length}}
|
package/rostsd_gen/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/* eslint-disable max-depth */
|
|
2
|
-
/* eslint-disable no-sync */
|
|
3
|
-
/* eslint-disable camelcase */
|
|
4
1
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
2
|
// you may not use this file except in compliance with the License.
|
|
6
3
|
// You may obtain a copy of the License at
|
package/scripts/cpplint.js
CHANGED
|
@@ -18,10 +18,9 @@ const exec = require('child_process').exec;
|
|
|
18
18
|
|
|
19
19
|
const cmd = 'wget -nc ';
|
|
20
20
|
const cpplintUrl =
|
|
21
|
-
'https://raw.githubusercontent.com/
|
|
22
|
-
'/gh-pages/cpplint/cpplint.py';
|
|
21
|
+
'https://raw.githubusercontent.com/cpplint/cpplint/refs/heads/develop/cpplint.py';
|
|
23
22
|
const root = `${__dirname}/../src`;
|
|
24
|
-
const args = `--extensions=cpp,h,hpp,cc ${root}/*`;
|
|
23
|
+
const args = `--filter=-build/include_subdir,-whitespace/indent_namespace --extensions=cpp,h,hpp,cc ${root}/*`;
|
|
25
24
|
|
|
26
25
|
console.log('Downloading the cpplint...');
|
|
27
26
|
exec(cmd + cpplintUrl, (err, stdout, stderr) => {
|
|
@@ -29,7 +28,7 @@ exec(cmd + cpplintUrl, (err, stdout, stderr) => {
|
|
|
29
28
|
console.log(`Downloading failed: ${stderr}`);
|
|
30
29
|
} else {
|
|
31
30
|
console.log('Running the cpplint...');
|
|
32
|
-
exec('
|
|
31
|
+
exec('python3 cpplint.py ' + args, (err, stdout, stderr) => {
|
|
33
32
|
console.log(stdout);
|
|
34
33
|
if (err) {
|
|
35
34
|
console.log(stderr);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
/* eslint-disable camelcase */
|
|
4
3
|
// Copyright (c) 2018 Intel Corporation. All rights reserved.
|
|
5
4
|
|
|
6
5
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -15,6 +14,7 @@
|
|
|
15
14
|
// See the License for the specific language governing permissions and
|
|
16
15
|
// limitations under the License.
|
|
17
16
|
|
|
17
|
+
/* eslint-disable camelcase */
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
20
|
const generator = require('../rosidl_gen/index.js');
|
package/scripts/npmjs-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
|
|
package/scripts/ros_distro.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('../lib/distro');
|
package/scripts/run_test.js
CHANGED
package/src/executor.hpp
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
|
|
15
|
-
#ifndef
|
|
16
|
-
#define
|
|
15
|
+
#ifndef SRC_EXECUTOR_HPP_
|
|
16
|
+
#define SRC_EXECUTOR_HPP_
|
|
17
17
|
|
|
18
18
|
#include <rcl/wait.h>
|
|
19
19
|
#include <uv.h>
|
|
@@ -74,4 +74,4 @@ class Executor {
|
|
|
74
74
|
|
|
75
75
|
} // namespace rclnodejs
|
|
76
76
|
|
|
77
|
-
#endif
|
|
77
|
+
#endif // SRC_EXECUTOR_HPP_
|
package/src/handle_manager.hpp
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
|
|
15
|
-
#ifndef
|
|
16
|
-
#define
|
|
15
|
+
#ifndef SRC_HANDLE_MANAGER_HPP_
|
|
16
|
+
#define SRC_HANDLE_MANAGER_HPP_
|
|
17
17
|
|
|
18
18
|
#include <nan.h>
|
|
19
19
|
#include <rcl/wait.h>
|
|
@@ -132,4 +132,4 @@ class HandleManager {
|
|
|
132
132
|
|
|
133
133
|
} // namespace rclnodejs
|
|
134
134
|
|
|
135
|
-
#endif
|
|
135
|
+
#endif // SRC_HANDLE_MANAGER_HPP_
|
package/src/macros.hpp
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
|
|
15
|
-
#ifndef
|
|
16
|
-
#define
|
|
15
|
+
#ifndef SRC_MACROS_HPP_
|
|
16
|
+
#define SRC_MACROS_HPP_
|
|
17
17
|
|
|
18
18
|
#include "rcutils/logging_macros.h"
|
|
19
19
|
|
|
@@ -43,4 +43,4 @@
|
|
|
43
43
|
#define RCLNODEJS_DEBUG(...)
|
|
44
44
|
#endif
|
|
45
45
|
|
|
46
|
-
#endif
|
|
46
|
+
#endif // SRC_MACROS_HPP_
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
14
|
|
|
15
|
-
#ifndef
|
|
16
|
-
#define
|
|
15
|
+
#ifndef SRC_RCL_ACTION_BINDINGS_HPP_
|
|
16
|
+
#define SRC_RCL_ACTION_BINDINGS_HPP_
|
|
17
17
|
|
|
18
18
|
#include <nan.h>
|
|
19
19
|
#include <rcl/rcl.h>
|
|
@@ -28,4 +28,4 @@ extern std::vector<BindingMethod> action_binding_methods;
|
|
|
28
28
|
|
|
29
29
|
} // namespace rclnodejs
|
|
30
30
|
|
|
31
|
-
#endif
|
|
31
|
+
#endif // SRC_RCL_ACTION_BINDINGS_HPP_
|