Skip to content

Commit aa9f8d7

Browse files
committed
Add getClock method to Node interface (osrf#43)
Useful for getting the current time from the Clock instance. Signed-off-by: Jacob Perron <jacob@openrobotics.org>
1 parent 6cfc727 commit aa9f8d7

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.ros2.rcljava.service.RMWRequestId;
3939
import org.ros2.rcljava.service.Service;
4040
import org.ros2.rcljava.subscription.Subscription;
41+
import org.ros2.rcljava.time.Clock;
4142
import org.ros2.rcljava.timer.Timer;
4243
import org.ros2.rcljava.timer.WallTimer;
4344

@@ -46,6 +47,11 @@
4647
* A Node must be created via @{link RCLJava#createNode(String)}
4748
*/
4849
public interface Node extends Disposable {
50+
/**
51+
* @return The nodes @{link Clock}.
52+
*/
53+
Clock getClock();
54+
4955
/**
5056
* return All the @{link Client}s that have been created by this instance.
5157
*/

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,13 @@ private static native <T extends MessageDefinition> long nativeCreatePublisherHa
220220
private static native <T extends MessageDefinition> long nativeCreateSubscriptionHandle(
221221
long handle, Class<T> messageType, String topic, long qosProfileHandle);
222222

223+
/**
224+
* {@inheritDoc}
225+
*/
226+
public final Clock getClock() {
227+
return this.clock;
228+
}
229+
223230
/**
224231
* {@inheritDoc}
225232
*/

0 commit comments

Comments
 (0)