Skip to content

Commit 92529ea

Browse files
committed
Add getClock method to Node interface
Useful for getting the current time from the Clock instance. Signed-off-by: Jacob Perron <[email protected]>
1 parent 0b48353 commit 92529ea

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

rcljava/src/main/java/org/ros2/rcljava/node/Node.java

+6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.ros2.rcljava.service.RMWRequestId;
3434
import org.ros2.rcljava.service.Service;
3535
import org.ros2.rcljava.subscription.Subscription;
36+
import org.ros2.rcljava.time.Clock;
3637
import org.ros2.rcljava.timer.Timer;
3738
import org.ros2.rcljava.timer.WallTimer;
3839

@@ -41,6 +42,11 @@
4142
* A Node must be created via @{link RCLJava#createNode(String)}
4243
*/
4344
public interface Node extends Disposable {
45+
/**
46+
* @return The nodes @{link Clock}.
47+
*/
48+
Clock getClock();
49+
4450
/**
4551
* return All the @{link Client}s that have been created by this instance.
4652
*/

rcljava/src/main/java/org/ros2/rcljava/node/NodeImpl.java

+7
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,13 @@ private static native <T extends MessageDefinition> long nativeCreatePublisherHa
176176
private static native <T extends MessageDefinition> long nativeCreateSubscriptionHandle(
177177
long handle, Class<T> messageType, String topic, long qosProfileHandle);
178178

179+
/**
180+
* {@inheritDoc}
181+
*/
182+
public final Clock getClock() {
183+
return this.clock;
184+
}
185+
179186
/**
180187
* {@inheritDoc}
181188
*/

0 commit comments

Comments
 (0)