rclnodejs 1.6.0 → 1.8.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/binding.gyp +2 -0
- package/index.js +152 -0
- package/lib/action/client.js +109 -10
- package/lib/action/deferred.js +8 -2
- package/lib/action/server.js +10 -1
- package/lib/action/uuid.js +4 -1
- package/lib/client.js +218 -4
- package/lib/clock.js +182 -1
- package/lib/clock_change.js +49 -0
- package/lib/clock_event.js +88 -0
- package/lib/context.js +12 -2
- package/lib/duration.js +37 -12
- package/lib/errors.js +621 -0
- package/lib/event_handler.js +21 -4
- package/lib/interface_loader.js +52 -12
- package/lib/lifecycle.js +8 -2
- package/lib/logging.js +90 -3
- package/lib/message_introspector.js +123 -0
- package/lib/message_serialization.js +10 -2
- package/lib/message_validation.js +512 -0
- package/lib/native_loader.js +9 -4
- package/lib/node.js +403 -50
- package/lib/node_options.js +40 -1
- package/lib/observable_subscription.js +105 -0
- package/lib/parameter.js +172 -35
- package/lib/parameter_client.js +506 -0
- package/lib/parameter_watcher.js +309 -0
- package/lib/publisher.js +56 -1
- package/lib/qos.js +79 -5
- package/lib/rate.js +6 -1
- package/lib/serialization.js +7 -2
- package/lib/subscription.js +8 -0
- package/lib/time.js +136 -21
- package/lib/time_source.js +13 -4
- package/lib/timer.js +42 -0
- package/lib/utils.js +27 -1
- package/lib/validator.js +74 -19
- package/package.json +4 -2
- package/prebuilds/linux-arm64/humble-jammy-arm64-rclnodejs.node +0 -0
- package/prebuilds/linux-arm64/jazzy-noble-arm64-rclnodejs.node +0 -0
- package/prebuilds/linux-arm64/kilted-noble-arm64-rclnodejs.node +0 -0
- package/prebuilds/linux-x64/humble-jammy-x64-rclnodejs.node +0 -0
- package/prebuilds/linux-x64/jazzy-noble-x64-rclnodejs.node +0 -0
- package/prebuilds/linux-x64/kilted-noble-x64-rclnodejs.node +0 -0
- package/rosidl_gen/message_translator.js +0 -61
- package/scripts/config.js +1 -0
- package/src/addon.cpp +2 -0
- package/src/clock_event.cpp +268 -0
- package/src/clock_event.hpp +62 -0
- package/src/macros.h +2 -4
- package/src/rcl_action_server_bindings.cpp +21 -3
- package/src/rcl_bindings.cpp +59 -0
- package/src/rcl_context_bindings.cpp +5 -0
- package/src/rcl_graph_bindings.cpp +73 -0
- package/src/rcl_logging_bindings.cpp +158 -0
- package/src/rcl_node_bindings.cpp +14 -2
- package/src/rcl_publisher_bindings.cpp +12 -0
- package/src/rcl_service_bindings.cpp +7 -6
- package/src/rcl_subscription_bindings.cpp +51 -14
- package/src/rcl_time_point_bindings.cpp +135 -0
- package/src/rcl_timer_bindings.cpp +140 -0
- package/src/rcl_utilities.cpp +103 -2
- package/src/rcl_utilities.h +7 -1
- package/types/action_client.d.ts +27 -2
- package/types/base.d.ts +6 -0
- package/types/client.d.ts +65 -1
- package/types/clock.d.ts +86 -0
- package/types/clock_change.d.ts +27 -0
- package/types/clock_event.d.ts +51 -0
- package/types/errors.d.ts +496 -0
- package/types/index.d.ts +10 -0
- package/types/logging.d.ts +32 -0
- package/types/message_introspector.d.ts +75 -0
- package/types/message_validation.d.ts +183 -0
- package/types/node.d.ts +107 -0
- package/types/node_options.d.ts +13 -0
- package/types/observable_subscription.d.ts +39 -0
- package/types/parameter_client.d.ts +252 -0
- package/types/parameter_watcher.d.ts +104 -0
- package/types/publisher.d.ts +28 -1
- package/types/qos.d.ts +18 -0
- package/types/subscription.d.ts +6 -0
- package/types/timer.d.ts +18 -0
- package/types/validator.d.ts +86 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
declare module 'rclnodejs' {
|
|
2
|
+
/**
|
|
3
|
+
* Class representing a ClockEvent in ROS
|
|
4
|
+
*/
|
|
5
|
+
class ClockEvent {
|
|
6
|
+
/**
|
|
7
|
+
* Create a ClockEvent.
|
|
8
|
+
*/
|
|
9
|
+
constructor();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wait until a time specified by a steady clock.
|
|
13
|
+
* @param clock - The clock to use for time synchronization.
|
|
14
|
+
* @param until - The time to wait until.
|
|
15
|
+
* @returns A promise that resolves when the time is reached.
|
|
16
|
+
*/
|
|
17
|
+
waitUntilSteady(clock: Clock, until: bigint): Promise<void>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Wait until a time specified by a system clock.
|
|
21
|
+
* @param clock - The clock to use for time synchronization.
|
|
22
|
+
* @param until - The time to wait until.
|
|
23
|
+
* @returns A promise that resolves when the time is reached.
|
|
24
|
+
*/
|
|
25
|
+
waitUntilSystem(clock: Clock, until: bigint): Promise<void>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Wait until a time specified by a ROS clock.
|
|
29
|
+
* @param clock - The clock to use for time synchronization.
|
|
30
|
+
* @param until - The time to wait until.
|
|
31
|
+
* @returns A promise that resolves when the time is reached.
|
|
32
|
+
*/
|
|
33
|
+
waitUntilRos(clock: Clock, until: bigint): Promise<void>;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Indicate if the ClockEvent is set.
|
|
37
|
+
* @returns True if the ClockEvent is set.
|
|
38
|
+
*/
|
|
39
|
+
isSet(): boolean;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Set the event.
|
|
43
|
+
*/
|
|
44
|
+
set(): void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Clear the event.
|
|
48
|
+
*/
|
|
49
|
+
clear(): void;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
// Copyright (c) 2025 Mahmoud Alghalayini. All rights reserved.
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
|
|
15
|
+
declare module 'rclnodejs' {
|
|
16
|
+
/**
|
|
17
|
+
* Options for RclNodeError constructor
|
|
18
|
+
*/
|
|
19
|
+
export interface RclNodeErrorOptions {
|
|
20
|
+
/** Machine-readable error code (e.g., 'TIMEOUT', 'INVALID_ARGUMENT') */
|
|
21
|
+
code?: string;
|
|
22
|
+
/** Name of the node where error occurred */
|
|
23
|
+
nodeName?: string;
|
|
24
|
+
/** Type of entity (publisher, subscription, client, etc.) */
|
|
25
|
+
entityType?: string;
|
|
26
|
+
/** Name of the entity (topic name, service name, etc.) */
|
|
27
|
+
entityName?: string;
|
|
28
|
+
/** Original error that caused this error */
|
|
29
|
+
cause?: Error;
|
|
30
|
+
/** Additional error-specific details */
|
|
31
|
+
details?: any;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Base error class for all rclnodejs errors.
|
|
36
|
+
* Provides structured error information with context.
|
|
37
|
+
*/
|
|
38
|
+
export class RclNodeError extends Error {
|
|
39
|
+
/** Error code for machine-readable error identification */
|
|
40
|
+
code: string;
|
|
41
|
+
/** Name of the node where error occurred */
|
|
42
|
+
nodeName?: string;
|
|
43
|
+
/** Type of entity (publisher, subscription, client, etc.) */
|
|
44
|
+
entityType?: string;
|
|
45
|
+
/** Name of the entity (topic name, service name, etc.) */
|
|
46
|
+
entityName?: string;
|
|
47
|
+
/** Additional error-specific details */
|
|
48
|
+
details?: any;
|
|
49
|
+
/** Original error that caused this error */
|
|
50
|
+
cause?: Error;
|
|
51
|
+
/** Timestamp when error was created */
|
|
52
|
+
timestamp: Date;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* @param message - Human-readable error message
|
|
56
|
+
* @param options - Additional error context
|
|
57
|
+
*/
|
|
58
|
+
constructor(message: string, options?: RclNodeErrorOptions);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Returns a detailed error object for logging/serialization
|
|
62
|
+
*/
|
|
63
|
+
toJSON(): {
|
|
64
|
+
name: string;
|
|
65
|
+
message: string;
|
|
66
|
+
code: string;
|
|
67
|
+
nodeName?: string;
|
|
68
|
+
entityType?: string;
|
|
69
|
+
entityName?: string;
|
|
70
|
+
details?: any;
|
|
71
|
+
timestamp: string;
|
|
72
|
+
stack?: string;
|
|
73
|
+
cause?: any;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns a user-friendly error description
|
|
78
|
+
*/
|
|
79
|
+
toString(): string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Options for ValidationError constructor
|
|
84
|
+
*/
|
|
85
|
+
export interface ValidationErrorOptions extends RclNodeErrorOptions {
|
|
86
|
+
/** Name of the argument that failed validation */
|
|
87
|
+
argumentName?: string;
|
|
88
|
+
/** The value that was provided */
|
|
89
|
+
providedValue?: any;
|
|
90
|
+
/** The expected type or format */
|
|
91
|
+
expectedType?: string;
|
|
92
|
+
/** The validation rule that failed */
|
|
93
|
+
validationRule?: string;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Error thrown when validation fails
|
|
98
|
+
*/
|
|
99
|
+
export class ValidationError extends RclNodeError {
|
|
100
|
+
/** Name of the argument that failed validation */
|
|
101
|
+
argumentName?: string;
|
|
102
|
+
/** The value that was provided */
|
|
103
|
+
providedValue?: any;
|
|
104
|
+
/** The expected type or format */
|
|
105
|
+
expectedType?: string;
|
|
106
|
+
/** The validation rule that failed */
|
|
107
|
+
validationRule?: string;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @param message - Error message
|
|
111
|
+
* @param options - Additional options
|
|
112
|
+
*/
|
|
113
|
+
constructor(message: string, options?: ValidationErrorOptions);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Type validation error
|
|
118
|
+
*/
|
|
119
|
+
export class TypeValidationError extends ValidationError {
|
|
120
|
+
/**
|
|
121
|
+
* @param argumentName - Name of the argument
|
|
122
|
+
* @param providedValue - The value that was provided
|
|
123
|
+
* @param expectedType - The expected type
|
|
124
|
+
* @param options - Additional options
|
|
125
|
+
*/
|
|
126
|
+
constructor(
|
|
127
|
+
argumentName: string,
|
|
128
|
+
providedValue: any,
|
|
129
|
+
expectedType: string,
|
|
130
|
+
options?: RclNodeErrorOptions
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Range/value validation error
|
|
136
|
+
*/
|
|
137
|
+
export class RangeValidationError extends ValidationError {
|
|
138
|
+
/**
|
|
139
|
+
* @param argumentName - Name of the argument
|
|
140
|
+
* @param providedValue - The value that was provided
|
|
141
|
+
* @param constraint - The constraint that was violated
|
|
142
|
+
* @param options - Additional options
|
|
143
|
+
*/
|
|
144
|
+
constructor(
|
|
145
|
+
argumentName: string,
|
|
146
|
+
providedValue: any,
|
|
147
|
+
constraint: string,
|
|
148
|
+
options?: RclNodeErrorOptions
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* A single validation issue found during message validation
|
|
154
|
+
*/
|
|
155
|
+
export interface MessageValidationIssue {
|
|
156
|
+
/** Field path where issue occurred (e.g., 'linear.x' or 'data') */
|
|
157
|
+
field: string;
|
|
158
|
+
/** Problem type (UNKNOWN_FIELD, TYPE_MISMATCH, etc.) */
|
|
159
|
+
problem: string;
|
|
160
|
+
/** Expected type or value */
|
|
161
|
+
expected?: string;
|
|
162
|
+
/** Actual value received */
|
|
163
|
+
received?: any;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Message validation error for ROS message structure/type issues
|
|
168
|
+
*/
|
|
169
|
+
export class MessageValidationError extends ValidationError {
|
|
170
|
+
/** The ROS message type (e.g., 'std_msgs/msg/String') */
|
|
171
|
+
messageType: string;
|
|
172
|
+
/** Array of validation issues found */
|
|
173
|
+
issues: MessageValidationIssue[];
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @param messageType - The ROS message type
|
|
177
|
+
* @param issues - Array of validation issues
|
|
178
|
+
* @param options - Additional options
|
|
179
|
+
*/
|
|
180
|
+
constructor(
|
|
181
|
+
messageType: string,
|
|
182
|
+
issues: MessageValidationIssue[],
|
|
183
|
+
options?: RclNodeErrorOptions
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Get issues filtered by problem type
|
|
188
|
+
* @param problemType - Problem type to filter by
|
|
189
|
+
* @returns Filtered issues
|
|
190
|
+
*/
|
|
191
|
+
getIssuesByType(problemType: string): MessageValidationIssue[];
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Check if a specific field has validation issues
|
|
195
|
+
* @param fieldPath - Field path to check
|
|
196
|
+
* @returns True if field has issues
|
|
197
|
+
*/
|
|
198
|
+
hasFieldIssue(fieldPath: string): boolean;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* ROS name validation error (topics, nodes, services)
|
|
203
|
+
*/
|
|
204
|
+
export class NameValidationError extends ValidationError {
|
|
205
|
+
/** Index where validation failed */
|
|
206
|
+
invalidIndex: number;
|
|
207
|
+
/** The validation error message */
|
|
208
|
+
validationResult: string;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* @param name - The invalid name
|
|
212
|
+
* @param nameType - Type of name (node, topic, service, etc.)
|
|
213
|
+
* @param validationResult - The validation error message
|
|
214
|
+
* @param invalidIndex - Index where validation failed
|
|
215
|
+
* @param options - Additional options
|
|
216
|
+
*/
|
|
217
|
+
constructor(
|
|
218
|
+
name: string,
|
|
219
|
+
nameType: string,
|
|
220
|
+
validationResult: string,
|
|
221
|
+
invalidIndex: number,
|
|
222
|
+
options?: RclNodeErrorOptions
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Base class for operation/runtime errors
|
|
228
|
+
*/
|
|
229
|
+
export class OperationError extends RclNodeError {
|
|
230
|
+
/**
|
|
231
|
+
* @param message - Error message
|
|
232
|
+
* @param options - Additional options
|
|
233
|
+
*/
|
|
234
|
+
constructor(message: string, options?: RclNodeErrorOptions);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Request timeout error
|
|
239
|
+
*/
|
|
240
|
+
export class TimeoutError extends OperationError {
|
|
241
|
+
/** Timeout duration in milliseconds */
|
|
242
|
+
timeout: number;
|
|
243
|
+
/** Type of operation that timed out */
|
|
244
|
+
operationType: string;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* @param operationType - Type of operation that timed out
|
|
248
|
+
* @param timeoutMs - Timeout duration in milliseconds
|
|
249
|
+
* @param options - Additional options
|
|
250
|
+
*/
|
|
251
|
+
constructor(
|
|
252
|
+
operationType: string,
|
|
253
|
+
timeoutMs: number,
|
|
254
|
+
options?: RclNodeErrorOptions
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Request abortion error
|
|
260
|
+
*/
|
|
261
|
+
export class AbortError extends OperationError {
|
|
262
|
+
/** Type of operation that was aborted */
|
|
263
|
+
operationType: string;
|
|
264
|
+
/** Reason for abortion */
|
|
265
|
+
abortReason?: string;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @param operationType - Type of operation that was aborted
|
|
269
|
+
* @param reason - Reason for abortion
|
|
270
|
+
* @param options - Additional options
|
|
271
|
+
*/
|
|
272
|
+
constructor(
|
|
273
|
+
operationType: string,
|
|
274
|
+
reason?: string,
|
|
275
|
+
options?: RclNodeErrorOptions
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Service not available error
|
|
281
|
+
*/
|
|
282
|
+
export class ServiceNotFoundError extends OperationError {
|
|
283
|
+
/** Name of the service */
|
|
284
|
+
serviceName: string;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* @param serviceName - Name of the service
|
|
288
|
+
* @param options - Additional options
|
|
289
|
+
*/
|
|
290
|
+
constructor(serviceName: string, options?: RclNodeErrorOptions);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Remote node not found error
|
|
295
|
+
*/
|
|
296
|
+
export class NodeNotFoundError extends OperationError {
|
|
297
|
+
/** Name of the target node */
|
|
298
|
+
targetNodeName: string;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* @param nodeName - Name of the node
|
|
302
|
+
* @param options - Additional options
|
|
303
|
+
*/
|
|
304
|
+
constructor(nodeName: string, options?: RclNodeErrorOptions);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Base error for parameter operations
|
|
309
|
+
*/
|
|
310
|
+
export class ParameterError extends RclNodeError {
|
|
311
|
+
/** Name of the parameter */
|
|
312
|
+
parameterName: string;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @param message - Error message
|
|
316
|
+
* @param parameterName - Name of the parameter
|
|
317
|
+
* @param options - Additional options
|
|
318
|
+
*/
|
|
319
|
+
constructor(
|
|
320
|
+
message: string,
|
|
321
|
+
parameterName: string,
|
|
322
|
+
options?: RclNodeErrorOptions
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Parameter not found error
|
|
328
|
+
*/
|
|
329
|
+
export class ParameterNotFoundError extends ParameterError {
|
|
330
|
+
/**
|
|
331
|
+
* @param parameterName - Name of the parameter
|
|
332
|
+
* @param nodeName - Name of the node
|
|
333
|
+
* @param options - Additional options
|
|
334
|
+
*/
|
|
335
|
+
constructor(
|
|
336
|
+
parameterName: string,
|
|
337
|
+
nodeName: string,
|
|
338
|
+
options?: RclNodeErrorOptions
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Parameter type mismatch error
|
|
344
|
+
*/
|
|
345
|
+
export class ParameterTypeError extends ParameterError {
|
|
346
|
+
/** Expected parameter type */
|
|
347
|
+
expectedType: string;
|
|
348
|
+
/** Actual parameter type */
|
|
349
|
+
actualType: string;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* @param parameterName - Name of the parameter
|
|
353
|
+
* @param expectedType - Expected parameter type
|
|
354
|
+
* @param actualType - Actual parameter type
|
|
355
|
+
* @param options - Additional options
|
|
356
|
+
*/
|
|
357
|
+
constructor(
|
|
358
|
+
parameterName: string,
|
|
359
|
+
expectedType: string,
|
|
360
|
+
actualType: string,
|
|
361
|
+
options?: RclNodeErrorOptions
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Read-only parameter modification error
|
|
367
|
+
*/
|
|
368
|
+
export class ReadOnlyParameterError extends ParameterError {
|
|
369
|
+
/**
|
|
370
|
+
* @param parameterName - Name of the parameter
|
|
371
|
+
* @param options - Additional options
|
|
372
|
+
*/
|
|
373
|
+
constructor(parameterName: string, options?: RclNodeErrorOptions);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Base error for topic operations
|
|
378
|
+
*/
|
|
379
|
+
export class TopicError extends RclNodeError {
|
|
380
|
+
/** Name of the topic */
|
|
381
|
+
topicName: string;
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @param message - Error message
|
|
385
|
+
* @param topicName - Name of the topic
|
|
386
|
+
* @param options - Additional options
|
|
387
|
+
*/
|
|
388
|
+
constructor(
|
|
389
|
+
message: string,
|
|
390
|
+
topicName: string,
|
|
391
|
+
options?: RclNodeErrorOptions
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Publisher-specific error
|
|
397
|
+
*/
|
|
398
|
+
export class PublisherError extends TopicError {
|
|
399
|
+
/**
|
|
400
|
+
* @param message - Error message
|
|
401
|
+
* @param topicName - Name of the topic
|
|
402
|
+
* @param options - Additional options
|
|
403
|
+
*/
|
|
404
|
+
constructor(
|
|
405
|
+
message: string,
|
|
406
|
+
topicName: string,
|
|
407
|
+
options?: RclNodeErrorOptions
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* Subscription-specific error
|
|
413
|
+
*/
|
|
414
|
+
export class SubscriptionError extends TopicError {
|
|
415
|
+
/**
|
|
416
|
+
* @param message - Error message
|
|
417
|
+
* @param topicName - Name of the topic
|
|
418
|
+
* @param options - Additional options
|
|
419
|
+
*/
|
|
420
|
+
constructor(
|
|
421
|
+
message: string,
|
|
422
|
+
topicName: string,
|
|
423
|
+
options?: RclNodeErrorOptions
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Base error for action operations
|
|
429
|
+
*/
|
|
430
|
+
export class ActionError extends RclNodeError {
|
|
431
|
+
/** Name of the action */
|
|
432
|
+
actionName: string;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* @param message - Error message
|
|
436
|
+
* @param actionName - Name of the action
|
|
437
|
+
* @param options - Additional options
|
|
438
|
+
*/
|
|
439
|
+
constructor(
|
|
440
|
+
message: string,
|
|
441
|
+
actionName: string,
|
|
442
|
+
options?: RclNodeErrorOptions
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Goal rejected by action server
|
|
448
|
+
*/
|
|
449
|
+
export class GoalRejectedError extends ActionError {
|
|
450
|
+
/** ID of the rejected goal */
|
|
451
|
+
goalId: string;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* @param actionName - Name of the action
|
|
455
|
+
* @param goalId - ID of the rejected goal
|
|
456
|
+
* @param options - Additional options
|
|
457
|
+
*/
|
|
458
|
+
constructor(
|
|
459
|
+
actionName: string,
|
|
460
|
+
goalId: string,
|
|
461
|
+
options?: RclNodeErrorOptions
|
|
462
|
+
);
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* Action server not found
|
|
467
|
+
*/
|
|
468
|
+
export class ActionServerNotFoundError extends ActionError {
|
|
469
|
+
/**
|
|
470
|
+
* @param actionName - Name of the action
|
|
471
|
+
* @param options - Additional options
|
|
472
|
+
*/
|
|
473
|
+
constructor(actionName: string, options?: RclNodeErrorOptions);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Wraps errors from native C++ layer with additional context
|
|
478
|
+
*/
|
|
479
|
+
export class NativeError extends RclNodeError {
|
|
480
|
+
/** Error message from C++ layer */
|
|
481
|
+
nativeMessage: string;
|
|
482
|
+
/** Operation that failed */
|
|
483
|
+
operation: string;
|
|
484
|
+
|
|
485
|
+
/**
|
|
486
|
+
* @param nativeMessage - Error message from C++ layer
|
|
487
|
+
* @param operation - Operation that failed
|
|
488
|
+
* @param options - Additional options
|
|
489
|
+
*/
|
|
490
|
+
constructor(
|
|
491
|
+
nativeMessage: string,
|
|
492
|
+
operation: string,
|
|
493
|
+
options?: RclNodeErrorOptions
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/// <reference path="./base.d.ts" />
|
|
2
|
+
/// <reference path="./clock_event.d.ts" />
|
|
3
|
+
/// <reference path="./clock_change.d.ts" />
|
|
4
|
+
/// <reference path="./message_validation.d.ts" />
|
|
2
5
|
|
|
3
6
|
import { ChildProcess } from 'child_process';
|
|
4
7
|
|
|
@@ -58,6 +61,13 @@ declare module 'rclnodejs' {
|
|
|
58
61
|
*/
|
|
59
62
|
function init(context?: Context, argv?: string[]): Promise<void>;
|
|
60
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Remove ROS-specific arguments from the given argument list.
|
|
66
|
+
* @param argv - The argument list to process.
|
|
67
|
+
* @returns The argument list with ROS arguments removed.
|
|
68
|
+
*/
|
|
69
|
+
function removeROSArgs(argv: string[]): string[];
|
|
70
|
+
|
|
61
71
|
/**
|
|
62
72
|
* Start detection and processing of units of work.
|
|
63
73
|
*
|
package/types/logging.d.ts
CHANGED
|
@@ -77,6 +77,19 @@ declare module 'rclnodejs' {
|
|
|
77
77
|
*/
|
|
78
78
|
readonly name: string;
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Create a child logger.
|
|
82
|
+
*
|
|
83
|
+
* @param name - name of the child logger.
|
|
84
|
+
* @returns The child logger object.
|
|
85
|
+
*/
|
|
86
|
+
getChild(name: string): Logging;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Destroy the logger and remove it from the parent logger if it is a child logger.
|
|
90
|
+
*/
|
|
91
|
+
destroy(): void;
|
|
92
|
+
|
|
80
93
|
/**
|
|
81
94
|
* Create a logger by name.
|
|
82
95
|
*
|
|
@@ -84,6 +97,25 @@ declare module 'rclnodejs' {
|
|
|
84
97
|
* @returns New logger.
|
|
85
98
|
*/
|
|
86
99
|
static getLogger(name: string): Logging;
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Configure the logging system with the given context.
|
|
103
|
+
*
|
|
104
|
+
* @param context - The context to configure logging for.
|
|
105
|
+
*/
|
|
106
|
+
static configure(context: Context): void;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Shutdown the logging system.
|
|
110
|
+
*/
|
|
111
|
+
static shutdown(): void;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Get the logging directory.
|
|
115
|
+
*
|
|
116
|
+
* @returns The logging directory.
|
|
117
|
+
*/
|
|
118
|
+
static getLoggingDirectory(): string;
|
|
87
119
|
}
|
|
88
120
|
|
|
89
121
|
namespace Logging {
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
declare module 'rclnodejs' {
|
|
2
|
+
/**
|
|
3
|
+
* A utility class for inspecting ROS 2 message structure without using loader.loadInterface directly.
|
|
4
|
+
* Provides access to message schema, field names, and default values.
|
|
5
|
+
*/
|
|
6
|
+
export class MessageIntrospector<T = any> {
|
|
7
|
+
/**
|
|
8
|
+
* Create a new MessageIntrospector for a ROS 2 message type.
|
|
9
|
+
* @param typeName - The full message type name (e.g., 'geometry_msgs/msg/Twist')
|
|
10
|
+
* @throws {TypeValidationError} If typeName is not a non-empty string
|
|
11
|
+
* @throws {Error} If the message type cannot be loaded
|
|
12
|
+
*/
|
|
13
|
+
constructor(typeName: string);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Get the full message type name.
|
|
17
|
+
*/
|
|
18
|
+
readonly typeName: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Get the underlying ROS message class.
|
|
22
|
+
*/
|
|
23
|
+
readonly typeClass: new () => T;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Get the field names of the message.
|
|
27
|
+
*/
|
|
28
|
+
readonly fields: string[];
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Get the ROSMessageDef schema for the message type.
|
|
32
|
+
*/
|
|
33
|
+
readonly schema: ROSMessageDef;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the default values for all fields.
|
|
37
|
+
* Creates a new instance of the message and converts it to a plain object.
|
|
38
|
+
* Result is cached for performance.
|
|
39
|
+
*/
|
|
40
|
+
readonly defaults: T;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* ROSMessageDef schema structure.
|
|
45
|
+
*/
|
|
46
|
+
interface ROSMessageDef {
|
|
47
|
+
constants: Array<{
|
|
48
|
+
name: string;
|
|
49
|
+
type: string;
|
|
50
|
+
value: any;
|
|
51
|
+
}>;
|
|
52
|
+
fields: Array<{
|
|
53
|
+
name: string;
|
|
54
|
+
type: {
|
|
55
|
+
isPrimitiveType: boolean;
|
|
56
|
+
type: string;
|
|
57
|
+
pkgName: string | null;
|
|
58
|
+
isArray: boolean;
|
|
59
|
+
isDynamicArray: boolean;
|
|
60
|
+
isFixedSizeArray: boolean | null;
|
|
61
|
+
arraySize: number | null;
|
|
62
|
+
stringUpperBound: number | null;
|
|
63
|
+
isUpperBound: boolean;
|
|
64
|
+
};
|
|
65
|
+
default_value: any;
|
|
66
|
+
}>;
|
|
67
|
+
msgName: string;
|
|
68
|
+
baseType: {
|
|
69
|
+
pkgName: string;
|
|
70
|
+
type: string;
|
|
71
|
+
stringUpperBound: number | null;
|
|
72
|
+
isPrimitiveType: boolean;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
}
|