Skip to content

Commit

Permalink
Add getClock method to Node interface
Browse files Browse the repository at this point in the history
Useful for getting the current time from the Clock instance.

Signed-off-by: Jacob Perron <jacob@openrobotics.org>
  • Loading branch information
jacobperron committed Oct 20, 2020
1 parent 0b48353 commit 92529ea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rcljava/src/main/java/org/ros2/rcljava/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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.
*/
Expand Down
7 changes: 7 additions & 0 deletions rcljava/src/main/java/org/ros2/rcljava/node/NodeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,13 @@ private static native <T extends MessageDefinition> long nativeCreatePublisherHa
private static native <T extends MessageDefinition> long nativeCreateSubscriptionHandle(
long handle, Class<T> messageType, String topic, long qosProfileHandle);

/**
* {@inheritDoc}
*/
public final Clock getClock() {
return this.clock;
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit 92529ea

Please sign in to comment.