From 92529eac82b4ad95d0c12e5165521237d45cff5d Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Tue, 22 Sep 2020 09:34:18 -0700 Subject: [PATCH] Add getClock method to Node interface Useful for getting the current time from the Clock instance. Signed-off-by: Jacob Perron --- rcljava/src/main/java/org/ros2/rcljava/node/Node.java | 6 ++++++ rcljava/src/main/java/org/ros2/rcljava/node/NodeImpl.java | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/Node.java b/rcljava/src/main/java/org/ros2/rcljava/node/Node.java index 0a3ba7ad..c5c034a7 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/Node.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/Node.java @@ -33,6 +33,7 @@ import org.ros2.rcljava.service.RMWRequestId; import org.ros2.rcljava.service.Service; import org.ros2.rcljava.subscription.Subscription; +import org.ros2.rcljava.time.Clock; import org.ros2.rcljava.timer.Timer; import org.ros2.rcljava.timer.WallTimer; @@ -41,6 +42,11 @@ * A Node must be created via @{link RCLJava#createNode(String)} */ public interface Node extends Disposable { + /** + * @return The nodes @{link Clock}. + */ + Clock getClock(); + /** * return All the @{link Client}s that have been created by this instance. */ diff --git a/rcljava/src/main/java/org/ros2/rcljava/node/NodeImpl.java b/rcljava/src/main/java/org/ros2/rcljava/node/NodeImpl.java index 9fdc1c27..c8af8640 100644 --- a/rcljava/src/main/java/org/ros2/rcljava/node/NodeImpl.java +++ b/rcljava/src/main/java/org/ros2/rcljava/node/NodeImpl.java @@ -176,6 +176,13 @@ private static native long nativeCreatePublisherHa private static native long nativeCreateSubscriptionHandle( long handle, Class messageType, String topic, long qosProfileHandle); + /** + * {@inheritDoc} + */ + public final Clock getClock() { + return this.clock; + } + /** * {@inheritDoc} */