rclnodejs 0.21.2 → 0.21.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/CONTRIBUTORS.md +6 -2
- package/README.md +1 -1
- package/index.js +8 -4
- package/lib/action/client.js +6 -20
- package/lib/action/server.js +1 -1
- package/lib/action/uuid.js +28 -1
- package/lib/interface_loader.js +1 -1
- package/package.json +1 -1
- package/scripts/npmjs-readme.md +1 -1
- package/types/action_server.d.ts +6 -4
- package/types/action_uuid.d.ts +58 -0
- package/types/base.d.ts +1 -0
package/CONTRIBUTORS.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
rclnodejs contributors (sorted alphabetically)
|
|
2
2
|
==============================================
|
|
3
3
|
|
|
4
|
+
* **[Alaa El Jawad](https://github.com/ejalaa12), [Ian McElroy](https://github.com/imcelroy)**
|
|
5
|
+
- Fix compatibility with ROS2 parameters array types
|
|
6
|
+
- Unit tests for all parameter types
|
|
7
|
+
- Handle concurrent ROS2 client calls, with unit tests
|
|
8
|
+
|
|
4
9
|
* **[Alex Mikhalev](https://github.com/amikhalev)**
|
|
5
10
|
* Fix build for AMENT_PREFIX_PATH with multiple entries
|
|
6
11
|
|
|
@@ -13,7 +18,7 @@ rclnodejs contributors (sorted alphabetically)
|
|
|
13
18
|
* Benchmark test script
|
|
14
19
|
|
|
15
20
|
* **[Kenny Yuan](https://github.com/kenny-y)**
|
|
16
|
-
* Message features: JS generation, typed arrays, plain JS object, compound msgs, many others...
|
|
21
|
+
* Message features: JS generation, typed arrays, plain JS object, compound msgs, many others...
|
|
17
22
|
* npm publish scripts
|
|
18
23
|
* Mac support
|
|
19
24
|
|
|
@@ -47,4 +52,3 @@ rclnodejs contributors (sorted alphabetically)
|
|
|
47
52
|
* ROS2 lifecycle node
|
|
48
53
|
* Rate class
|
|
49
54
|
* Node class hierarchy
|
|
50
|
-
|
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ npm i rclnodejs@x.y.z
|
|
|
45
45
|
|
|
46
46
|
| RCLNODEJS Version | Compatible ROS 2 Release |
|
|
47
47
|
| :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
48
|
-
| [0.21.
|
|
48
|
+
| [0.21.3 (current)](https://www.npmjs.com/package/rclnodejs/v/0.21.3) ([API](http://robotwebtools.org/rclnodejs/docs/0.21.3/index.html)) | [Humble Hawksbill](https://github.com/ros2/ros2/releases/tag/release-humble-20220523)<br>[Galactic Geochelone](https://github.com/ros2/ros2/releases/tag/release-galactic-20210716)<br>[Foxy Fitzroy](https://github.com/ros2/ros2/releases/tag/release-foxy-20201211)<br>[Eloquent Elusor](https://github.com/ros2/ros2/releases/tag/release-eloquent-20200124) |
|
|
49
49
|
| [0.10.3](https://github.com/RobotWebTools/rclnodejs/releases/tag/0.10.3) | [Dashing Diademata - Patch 4](https://github.com/ros2/ros2/releases/tag/release-dashing-20191018) |
|
|
50
50
|
|
|
51
51
|
## Documentation
|
package/index.js
CHANGED
|
@@ -42,6 +42,7 @@ const validator = require('./lib/validator.js');
|
|
|
42
42
|
const Time = require('./lib/time.js');
|
|
43
43
|
const ActionClient = require('./lib/action/client.js');
|
|
44
44
|
const ActionServer = require('./lib/action/server.js');
|
|
45
|
+
const ActionUuid = require('./lib/action/uuid.js');
|
|
45
46
|
const ClientGoalHandle = require('./lib/action/client_goal_handle.js');
|
|
46
47
|
const { CancelResponse, GoalResponse } = require('./lib/action/response.js');
|
|
47
48
|
const ServerGoalHandle = require('./lib/action/server_goal_handle.js');
|
|
@@ -80,13 +81,13 @@ async function getCurrentGeneratorVersion() {
|
|
|
80
81
|
});
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
let _rosVersionChecked = false;
|
|
85
|
+
|
|
83
86
|
/**
|
|
84
87
|
* A module that exposes the rclnodejs interfaces.
|
|
85
88
|
* @exports rclnodejs
|
|
86
89
|
*/
|
|
87
90
|
let rcl = {
|
|
88
|
-
_rosVersionChecked: false,
|
|
89
|
-
|
|
90
91
|
/** {@link Clock} class */
|
|
91
92
|
Clock: Clock,
|
|
92
93
|
|
|
@@ -150,6 +151,9 @@ let rcl = {
|
|
|
150
151
|
/** {@link ActionServer} class */
|
|
151
152
|
ActionServer: ActionServer,
|
|
152
153
|
|
|
154
|
+
/** {@link ActionUuid} class */
|
|
155
|
+
ActionUuid: ActionUuid,
|
|
156
|
+
|
|
153
157
|
/** {@link ClientGoalHandle} class */
|
|
154
158
|
ClientGoalHandle: ClientGoalHandle,
|
|
155
159
|
|
|
@@ -245,7 +249,7 @@ let rcl = {
|
|
|
245
249
|
|
|
246
250
|
rclnodejs.init(context.handle, argv);
|
|
247
251
|
|
|
248
|
-
if (
|
|
252
|
+
if (_rosVersionChecked) {
|
|
249
253
|
// no further processing required
|
|
250
254
|
return;
|
|
251
255
|
}
|
|
@@ -262,7 +266,7 @@ let rcl = {
|
|
|
262
266
|
|
|
263
267
|
await generator.generateAll(forced);
|
|
264
268
|
// TODO determine if tsd generateAll() should be here
|
|
265
|
-
|
|
269
|
+
_rosVersionChecked = true;
|
|
266
270
|
},
|
|
267
271
|
|
|
268
272
|
/**
|
package/lib/action/client.js
CHANGED
|
@@ -100,7 +100,7 @@ class ActionClient extends Entity {
|
|
|
100
100
|
);
|
|
101
101
|
|
|
102
102
|
if (goalHandle.accepted) {
|
|
103
|
-
let uuid = ActionUuid.
|
|
103
|
+
let uuid = ActionUuid.fromMessage(goalHandle.goalId).toString();
|
|
104
104
|
if (this._goalHandles.has(uuid)) {
|
|
105
105
|
throw new Error(`Two goals were accepted with the same ID (${uuid})`);
|
|
106
106
|
}
|
|
@@ -150,7 +150,7 @@ class ActionClient extends Entity {
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
processFeedbackMessage(message) {
|
|
153
|
-
let uuid = ActionUuid.
|
|
153
|
+
let uuid = ActionUuid.fromMessage(message.goal_id).toString();
|
|
154
154
|
if (this._feedbackCallbacks.has(uuid)) {
|
|
155
155
|
this._feedbackCallbacks.get(uuid)(
|
|
156
156
|
message.toPlainObject(this.typedArrayEnabled).feedback
|
|
@@ -161,8 +161,8 @@ class ActionClient extends Entity {
|
|
|
161
161
|
processStatusMessage(message) {
|
|
162
162
|
// Update the status of all goal handles maintained by this Action Client
|
|
163
163
|
for (const statusMessage of message.status_list.data) {
|
|
164
|
-
let uuid = ActionUuid.
|
|
165
|
-
statusMessage.goal_info.goal_id
|
|
164
|
+
let uuid = ActionUuid.fromMessage(
|
|
165
|
+
statusMessage.goal_info.goal_id
|
|
166
166
|
).toString();
|
|
167
167
|
let status = statusMessage.status;
|
|
168
168
|
|
|
@@ -200,7 +200,7 @@ class ActionClient extends Entity {
|
|
|
200
200
|
*/
|
|
201
201
|
sendGoal(goal, feedbackCallback, goalUuid) {
|
|
202
202
|
let request = new this._typeClass.impl.SendGoalService.Request();
|
|
203
|
-
request['goal_id'] = goalUuid ||
|
|
203
|
+
request['goal_id'] = goalUuid || ActionUuid.randomMessage();
|
|
204
204
|
request.goal = goal;
|
|
205
205
|
|
|
206
206
|
let sequenceNumber = rclnodejs.actionSendGoalRequest(
|
|
@@ -215,7 +215,7 @@ class ActionClient extends Entity {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
if (feedbackCallback) {
|
|
218
|
-
let uuid = ActionUuid.
|
|
218
|
+
let uuid = ActionUuid.fromMessage(request.goal_id).toString();
|
|
219
219
|
this._feedbackCallbacks.set(uuid, feedbackCallback);
|
|
220
220
|
}
|
|
221
221
|
|
|
@@ -345,20 +345,6 @@ class ActionClient extends Entity {
|
|
|
345
345
|
return deferred.promise;
|
|
346
346
|
}
|
|
347
347
|
|
|
348
|
-
/**
|
|
349
|
-
* Creates a new random UUID message.
|
|
350
|
-
* @ignore
|
|
351
|
-
* @returns {object} - The new UUID message.
|
|
352
|
-
*/
|
|
353
|
-
_createRandomUuid() {
|
|
354
|
-
let uuid = ActionUuid.random();
|
|
355
|
-
|
|
356
|
-
let uuidMsg = new ActionInterfaces.UUID();
|
|
357
|
-
uuidMsg.uuid = uuid.bytes;
|
|
358
|
-
|
|
359
|
-
return uuidMsg;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
348
|
_removePendingGoalRequest(sequenceNumber) {
|
|
363
349
|
this._pendingGoalRequests.delete(sequenceNumber);
|
|
364
350
|
this._sequenceNumberGoalIdMap.delete(sequenceNumber);
|
package/lib/action/server.js
CHANGED
|
@@ -190,7 +190,7 @@ class ActionServer extends Entity {
|
|
|
190
190
|
*
|
|
191
191
|
* The purpose of the cancel callback is to decide if a request to cancel an on-going
|
|
192
192
|
* (or queued) goal should be accepted or rejected.
|
|
193
|
-
* The callback should take one parameter containing the cancel request and must return a
|
|
193
|
+
* The callback should take one parameter containing the cancel request (a goal handle) and must return a
|
|
194
194
|
* {@link CancelResponse} value.
|
|
195
195
|
*
|
|
196
196
|
* There can only be one cancel callback per {@link ActionServer}, therefore calling this
|
package/lib/action/uuid.js
CHANGED
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
|
|
15
15
|
'use strict';
|
|
16
16
|
|
|
17
|
+
const ActionInterfaces = require('./interfaces.js');
|
|
17
18
|
const { v4: uuidv4 } = require('uuid');
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* @class - Represents a unique identifier used by actions.
|
|
21
22
|
* @ignore
|
|
22
23
|
*/
|
|
23
|
-
|
|
24
24
|
class ActionUuid {
|
|
25
25
|
/**
|
|
26
26
|
* Creates a new instance of ActionUuid.
|
|
@@ -73,6 +73,33 @@ class ActionUuid {
|
|
|
73
73
|
toString() {
|
|
74
74
|
return [].slice.call(this._bytes).join(',');
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Create an instance from a ROS2 UUID message
|
|
79
|
+
* @param {unique_identifier_msgs.msg.UUID} msg - The ROS2 UUID message
|
|
80
|
+
* @returns {ActionUuid} - The new instance.
|
|
81
|
+
*/
|
|
82
|
+
static fromMessage(msg) {
|
|
83
|
+
return ActionUuid.fromBytes(msg.uuid);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Create a ROS2 UUID message from this instance.
|
|
88
|
+
* @returns {unique_identifier_msgs.msg.UUID} - The new ROS2 UUID message
|
|
89
|
+
*/
|
|
90
|
+
toMessage() {
|
|
91
|
+
const uuidMsg = new ActionInterfaces.UUID();
|
|
92
|
+
uuidMsg.uuid = this.bytes;
|
|
93
|
+
return uuidMsg;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Create a ROS2 UUID message with random uuid data
|
|
98
|
+
* @returns {ActionUuid} - The new instance.
|
|
99
|
+
*/
|
|
100
|
+
static randomMessage() {
|
|
101
|
+
return ActionUuid.random().toMessage();
|
|
102
|
+
}
|
|
76
103
|
}
|
|
77
104
|
|
|
78
105
|
module.exports = ActionUuid;
|
package/lib/interface_loader.js
CHANGED
|
@@ -114,7 +114,7 @@ let interfaceLoader = {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
throw new Error(
|
|
117
|
-
`The message required does not exist: ${packageName}, ${type}, ${messageName}`
|
|
117
|
+
`The message required does not exist: ${packageName}, ${type}, ${messageName} at ${generator.generatedRoot}`
|
|
118
118
|
);
|
|
119
119
|
},
|
|
120
120
|
};
|
package/package.json
CHANGED
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 Release |
|
|
47
47
|
| :-------------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|
|
48
|
-
| [0.21.
|
|
48
|
+
| [0.21.3 (current)](https://www.npmjs.com/package/rclnodejs/v/0.21.3) ([API](http://robotwebtools.org/rclnodejs/docs/0.21.3/index.html)) | [Humble Hawksbill](https://github.com/ros2/ros2/releases/tag/release-humble-20220523)<br>[Galactic Geochelone](https://github.com/ros2/ros2/releases/tag/release-galactic-20210716)<br>[Foxy Fitzroy](https://github.com/ros2/ros2/releases/tag/release-foxy-20201211)<br>[Eloquent Elusor](https://github.com/ros2/ros2/releases/tag/release-eloquent-20200124) |
|
|
49
49
|
| [0.10.3](https://github.com/RobotWebTools/rclnodejs/releases/tag/0.10.3) | [Dashing Diademata - Patch 4](https://github.com/ros2/ros2/releases/tag/release-dashing-20191018) |
|
|
50
50
|
|
|
51
51
|
## Documentation
|
package/types/action_server.d.ts
CHANGED
|
@@ -84,7 +84,9 @@ declare module 'rclnodejs' {
|
|
|
84
84
|
type HandleAcceptedCallback<T extends TypeClass<ActionTypeClassName>> = (
|
|
85
85
|
goalHandle: ServerGoalHandle<T>
|
|
86
86
|
) => void;
|
|
87
|
-
type CancelCallback
|
|
87
|
+
type CancelCallback<T extends TypeClass<ActionTypeClassName>> = (
|
|
88
|
+
goalHandle?: ServerGoalHandle<T>
|
|
89
|
+
) => Promise<CancelResponse> | CancelResponse;
|
|
88
90
|
|
|
89
91
|
interface ActionServerOptions extends Options<ActionQoS> {
|
|
90
92
|
/**
|
|
@@ -116,7 +118,7 @@ declare module 'rclnodejs' {
|
|
|
116
118
|
executeCallback: ExecuteCallback<T>,
|
|
117
119
|
goalCallback?: GoalCallback<T>,
|
|
118
120
|
handleAcceptedCallback?: HandleAcceptedCallback<T>,
|
|
119
|
-
cancelCallback?: CancelCallback
|
|
121
|
+
cancelCallback?: CancelCallback<T>,
|
|
120
122
|
options?: ActionServerOptions
|
|
121
123
|
);
|
|
122
124
|
|
|
@@ -153,14 +155,14 @@ declare module 'rclnodejs' {
|
|
|
153
155
|
*
|
|
154
156
|
* The purpose of the cancel callback is to decide if a request to cancel an on-going
|
|
155
157
|
* (or queued) goal should be accepted or rejected.
|
|
156
|
-
* The callback should take one parameter containing the cancel request and must return a
|
|
158
|
+
* The callback should take one parameter containing the cancel request ( a GoalHandle) and must return a
|
|
157
159
|
* {@link CancelResponse} value.
|
|
158
160
|
*
|
|
159
161
|
* There can only be one cancel callback per {@link ActionServer}, therefore calling this
|
|
160
162
|
* function will replace any previously registered callback.
|
|
161
163
|
* @param cancelCallback - Callback function, if not provided, then unregisters any previously registered callback.
|
|
162
164
|
*/
|
|
163
|
-
registerCancelCallback(cancelCallback?: CancelCallback): void;
|
|
165
|
+
registerCancelCallback(cancelCallback?: CancelCallback<T>): void;
|
|
164
166
|
|
|
165
167
|
/**
|
|
166
168
|
* Register a callback for executing action goals.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
declare module 'rclnodejs' {
|
|
2
|
+
/**
|
|
3
|
+
* @class - Represents a unique identifier used by actions.
|
|
4
|
+
* @ignore
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export class ActionUuid {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new instance of ActionUuid.
|
|
10
|
+
* @param bytes - The bytes to create the UUID from.
|
|
11
|
+
* A new random UUID will be created, if not provided.
|
|
12
|
+
*/
|
|
13
|
+
constructor(bytes?: Uint8Array);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a new {@link ActionUuid} from the given bytes.
|
|
17
|
+
* @param bytes - The bytes to create the UUID from.
|
|
18
|
+
* @returns The new UUID.
|
|
19
|
+
*/
|
|
20
|
+
static fromBytes(byte: Uint8Array): ActionUuid;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new random {@link ActionUuid}.
|
|
24
|
+
* @returns The new UUID.
|
|
25
|
+
*/
|
|
26
|
+
static random(): ActionUuid;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Gets the bytes from the UUID.
|
|
30
|
+
*/
|
|
31
|
+
get bytes(): Uint8Array;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Returns the UUID as a string.
|
|
35
|
+
* @returns String representation of the UUID.
|
|
36
|
+
*/
|
|
37
|
+
toString(): string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Create an instance from a ROS2 UUID message
|
|
41
|
+
* @param msg - The ROS2 UUID message
|
|
42
|
+
* @returns The new instance.
|
|
43
|
+
*/
|
|
44
|
+
static fromMessage(msg: unique_identifier_msgs.msg.UUID): ActionUuid;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Create a ROS2 UUID message from this instance.
|
|
48
|
+
* @returns The new ROS2 UUID message
|
|
49
|
+
*/
|
|
50
|
+
toMessage(): unique_identifier_msgs.msg.UUID;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Create a ROS2 UUID message with random uuid data
|
|
54
|
+
* @returns The new instance.
|
|
55
|
+
*/
|
|
56
|
+
static randomMessage(): unique_identifier_msgs.msg.UUID;
|
|
57
|
+
}
|
|
58
|
+
}
|
package/types/base.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* eslint-disable spaced-comment */
|
|
2
2
|
/// <reference path="action_client.d.ts" />
|
|
3
3
|
/// <reference path="action_server.d.ts" />
|
|
4
|
+
/// <reference path="action_uuid.d.ts" />
|
|
4
5
|
/// <reference path="client.d.ts" />
|
|
5
6
|
/// <reference path="clock_type.d.ts" />
|
|
6
7
|
/// <reference path="clock.d.ts" />
|