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,104 @@
|
|
|
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
|
+
import { EventEmitter } from 'events';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Options for ParameterWatcher constructor.
|
|
20
|
+
*/
|
|
21
|
+
export interface ParameterWatcherOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Default timeout in milliseconds for service calls.
|
|
24
|
+
* @default 5000
|
|
25
|
+
*/
|
|
26
|
+
timeout?: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* ParameterWatcher - Watches parameter changes on a remote node.
|
|
31
|
+
*
|
|
32
|
+
* Subscribes to /parameter_events and emits 'change' events when
|
|
33
|
+
* watched parameters on the target node are modified.
|
|
34
|
+
*/
|
|
35
|
+
class ParameterWatcher extends EventEmitter {
|
|
36
|
+
/**
|
|
37
|
+
* Get the remote node name being watched.
|
|
38
|
+
*/
|
|
39
|
+
readonly remoteNodeName: string;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get the list of watched parameter names.
|
|
43
|
+
*/
|
|
44
|
+
readonly watchedParameters: string[];
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Start watching for parameter changes.
|
|
48
|
+
* Waits for the remote node's parameter services and subscribes to parameter events.
|
|
49
|
+
*
|
|
50
|
+
* @param timeout - Timeout in milliseconds to wait for services.
|
|
51
|
+
* @returns Promise that resolves to true when watching has started.
|
|
52
|
+
*/
|
|
53
|
+
start(timeout?: number): Promise<boolean>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Get current values of all watched parameters.
|
|
57
|
+
*
|
|
58
|
+
* @param options - Optional request options (timeout, signal).
|
|
59
|
+
* @returns Promise that resolves to an array of Parameter objects.
|
|
60
|
+
*/
|
|
61
|
+
getCurrentValues(options?: {
|
|
62
|
+
timeout?: number;
|
|
63
|
+
signal?: AbortSignal;
|
|
64
|
+
}): Promise<Parameter[]>;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Add a parameter name to the watch list.
|
|
68
|
+
*
|
|
69
|
+
* @param name - Parameter name to watch.
|
|
70
|
+
*/
|
|
71
|
+
addParameter(name: string): void;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Remove a parameter name from the watch list.
|
|
75
|
+
*
|
|
76
|
+
* @param name - Parameter name to stop watching.
|
|
77
|
+
* @returns True if the parameter was in the watch list.
|
|
78
|
+
*/
|
|
79
|
+
removeParameter(name: string): boolean;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Check if the watcher has been destroyed.
|
|
83
|
+
*
|
|
84
|
+
* @returns True if destroyed.
|
|
85
|
+
*/
|
|
86
|
+
isDestroyed(): boolean;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Destroy the watcher and clean up resources.
|
|
90
|
+
* Unsubscribes from parameter events and destroys the parameter client.
|
|
91
|
+
*/
|
|
92
|
+
destroy(): void;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Event emitted when watched parameters change.
|
|
96
|
+
*
|
|
97
|
+
* @event change
|
|
98
|
+
* @param params - Array of changed parameters (ParameterValue messages).
|
|
99
|
+
*/
|
|
100
|
+
on(event: 'change', listener: (params: any[]) => void): this;
|
|
101
|
+
once(event: 'change', listener: (params: any[]) => void): this;
|
|
102
|
+
emit(event: 'change', params: any[]): boolean;
|
|
103
|
+
}
|
|
104
|
+
}
|
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
|
+
}
|