Package org.ros.time

Class NtpTimeProvider

java.lang.Object
org.ros.time.NtpTimeProvider
All Implemented Interfaces:
TimeProvider

public class NtpTimeProvider extends Object implements TimeProvider
Provides NTP synchronized wallclock (actual) time.
Author:
damonkohler@google.com (Damon Kohler)
  • Constructor Details

  • Method Details

    • updateTime

      public void updateTime() throws IOException
      Update the current time offset from the configured NTP host.
      Throws:
      IOException - : if ntpClient.getTime() fails too often.
    • startPeriodicUpdates

      public void startPeriodicUpdates(long period, TimeUnit unit)
      Starts periodically updating the current time offset periodically.

      The first time update happens immediately.

      Note that errors thrown while periodically updating time will be logged but not rethrown.

      Parameters:
      period - time between updates
      unit - unit of period
    • stopPeriodicUpdates

      public void stopPeriodicUpdates()
      Stops periodically updating the current time offset.
    • getCurrentTime

      public org.ros.message.Time getCurrentTime()
      Specified by:
      getCurrentTime in interface TimeProvider
      Returns:
      the current time of the system using rostime
    • setUpdateTimeSampleSize

      public void setUpdateTimeSampleSize(int sampleSize)
      Sets how many samples will be taken from the NTP server when calling updateTime().
      Parameters:
      sampleSize - Number of samples to take. It has to be > 0.