rclnodejs 1.7.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 +93 -0
- package/lib/action/client.js +54 -1
- package/lib/client.js +66 -1
- package/lib/clock.js +178 -0
- package/lib/clock_change.js +49 -0
- package/lib/clock_event.js +88 -0
- package/lib/errors.js +50 -0
- package/lib/logging.js +78 -0
- package/lib/message_introspector.js +123 -0
- package/lib/message_validation.js +512 -0
- package/lib/node.js +133 -1
- package/lib/node_options.js +40 -1
- package/lib/observable_subscription.js +105 -0
- package/lib/publisher.js +56 -1
- package/lib/qos.js +57 -0
- package/lib/subscription.js +8 -0
- package/lib/timer.js +42 -0
- package/lib/validator.js +63 -7
- 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 +3 -0
- package/types/client.d.ts +29 -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 +49 -0
- package/types/index.d.ts +10 -0
- package/types/interfaces.d.ts +1 -1910
- 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 +67 -0
- package/types/node_options.d.ts +13 -0
- package/types/observable_subscription.d.ts +39 -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
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
|
+
}
|
|
@@ -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
|
*
|
|
@@ -851,6 +868,56 @@ declare module 'rclnodejs' {
|
|
|
851
868
|
noDemangle: boolean
|
|
852
869
|
): Array<object>;
|
|
853
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
|
+
|
|
854
921
|
/**
|
|
855
922
|
* Get the list of nodes discovered by the provided node.
|
|
856
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
|
+
}
|
package/types/publisher.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
declare module 'rclnodejs' {
|
|
2
|
+
/**
|
|
3
|
+
* Options for publishing a message
|
|
4
|
+
*/
|
|
5
|
+
interface PublishOptions {
|
|
6
|
+
/** Override validateMessages setting for this publish call */
|
|
7
|
+
validate?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
2
10
|
/**
|
|
3
11
|
* A ROS Publisher that publishes messages on a topic.
|
|
4
12
|
*/
|
|
@@ -8,12 +16,26 @@ declare module 'rclnodejs' {
|
|
|
8
16
|
* Topic on which messages are published.
|
|
9
17
|
*/
|
|
10
18
|
readonly topic: string;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Whether messages will be validated before publishing.
|
|
22
|
+
*/
|
|
23
|
+
willValidateMessage: boolean;
|
|
24
|
+
|
|
11
25
|
/**
|
|
12
26
|
* Publish a message
|
|
13
27
|
*
|
|
14
28
|
* @param message - The message to be sent.
|
|
29
|
+
* @param options - Publish options (e.g., { validate: true })
|
|
30
|
+
* @throws MessageValidationError if validation is enabled and message is invalid
|
|
31
|
+
*/
|
|
32
|
+
publish(message: MessageType<T> | Buffer, options?: PublishOptions): void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Set validation options for this publisher.
|
|
36
|
+
* @param options - Validation options
|
|
15
37
|
*/
|
|
16
|
-
|
|
38
|
+
setValidation(options: MessageValidationOptions): void;
|
|
17
39
|
|
|
18
40
|
/**
|
|
19
41
|
* Get the number of subscriptions to this publisher.
|
|
@@ -38,6 +60,11 @@ declare module 'rclnodejs' {
|
|
|
38
60
|
*/
|
|
39
61
|
waitForAllAcked(timeout: bigint): boolean;
|
|
40
62
|
|
|
63
|
+
/**
|
|
64
|
+
* Manually assert that this Publisher is alive (for RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC).
|
|
65
|
+
*/
|
|
66
|
+
assertLiveliness(): void;
|
|
67
|
+
|
|
41
68
|
/**
|
|
42
69
|
* Get the logger name for this publisher.
|
|
43
70
|
*/
|
package/types/qos.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ declare module 'rclnodejs' {
|
|
|
11
11
|
* @param depth - The depth value, default = 0.
|
|
12
12
|
* @param reliability - The reliability value, default = RMW_QOS_POLICY_RELIABILITY_SYSTEM_DEFAULT
|
|
13
13
|
* @param durability - The durability value, default = RMW_QOS_POLICY_DURABILITY_SYSTEM_DEFAULT
|
|
14
|
+
* @param liveliness - The liveliness value, default = RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT
|
|
14
15
|
* @param avoidRosNameSpaceConventions - The avoidRosNameSpaceConventions value, default = false.
|
|
15
16
|
*/
|
|
16
17
|
constructor(
|
|
@@ -18,6 +19,7 @@ declare module 'rclnodejs' {
|
|
|
18
19
|
depth?: number,
|
|
19
20
|
reliability?: QoS.ReliabilityPolicy,
|
|
20
21
|
durability?: QoS.DurabilityPolicy,
|
|
22
|
+
liveliness?: QoS.LivelinessPolicy,
|
|
21
23
|
avoidRosNameSpaceConventions?: boolean
|
|
22
24
|
);
|
|
23
25
|
|
|
@@ -41,6 +43,11 @@ declare module 'rclnodejs' {
|
|
|
41
43
|
*/
|
|
42
44
|
durability: QoS.DurabilityPolicy;
|
|
43
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Get the liveliness value.
|
|
48
|
+
*/
|
|
49
|
+
liveliness: QoS.LivelinessPolicy;
|
|
50
|
+
|
|
44
51
|
/**
|
|
45
52
|
* Get the avoidRosNameSpaceConventions value.
|
|
46
53
|
*/
|
|
@@ -115,5 +122,16 @@ declare module 'rclnodejs' {
|
|
|
115
122
|
RMW_QOS_POLICY_DURABILITY_TRANSIENT_LOCAL = 1,
|
|
116
123
|
RMW_QOS_POLICY_DURABILITY_VOLATILE = 2,
|
|
117
124
|
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* LivelinessPolicy
|
|
128
|
+
*/
|
|
129
|
+
enum LivelinessPolicy {
|
|
130
|
+
RMW_QOS_POLICY_LIVELINESS_SYSTEM_DEFAULT = 0,
|
|
131
|
+
RMW_QOS_POLICY_LIVELINESS_AUTOMATIC = 1,
|
|
132
|
+
RMW_QOS_POLICY_LIVELINESS_MANUAL_BY_TOPIC = 3,
|
|
133
|
+
RMW_QOS_POLICY_LIVELINESS_UNKNOWN = 4,
|
|
134
|
+
RMW_QOS_POLICY_LIVELINESS_BEST_AVAILABLE = 5,
|
|
135
|
+
}
|
|
118
136
|
}
|
|
119
137
|
}
|
package/types/subscription.d.ts
CHANGED
|
@@ -61,6 +61,12 @@ declare module 'rclnodejs' {
|
|
|
61
61
|
*/
|
|
62
62
|
setContentFilter(filter: SubscriptionContentFilter): boolean;
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Get the current content-filter.
|
|
66
|
+
* @returns The content-filter description {expression: string, parameters: string[]} or undefined if not set/supported.
|
|
67
|
+
*/
|
|
68
|
+
getContentFilter(): SubscriptionContentFilter | undefined;
|
|
69
|
+
|
|
64
70
|
/**
|
|
65
71
|
* Clear the current content-filter. No filtering is to be applied.
|
|
66
72
|
* @returns True if successful; false otherwise
|
package/types/timer.d.ts
CHANGED
|
@@ -46,6 +46,13 @@ declare module 'rclnodejs' {
|
|
|
46
46
|
*/
|
|
47
47
|
timeUntilNextCall(): bigint;
|
|
48
48
|
|
|
49
|
+
/**
|
|
50
|
+
* Get the absolute time in nanoseconds when the next callback is due.
|
|
51
|
+
*
|
|
52
|
+
* @returns The next call time in nanoseconds, or null if the timer is canceled.
|
|
53
|
+
*/
|
|
54
|
+
getNextCallTime(): bigint | null;
|
|
55
|
+
|
|
49
56
|
/**
|
|
50
57
|
* Change the timer period.
|
|
51
58
|
* @param period - The new period in nanoseconds.
|
|
@@ -58,6 +65,17 @@ declare module 'rclnodejs' {
|
|
|
58
65
|
*/
|
|
59
66
|
timerPeriod(): bigint;
|
|
60
67
|
|
|
68
|
+
/**
|
|
69
|
+
* Set the on reset callback.
|
|
70
|
+
* @param callback - The callback to be called when the timer is reset.
|
|
71
|
+
*/
|
|
72
|
+
setOnResetCallback(callback: (events: number) => void): void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Clear the on reset callback.
|
|
76
|
+
*/
|
|
77
|
+
clearOnResetCallback(): void;
|
|
78
|
+
|
|
61
79
|
/**
|
|
62
80
|
* Call a timer and starts counting again, retrieves actual and expected call time.
|
|
63
81
|
* @return - The timer information.
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
* Validator for ROS 2 names (topics, services, nodes, namespaces).
|
|
18
|
+
*/
|
|
19
|
+
namespace validator {
|
|
20
|
+
/**
|
|
21
|
+
* Validate a fully-qualified topic or service name.
|
|
22
|
+
* The name must be fully-qualified and already expanded.
|
|
23
|
+
* @param topic - The topic/service name to validate.
|
|
24
|
+
* @returns Always returns true if valid.
|
|
25
|
+
* @throws TypeValidationError if topic is not a string.
|
|
26
|
+
* @throws NameValidationError if the name is invalid.
|
|
27
|
+
*/
|
|
28
|
+
function validateFullTopicName(topic: string): true;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Check if a fully-qualified topic name is valid without throwing.
|
|
32
|
+
* @param topic - The topic/service name to check.
|
|
33
|
+
* @returns True if valid, false otherwise.
|
|
34
|
+
*/
|
|
35
|
+
function isValidFullTopicName(topic: string): boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Validate a node name.
|
|
39
|
+
* @param name - The node name to validate.
|
|
40
|
+
* @returns Always returns true if valid.
|
|
41
|
+
* @throws TypeValidationError if name is not a string.
|
|
42
|
+
* @throws NameValidationError if the name is invalid.
|
|
43
|
+
*/
|
|
44
|
+
function validateNodeName(name: string): true;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Check if a node name is valid without throwing.
|
|
48
|
+
* @param name - The node name to check.
|
|
49
|
+
* @returns True if valid, false otherwise.
|
|
50
|
+
*/
|
|
51
|
+
function isValidNodeName(name: string): boolean;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Validate a topic or service name.
|
|
55
|
+
* The name does not have to be fully-qualified and is not expanded.
|
|
56
|
+
* @param topic - The topic/service name to validate.
|
|
57
|
+
* @returns Always returns true if valid.
|
|
58
|
+
* @throws TypeValidationError if topic is not a string.
|
|
59
|
+
* @throws NameValidationError if the name is invalid.
|
|
60
|
+
*/
|
|
61
|
+
function validateTopicName(topic: string): true;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Check if a topic name is valid without throwing.
|
|
65
|
+
* @param topic - The topic/service name to check.
|
|
66
|
+
* @returns True if valid, false otherwise.
|
|
67
|
+
*/
|
|
68
|
+
function isValidTopicName(topic: string): boolean;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Validate a namespace.
|
|
72
|
+
* @param namespace - The namespace to validate.
|
|
73
|
+
* @returns Always returns true if valid.
|
|
74
|
+
* @throws TypeValidationError if namespace is not a string.
|
|
75
|
+
* @throws NameValidationError if the namespace is invalid.
|
|
76
|
+
*/
|
|
77
|
+
function validateNamespace(namespace: string): true;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Check if a namespace is valid without throwing.
|
|
81
|
+
* @param namespace - The namespace to check.
|
|
82
|
+
* @returns True if valid, false otherwise.
|
|
83
|
+
*/
|
|
84
|
+
function isValidNamespace(namespace: string): boolean;
|
|
85
|
+
}
|
|
86
|
+
}
|