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,183 @@
|
|
|
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
|
+
* Validation issue problem types
|
|
18
|
+
*/
|
|
19
|
+
export const ValidationProblem: {
|
|
20
|
+
/** Field exists in object but not in message schema */
|
|
21
|
+
readonly UNKNOWN_FIELD: 'UNKNOWN_FIELD';
|
|
22
|
+
/** Field type doesn't match expected type */
|
|
23
|
+
readonly TYPE_MISMATCH: 'TYPE_MISMATCH';
|
|
24
|
+
/** Required field is missing */
|
|
25
|
+
readonly MISSING_FIELD: 'MISSING_FIELD';
|
|
26
|
+
/** Array length constraint violated */
|
|
27
|
+
readonly ARRAY_LENGTH: 'ARRAY_LENGTH';
|
|
28
|
+
/** Value is out of valid range */
|
|
29
|
+
readonly OUT_OF_RANGE: 'OUT_OF_RANGE';
|
|
30
|
+
/** Nested message validation failed */
|
|
31
|
+
readonly NESTED_ERROR: 'NESTED_ERROR';
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Field type information from message schema
|
|
36
|
+
*/
|
|
37
|
+
export interface MessageFieldType {
|
|
38
|
+
/** The type name (e.g., 'string', 'float64', 'Vector3') */
|
|
39
|
+
type: string;
|
|
40
|
+
/** Whether this is a primitive ROS type */
|
|
41
|
+
isPrimitiveType: boolean;
|
|
42
|
+
/** Whether this field is an array */
|
|
43
|
+
isArray: boolean;
|
|
44
|
+
/** For fixed-size arrays, the required size */
|
|
45
|
+
arraySize?: number;
|
|
46
|
+
/** Whether this is a fixed-size array */
|
|
47
|
+
isFixedSizeArray: boolean;
|
|
48
|
+
/** Whether this has an upper bound (bounded sequence) */
|
|
49
|
+
isUpperBound: boolean;
|
|
50
|
+
/** Whether this is a dynamic array */
|
|
51
|
+
isDynamicArray: boolean;
|
|
52
|
+
/** Package name for non-primitive types */
|
|
53
|
+
pkgName?: string;
|
|
54
|
+
/** String upper bound for bounded strings */
|
|
55
|
+
stringUpperBound?: number;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Field definition from message schema
|
|
60
|
+
*/
|
|
61
|
+
export interface MessageField {
|
|
62
|
+
/** Field name */
|
|
63
|
+
name: string;
|
|
64
|
+
/** Field type information */
|
|
65
|
+
type: MessageFieldType;
|
|
66
|
+
/** Default value if any */
|
|
67
|
+
default_value?: any;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Constant definition from message schema
|
|
72
|
+
*/
|
|
73
|
+
export interface MessageConstant {
|
|
74
|
+
/** Constant name */
|
|
75
|
+
name: string;
|
|
76
|
+
/** Constant type */
|
|
77
|
+
type: string;
|
|
78
|
+
/** Constant value */
|
|
79
|
+
value: any;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Message schema definition
|
|
84
|
+
*/
|
|
85
|
+
export interface MessageSchema {
|
|
86
|
+
/** Array of field definitions */
|
|
87
|
+
fields: MessageField[];
|
|
88
|
+
/** Array of constant definitions */
|
|
89
|
+
constants: MessageConstant[];
|
|
90
|
+
/** Full message type string (e.g., 'std_msgs/msg/String') */
|
|
91
|
+
messageType: string;
|
|
92
|
+
/** Base type information */
|
|
93
|
+
baseType?: {
|
|
94
|
+
pkgName: string;
|
|
95
|
+
type: string;
|
|
96
|
+
isPrimitiveType: boolean;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Options for message validation
|
|
102
|
+
*/
|
|
103
|
+
export interface MessageValidationOptions {
|
|
104
|
+
/** If true, unknown fields cause validation failure (default: false) */
|
|
105
|
+
strict?: boolean;
|
|
106
|
+
/** If true, validate field types (default: true) */
|
|
107
|
+
checkTypes?: boolean;
|
|
108
|
+
/** If true, check for missing fields (default: false) */
|
|
109
|
+
checkRequired?: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Result of message validation
|
|
114
|
+
*/
|
|
115
|
+
export interface MessageValidationResult {
|
|
116
|
+
/** Whether the message is valid */
|
|
117
|
+
valid: boolean;
|
|
118
|
+
/** Array of validation issues found */
|
|
119
|
+
issues: MessageValidationIssue[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Get the schema definition for a message type
|
|
124
|
+
* @param typeClass - Message type class or identifier
|
|
125
|
+
* @returns Schema definition with fields and constants, or null if not found
|
|
126
|
+
*/
|
|
127
|
+
export function getMessageSchema(typeClass: TypeClass): MessageSchema | null;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Get field names for a message type
|
|
131
|
+
* @param typeClass - Message type class or identifier
|
|
132
|
+
* @returns Array of field names
|
|
133
|
+
*/
|
|
134
|
+
export function getFieldNames(typeClass: TypeClass): string[];
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Get type information for a specific field
|
|
138
|
+
* @param typeClass - Message type class or identifier
|
|
139
|
+
* @param fieldName - Name of the field
|
|
140
|
+
* @returns Field type information or null if not found
|
|
141
|
+
*/
|
|
142
|
+
export function getFieldType(
|
|
143
|
+
typeClass: TypeClass,
|
|
144
|
+
fieldName: string
|
|
145
|
+
): MessageFieldType | null;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Validate a message object against its schema
|
|
149
|
+
* @param obj - Plain object to validate
|
|
150
|
+
* @param typeClass - Message type class or identifier
|
|
151
|
+
* @param options - Validation options
|
|
152
|
+
* @returns Validation result with valid flag and issues array
|
|
153
|
+
*/
|
|
154
|
+
export function validateMessage(
|
|
155
|
+
obj: any,
|
|
156
|
+
typeClass: TypeClass,
|
|
157
|
+
options?: MessageValidationOptions
|
|
158
|
+
): MessageValidationResult;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Validate a message and throw if invalid
|
|
162
|
+
* @param obj - Plain object to validate
|
|
163
|
+
* @param typeClass - Message type class or identifier
|
|
164
|
+
* @param options - Validation options
|
|
165
|
+
* @throws MessageValidationError if validation fails
|
|
166
|
+
*/
|
|
167
|
+
export function assertValidMessage(
|
|
168
|
+
obj: any,
|
|
169
|
+
typeClass: TypeClass,
|
|
170
|
+
options?: MessageValidationOptions
|
|
171
|
+
): void;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Create a validator function for a specific message type
|
|
175
|
+
* @param typeClass - Message type class or identifier
|
|
176
|
+
* @param defaultOptions - Default validation options
|
|
177
|
+
* @returns Validator function that takes (obj, options?) and returns validation result
|
|
178
|
+
*/
|
|
179
|
+
export function createMessageValidator(
|
|
180
|
+
typeClass: TypeClass,
|
|
181
|
+
defaultOptions?: MessageValidationOptions
|
|
182
|
+
): (obj: any, options?: MessageValidationOptions) => MessageValidationResult;
|
|
183
|
+
}
|
package/types/node.d.ts
CHANGED
|
@@ -363,6 +363,23 @@ declare module 'rclnodejs' {
|
|
|
363
363
|
eventCallbacks?: (event: object) => void
|
|
364
364
|
): Subscription;
|
|
365
365
|
|
|
366
|
+
/**
|
|
367
|
+
* Create a Subscription that returns an RxJS Observable.
|
|
368
|
+
* This allows using reactive programming patterns with ROS 2 messages.
|
|
369
|
+
*
|
|
370
|
+
* @param typeClass - Type of ROS messages the subscription will subscribe to.
|
|
371
|
+
* @param topic - Name of the topic the subscription will subscribe to.
|
|
372
|
+
* @param options - Configuration options, see DEFAULT_OPTIONS.
|
|
373
|
+
* @param eventCallbacks - Optional event callbacks for the subscription.
|
|
374
|
+
* @returns An ObservableSubscription with an RxJS Observable.
|
|
375
|
+
*/
|
|
376
|
+
createObservableSubscription<T extends TypeClass<MessageTypeClassName>>(
|
|
377
|
+
typeClass: T,
|
|
378
|
+
topic: string,
|
|
379
|
+
options?: Options,
|
|
380
|
+
eventCallbacks?: (event: object) => void
|
|
381
|
+
): ObservableSubscription<MessageType<T>>;
|
|
382
|
+
|
|
366
383
|
/**
|
|
367
384
|
* Create a Client for making server requests.
|
|
368
385
|
*
|
|
@@ -407,6 +424,32 @@ declare module 'rclnodejs' {
|
|
|
407
424
|
callback: ServiceRequestHandler<T>
|
|
408
425
|
): ServiceType<T>;
|
|
409
426
|
|
|
427
|
+
/**
|
|
428
|
+
* Create a ParameterClient for accessing parameters on a remote node.
|
|
429
|
+
*
|
|
430
|
+
* @param remoteNodeName - The name of the remote node whose parameters to access.
|
|
431
|
+
* @param options - Options for parameter client.
|
|
432
|
+
* @returns An instance of ParameterClient.
|
|
433
|
+
*/
|
|
434
|
+
createParameterClient(
|
|
435
|
+
remoteNodeName: string,
|
|
436
|
+
options?: { timeout?: number }
|
|
437
|
+
): ParameterClient;
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Create a ParameterWatcher for watching parameter changes on a remote node.
|
|
441
|
+
*
|
|
442
|
+
* @param remoteNodeName - The name of the remote node whose parameters to watch.
|
|
443
|
+
* @param parameterNames - Array of parameter names to watch.
|
|
444
|
+
* @param options - Options for parameter watcher.
|
|
445
|
+
* @returns An instance of ParameterWatcher.
|
|
446
|
+
*/
|
|
447
|
+
createParameterWatcher(
|
|
448
|
+
remoteNodeName: string,
|
|
449
|
+
parameterNames: string[],
|
|
450
|
+
options?: { timeout?: number }
|
|
451
|
+
): ParameterWatcher;
|
|
452
|
+
|
|
410
453
|
/**
|
|
411
454
|
* Create a guard condition.
|
|
412
455
|
*
|
|
@@ -454,6 +497,20 @@ declare module 'rclnodejs' {
|
|
|
454
497
|
*/
|
|
455
498
|
destroyService(service: Service): void;
|
|
456
499
|
|
|
500
|
+
/**
|
|
501
|
+
* Destroy a ParameterClient.
|
|
502
|
+
*
|
|
503
|
+
* @param parameterClient - ParameterClient to be destroyed.
|
|
504
|
+
*/
|
|
505
|
+
destroyParameterClient(parameterClient: ParameterClient): void;
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Destroy a ParameterWatcher.
|
|
509
|
+
*
|
|
510
|
+
* @param watcher - ParameterWatcher to be destroyed.
|
|
511
|
+
*/
|
|
512
|
+
destroyParameterWatcher(watcher: ParameterWatcher): void;
|
|
513
|
+
|
|
457
514
|
/**
|
|
458
515
|
* Destroy a Timer.
|
|
459
516
|
*
|
|
@@ -811,6 +868,56 @@ declare module 'rclnodejs' {
|
|
|
811
868
|
noDemangle: boolean
|
|
812
869
|
): Array<object>;
|
|
813
870
|
|
|
871
|
+
/**
|
|
872
|
+
* Return a list of clients on a given service.
|
|
873
|
+
*
|
|
874
|
+
* The returned parameter is a list of ServiceEndpointInfo objects, where each will contain
|
|
875
|
+
* the node name, node namespace, service type, service endpoint's GID, and its QoS profile.
|
|
876
|
+
*
|
|
877
|
+
* When the `no_mangle` parameter is `true`, the provided `service` should be a valid
|
|
878
|
+
* service name for the middleware (useful when combining ROS with native middleware (e.g. DDS)
|
|
879
|
+
* apps). When the `no_mangle` parameter is `false`, the provided `service` should
|
|
880
|
+
* follow ROS service name conventions.
|
|
881
|
+
*
|
|
882
|
+
* `service` may be a relative, private, or fully qualified service name.
|
|
883
|
+
* A relative or private service will be expanded using this node's namespace and name.
|
|
884
|
+
* The queried `service` is not remapped.
|
|
885
|
+
*
|
|
886
|
+
* @param service - The service on which to find the clients.
|
|
887
|
+
* @param [noDemangle=false] - If `true`, `service` needs to be a valid middleware service
|
|
888
|
+
* name, otherwise it should be a valid ROS service name. Defaults to `false`.
|
|
889
|
+
* @returns An array of clients.
|
|
890
|
+
*/
|
|
891
|
+
getClientsInfoByService(
|
|
892
|
+
service: string,
|
|
893
|
+
noDemangle: boolean
|
|
894
|
+
): Array<object>;
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Return a list of servers on a given service.
|
|
898
|
+
*
|
|
899
|
+
* The returned parameter is a list of ServiceEndpointInfo objects, where each will contain
|
|
900
|
+
* the node name, node namespace, service type, service endpoint's GID, and its QoS profile.
|
|
901
|
+
*
|
|
902
|
+
* When the `no_mangle` parameter is `true`, the provided `service` should be a valid
|
|
903
|
+
* service name for the middleware (useful when combining ROS with native middleware (e.g. DDS)
|
|
904
|
+
* apps). When the `no_mangle` parameter is `false`, the provided `service` should
|
|
905
|
+
* follow ROS service name conventions.
|
|
906
|
+
*
|
|
907
|
+
* `service` may be a relative, private, or fully qualified service name.
|
|
908
|
+
* A relative or private service will be expanded using this node's namespace and name.
|
|
909
|
+
* The queried `service` is not remapped.
|
|
910
|
+
*
|
|
911
|
+
* @param service - The service on which to find the servers.
|
|
912
|
+
* @param [noDemangle=false] - If `true`, `service` needs to be a valid middleware service
|
|
913
|
+
* name, otherwise it should be a valid ROS service name. Defaults to `false`.
|
|
914
|
+
* @returns An array of servers.
|
|
915
|
+
*/
|
|
916
|
+
getServersInfoByService(
|
|
917
|
+
service: string,
|
|
918
|
+
noDemangle: boolean
|
|
919
|
+
): Array<object>;
|
|
920
|
+
|
|
814
921
|
/**
|
|
815
922
|
* Get the list of nodes discovered by the provided node.
|
|
816
923
|
*
|
package/types/node_options.d.ts
CHANGED
|
@@ -32,6 +32,19 @@ declare module 'rclnodejs' {
|
|
|
32
32
|
*/
|
|
33
33
|
automaticallyDeclareParametersFromOverrides: boolean;
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* A flag controlling the startup of the rosout logging.
|
|
37
|
+
* When true a node will start the rosout logging.
|
|
38
|
+
* Default value = true;
|
|
39
|
+
* @returns {boolean} -
|
|
40
|
+
*/
|
|
41
|
+
enableRosout: boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The QoS profile for the rosout publisher.
|
|
45
|
+
*/
|
|
46
|
+
rosoutQos: QoS | QoS.ProfileRef;
|
|
47
|
+
|
|
35
48
|
/**
|
|
36
49
|
* An instance configured with default values.
|
|
37
50
|
*/
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare module 'rclnodejs' {
|
|
2
|
+
/**
|
|
3
|
+
* A wrapper that provides RxJS Observable support for ROS 2 subscriptions.
|
|
4
|
+
* This class wraps a standard Subscription and emits messages through an Observable.
|
|
5
|
+
*/
|
|
6
|
+
class ObservableSubscription<T = any> {
|
|
7
|
+
/**
|
|
8
|
+
* Get the RxJS Observable for this subscription.
|
|
9
|
+
* Use this to pipe operators and subscribe to messages.
|
|
10
|
+
*/
|
|
11
|
+
readonly observable: import('rxjs').Observable<T>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Get the underlying ROS 2 subscription.
|
|
15
|
+
*/
|
|
16
|
+
readonly subscription: Subscription;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get the topic name.
|
|
20
|
+
*/
|
|
21
|
+
readonly topic: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Check if this observable subscription has been destroyed.
|
|
25
|
+
*/
|
|
26
|
+
readonly isDestroyed: boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Complete the observable and clean up resources.
|
|
30
|
+
* After calling this, no more messages will be emitted.
|
|
31
|
+
*/
|
|
32
|
+
complete(): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Alias for complete() for consistency with RxJS naming.
|
|
36
|
+
*/
|
|
37
|
+
destroy(): void;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
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 ParameterClient constructor.
|
|
18
|
+
*/
|
|
19
|
+
export interface ParameterClientOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Default timeout in milliseconds for service calls.
|
|
22
|
+
* @default 5000
|
|
23
|
+
*/
|
|
24
|
+
timeout?: number;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Options for parameter service calls.
|
|
29
|
+
*/
|
|
30
|
+
export interface ParameterServiceCallOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Timeout in milliseconds for this specific call.
|
|
33
|
+
*/
|
|
34
|
+
timeout?: number;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* AbortSignal to cancel the request.
|
|
38
|
+
*/
|
|
39
|
+
signal?: AbortSignal;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Result of a parameter set operation.
|
|
44
|
+
*/
|
|
45
|
+
export interface ParameterSetResult {
|
|
46
|
+
/**
|
|
47
|
+
* The name of the parameter.
|
|
48
|
+
*/
|
|
49
|
+
name: string;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether the operation was successful.
|
|
53
|
+
*/
|
|
54
|
+
successful: boolean;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Reason message, typically populated on failure.
|
|
58
|
+
*/
|
|
59
|
+
reason: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Result of a list parameters operation.
|
|
64
|
+
*/
|
|
65
|
+
export interface ListParametersResult {
|
|
66
|
+
/**
|
|
67
|
+
* Array of parameter names found.
|
|
68
|
+
*/
|
|
69
|
+
names: string[];
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Array of parameter prefixes found.
|
|
73
|
+
*/
|
|
74
|
+
prefixes: string[];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Options for listing parameters.
|
|
79
|
+
*/
|
|
80
|
+
export interface ListParametersOptions extends ParameterServiceCallOptions {
|
|
81
|
+
/**
|
|
82
|
+
* Optional array of parameter name prefixes to filter by.
|
|
83
|
+
*/
|
|
84
|
+
prefixes?: string[];
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Depth of parameter namespace to list.
|
|
88
|
+
* @default 0 (unlimited)
|
|
89
|
+
*/
|
|
90
|
+
depth?: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Parameter to set with name and value.
|
|
95
|
+
*/
|
|
96
|
+
export interface ParameterToSet {
|
|
97
|
+
/**
|
|
98
|
+
* The name of the parameter.
|
|
99
|
+
*/
|
|
100
|
+
name: string;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The value to set. Type is automatically inferred.
|
|
104
|
+
*/
|
|
105
|
+
value: any;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Class for accessing parameters on remote ROS 2 nodes.
|
|
110
|
+
*
|
|
111
|
+
* Provides promise-based APIs to get, set, list, and describe parameters
|
|
112
|
+
* on other nodes in the ROS 2 system.
|
|
113
|
+
*/
|
|
114
|
+
export class ParameterClient {
|
|
115
|
+
/**
|
|
116
|
+
* Create a new ParameterClient for accessing parameters on a remote node.
|
|
117
|
+
*
|
|
118
|
+
* @param node - The node to use for creating service clients.
|
|
119
|
+
* @param remoteNodeName - The name of the remote node whose parameters to access.
|
|
120
|
+
* @param options - Optional configuration for the parameter client.
|
|
121
|
+
* @throws {TypeError} If node is not provided or remoteNodeName is not a valid string.
|
|
122
|
+
* @throws {Error} If remoteNodeName is not a valid ROS node name.
|
|
123
|
+
*/
|
|
124
|
+
constructor(
|
|
125
|
+
node: Node,
|
|
126
|
+
remoteNodeName: string,
|
|
127
|
+
options?: ParameterClientOptions
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Get the name of the remote node this client is connected to.
|
|
132
|
+
*/
|
|
133
|
+
readonly remoteNodeName: string;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Get a single parameter from the remote node.
|
|
137
|
+
*
|
|
138
|
+
* @param name - The name of the parameter to retrieve.
|
|
139
|
+
* @param options - Optional timeout and abort signal.
|
|
140
|
+
* @returns Promise that resolves with the Parameter object.
|
|
141
|
+
* @throws {Error} If the parameter is not found or service call fails.
|
|
142
|
+
*/
|
|
143
|
+
getParameter(
|
|
144
|
+
name: string,
|
|
145
|
+
options?: ParameterServiceCallOptions
|
|
146
|
+
): Promise<Parameter>;
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Get multiple parameters from the remote node.
|
|
150
|
+
*
|
|
151
|
+
* @param names - Array of parameter names to retrieve.
|
|
152
|
+
* @param options - Optional timeout and abort signal.
|
|
153
|
+
* @returns Promise that resolves with an array of Parameter objects.
|
|
154
|
+
* @throws {Error} If the service call fails.
|
|
155
|
+
* @throws {TypeError} If names is not a non-empty array.
|
|
156
|
+
*/
|
|
157
|
+
getParameters(
|
|
158
|
+
names: string[],
|
|
159
|
+
options?: ParameterServiceCallOptions
|
|
160
|
+
): Promise<Parameter[]>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Set a single parameter on the remote node.
|
|
164
|
+
*
|
|
165
|
+
* @param name - The name of the parameter to set.
|
|
166
|
+
* @param value - The value to set. Type is automatically inferred.
|
|
167
|
+
* @param options - Optional timeout and abort signal.
|
|
168
|
+
* @returns Promise that resolves with the result.
|
|
169
|
+
* @throws {Error} If the service call fails.
|
|
170
|
+
*/
|
|
171
|
+
setParameter(
|
|
172
|
+
name: string,
|
|
173
|
+
value: any,
|
|
174
|
+
options?: ParameterServiceCallOptions
|
|
175
|
+
): Promise<ParameterSetResult>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Set multiple parameters on the remote node.
|
|
179
|
+
*
|
|
180
|
+
* @param parameters - Array of parameter objects with name and value.
|
|
181
|
+
* @param options - Optional timeout and abort signal.
|
|
182
|
+
* @returns Promise that resolves with an array of results.
|
|
183
|
+
* @throws {Error} If the service call fails.
|
|
184
|
+
* @throws {TypeError} If parameters is not a non-empty array.
|
|
185
|
+
*/
|
|
186
|
+
setParameters(
|
|
187
|
+
parameters: ParameterToSet[],
|
|
188
|
+
options?: ParameterServiceCallOptions
|
|
189
|
+
): Promise<ParameterSetResult[]>;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* List all parameters available on the remote node.
|
|
193
|
+
*
|
|
194
|
+
* @param options - Optional filters, depth, timeout and abort signal.
|
|
195
|
+
* @returns Promise that resolves with parameter names and prefixes.
|
|
196
|
+
* @throws {Error} If the service call fails.
|
|
197
|
+
*/
|
|
198
|
+
listParameters(
|
|
199
|
+
options?: ListParametersOptions
|
|
200
|
+
): Promise<ListParametersResult>;
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Describe parameters on the remote node.
|
|
204
|
+
*
|
|
205
|
+
* @param names - Array of parameter names to describe.
|
|
206
|
+
* @param options - Optional timeout and abort signal.
|
|
207
|
+
* @returns Promise that resolves with an array of parameter descriptors.
|
|
208
|
+
* @throws {Error} If the service call fails.
|
|
209
|
+
* @throws {TypeError} If names is not a non-empty array.
|
|
210
|
+
*/
|
|
211
|
+
describeParameters(
|
|
212
|
+
names: string[],
|
|
213
|
+
options?: ParameterServiceCallOptions
|
|
214
|
+
): Promise<any[]>;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Get the types of parameters on the remote node.
|
|
218
|
+
*
|
|
219
|
+
* @param names - Array of parameter names.
|
|
220
|
+
* @param options - Optional timeout and abort signal.
|
|
221
|
+
* @returns Promise that resolves with an array of parameter types.
|
|
222
|
+
* @throws {Error} If the service call fails.
|
|
223
|
+
* @throws {TypeError} If names is not a non-empty array.
|
|
224
|
+
*/
|
|
225
|
+
getParameterTypes(
|
|
226
|
+
names: string[],
|
|
227
|
+
options?: ParameterServiceCallOptions
|
|
228
|
+
): Promise<ParameterType[]>;
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Wait for the parameter services to be available on the remote node.
|
|
232
|
+
* This is useful to verify the remote node is running before making calls.
|
|
233
|
+
*
|
|
234
|
+
* @param timeout - Optional timeout in milliseconds.
|
|
235
|
+
* @returns Promise that resolves to true if services are available.
|
|
236
|
+
*/
|
|
237
|
+
waitForService(timeout?: number): Promise<boolean>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Check if the parameter client has been destroyed.
|
|
241
|
+
*
|
|
242
|
+
* @returns True if destroyed, false otherwise.
|
|
243
|
+
*/
|
|
244
|
+
isDestroyed(): boolean;
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Destroy the parameter client and clean up all service clients.
|
|
248
|
+
* After calling this method, the client cannot be used anymore.
|
|
249
|
+
*/
|
|
250
|
+
destroy(): void;
|
|
251
|
+
}
|
|
252
|
+
}
|