diff --git a/test/types/index.test-d.ts b/test/types/index.test-d.ts index 83c982af..e6bad0ad 100644 --- a/test/types/index.test-d.ts +++ b/test/types/index.test-d.ts @@ -7,6 +7,7 @@ const NODE_NAME = 'test_node'; const LIFECYCLE_NODE_NAME = 'lifecycle_test_node'; const TYPE_CLASS = 'std_msgs/msg/String'; const TOPIC = 'topic'; +const SERVICE_NAME = 'service'; const MSG = rclnodejs.createMessageObject(TYPE_CLASS); MSG.data = ''; @@ -27,6 +28,7 @@ expectType(rclnodejs.DistroUtils.getDistroName(2105)); // ---- Context ----- expectType(rclnodejs.Context.defaultContext()); +expectType(rclnodejs.Context.defaultContext().domainId()); // ---- NodeOptions ---- const nodeOptions = new rclnodejs.NodeOptions(); @@ -69,6 +71,8 @@ expectType>(node.getPublishersInfoByTopic('topic', false)); expectType>(node.getSubscriptionsInfoByTopic('topic', false)); expectType(node.countPublishers(TOPIC)); expectType(node.countSubscribers(TOPIC)); +expectType(node.countClients(SERVICE_NAME)); +expectType(node.countServices(SERVICE_NAME)); expectType>( rclnodejs.Node.getDefaultOptions() ); @@ -229,6 +233,9 @@ expectType(timer.timeSinceLastCall()); expectType(timer.timeUntilNextCall()); expectType(timer.isCanceled()); expectType(timer.cancel()); +expectType(timer.changeTimerPeriod(BigInt(100000))); +expectType(timer.timerPeriod()); +expectType(timer.callTimerWithInfo()); // ---- Rate ---- const rate = await node.createRate(1); diff --git a/types/context.d.ts b/types/context.d.ts index 38292463..07a73b17 100644 --- a/types/context.d.ts +++ b/types/context.d.ts @@ -87,5 +87,11 @@ declare module 'rclnodejs' { * @returns The default Context */ static defaultContext(): Context; + + /** + * Get the domain ID of this context. + * @returns domain ID of this context + */ + domainId(): number; } } diff --git a/types/node.d.ts b/types/node.d.ts index 5eeab78f..89d5c6c7 100644 --- a/types/node.d.ts +++ b/types/node.d.ts @@ -782,5 +782,19 @@ declare module 'rclnodejs' { * @returns Number of subscribers on the given topic. */ countSubscribers(topic: string): number; + + /** + * Get the number of clients on a given service name. + * @param serviceName - The service name. + * @returns Number of clients. + */ + countClients(serviceName: string): number; + + /** + * Get the number of services on a given service name. + * @param serviceName - The service name. + * @returns Number of services. + */ + countServices(serviceName: string): number; } } diff --git a/types/publisher.d.ts b/types/publisher.d.ts index 89fe12f7..d849925a 100644 --- a/types/publisher.d.ts +++ b/types/publisher.d.ts @@ -14,5 +14,11 @@ declare module 'rclnodejs' { * @param message - The message to be sent. */ publish(message: MessageType | Buffer): void; + + /** + * Get the number of subscriptions to this publisher. + * @returns The number of subscriptions + */ + subscriptionCount(): number; } } diff --git a/types/subscription.d.ts b/types/subscription.d.ts index a0a41c9b..5e28c37a 100644 --- a/types/subscription.d.ts +++ b/types/subscription.d.ts @@ -66,5 +66,11 @@ declare module 'rclnodejs' { * @returns True if successful; false otherwise */ clearContentFilter(): boolean; + + /** + * Get the number of publishers to this subscription. + * @returns The number of publishers + */ + publisherCount(): number; } } diff --git a/types/timer.d.ts b/types/timer.d.ts index 04f0f880..8fc73f58 100644 --- a/types/timer.d.ts +++ b/types/timer.d.ts @@ -45,5 +45,23 @@ declare module 'rclnodejs' { * @returns The interval value in nanoseconds */ timeUntilNextCall(): bigint; + + /** + * Change the timer period. + * @param period - The new period in nanoseconds. + */ + changeTimerPeriod(period: bigint): void; + + /** + * Get the timer period. + * @return The period in nanoseconds. + */ + timerPeriod(): bigint; + + /** + * Call a timer and starts counting again, retrieves actual and expected call time. + * @return - The timer information. + */ + callTimerWithInfo(): object; } }