org.ros.time
Class RemoteUptimeClock

java.lang.Object
  extended by org.ros.time.RemoteUptimeClock

public class RemoteUptimeClock
extends java.lang.Object


Method Summary
 void calibrate(int sampleSize, double samplingDelayMillis)
          Good calibration settings will depend on the remote uptime provider.
static RemoteUptimeClock newDefault(TimeProvider timeProvider, java.util.concurrent.Callable<java.lang.Double> callable, double driftSensitivity, double errorReductionCoefficientSensitivity, int latencyOutlierFilterSampleSize, double latencyOutlierFilterThreshold)
          The provided Callable should return the current measuredRemoteUptime of the remote clock with minimal overhead since the run time of this call will be used to further improve the estimation of measuredRemoteUptime.
 double toLocalUptime(double remoteUptime)
          Returns the estimated local uptime in seconds for the given remote uptime.
 void update()
          Update this RemoteUptimeClock with the latest uptime from the remote clock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

newDefault

public static RemoteUptimeClock newDefault(TimeProvider timeProvider,
                                           java.util.concurrent.Callable<java.lang.Double> callable,
                                           double driftSensitivity,
                                           double errorReductionCoefficientSensitivity,
                                           int latencyOutlierFilterSampleSize,
                                           double latencyOutlierFilterThreshold)
The provided Callable should return the current measuredRemoteUptime of the remote clock with minimal overhead since the run time of this call will be used to further improve the estimation of measuredRemoteUptime.

Parameters:
timeProvider - the local time provider
callable - returns the current remote uptime in arbitrary units
driftSensitivity - the sensitivity to drift adjustments, must be in the range [0, 1]
errorReductionCoefficientSensitivity - the sensitivity to error reduction coefficient adjustments, must be in the range [0, 1]
Returns:
a new RemoteUptimeClock

calibrate

public void calibrate(int sampleSize,
                      double samplingDelayMillis)
Good calibration settings will depend on the remote uptime provider. In general, choosing a sample size around 10 and a delay that is large enough to include more than 100 uptime ticks will give reasonable results.

Parameters:
sampleSize - the number of samples to use for calibration
samplingDelayMillis - the delay in milliseconds between collecting each sample

update

public void update()
Update this RemoteUptimeClock with the latest uptime from the remote clock.

This will update internal estimates of drift and error. Ideally, it should be called periodically with a consistent time interval between updates (e.g. 10 seconds).


toLocalUptime

public double toLocalUptime(double remoteUptime)
Returns the estimated local uptime in seconds for the given remote uptime.

Parameters:
remoteUptime - the remote uptime to convert to local uptime
Returns:
the estimated local uptime in seconds at the provided remote uptime