Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Commit 8861658

Browse files
author
Juan Ignacio Ubeira
authored
Merge pull request #263 from drigz/avoid-simtime-crash
simtime: use time=0 by default
2 parents 13bcbee + 591f71d commit 8861658

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

rosjava/src/main/java/org/ros/time/ClockTopicTimeProvider.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ public Subscriber<rosgraph_msgs.Clock> getSubscriber() {
5757

5858
@Override
5959
public Time getCurrentTime() {
60-
Preconditions.checkNotNull(clock);
60+
// When using simulation time, the ROS Time API will return time=0 until it has received a
61+
// message from the /clock topic.
62+
if (clock == null) {
63+
return new Time();
64+
}
65+
6166
synchronized (mutex) {
6267
return new Time(clock.getClock());
6368
}

0 commit comments

Comments
 (0)