aggregator
Public Member Functions | List of all members
aggregator::TimestampEstimator Class Reference

#include <TimestampEstimator.hpp>

Public Member Functions

 TimestampEstimator (base::Time window, base::Time initial_period, base::Time min_latency, int lost_threshold=2)
 
 TimestampEstimator (base::Time window, base::Time initial_period, int lost_threshold=2)
 
 TimestampEstimator (base::Time window=base::Time(), int lost_threshold=2)
 
void reset ()
 
void reset (base::Time window, int lost_threshold=2)
 
void reset (base::Time window, base::Time initial_period, int lost_threshold=2)
 
void reset (base::Time window, base::Time initial_period, base::Time min_latency, int lost_threshold=2)
 
base::Time update (base::Time ts)
 
base::Time update (base::Time ts, int64_t index)
 
void updateLoss ()
 
void updateReference (base::Time ts)
 
base::Time getPeriod () const
 
void shortenSampleList (double current)
 
int getLostSampleCount () const
 
bool haveEstimate () const
 
base::Time getLatency () const
 
base::Time getMaxJitter () const
 
TimestampEstimatorStatus getStatus () const
 
void dumpInternalState () const
 

Detailed Description

The timestamp estimator takes a stream of samples and determines a best guess for each of the samples timestamp.

It assumes that most samples will be received at the right period. It will not work if the reception period is completely random.

Constructor & Destructor Documentation

◆ TimestampEstimator() [1/3]

TimestampEstimator::TimestampEstimator ( base::Time  window,
base::Time  initial_period,
base::Time  min_latency,
int  lost_threshold = 2 
)

Creates a timestamp estimator

  • window the size of the window that should be used to the estimation. It should be an order of magnitude smaller than the period drift in the estimated stream
  • initial_period initial estimate for the period, used to fill the initial window.
  • min_latency the smallest amount of latency between the reference timestamps and the data timestamps
  • lost_threshold if that many calls to update() are out of bounds (i.e. the distance between the two timestamps are greater than the period), then we consider that we lost samples and update the timestamp accordingly. Set to 0 if you are sure that the acquisition latency is lower than the device period. Set to INT_MAX if you are sure to either not lose any samples or know about all lost samples and use updateLoss()/ update(base::Time,int)

◆ TimestampEstimator() [2/3]

TimestampEstimator::TimestampEstimator ( base::Time  window,
base::Time  initial_period,
int  lost_threshold = 2 
)

◆ TimestampEstimator() [3/3]

TimestampEstimator::TimestampEstimator ( base::Time  window = base::Time(),
int  lost_threshold = 2 
)

Member Function Documentation

◆ dumpInternalState()

void TimestampEstimator::dumpInternalState ( ) const

Dumps part of the estimator's internal state to std::cout

◆ getLatency()

base::Time TimestampEstimator::getLatency ( ) const

Returns the current latency estimate. This is valid only if updateReference() is called

◆ getLostSampleCount()

int TimestampEstimator::getLostSampleCount ( ) const

The total estimated count of lost samples so far

◆ getMaxJitter()

base::Time aggregator::TimestampEstimator::getMaxJitter ( ) const

Returns the maximum jitter duration estimated so far

It is reset to zero only on reset

◆ getPeriod()

base::Time TimestampEstimator::getPeriod ( ) const

The currently estimated period

◆ getStatus()

TimestampEstimatorStatus TimestampEstimator::getStatus ( ) const

Returns a data structure that represents the estimator's internal status

This is constant time

◆ haveEstimate()

bool TimestampEstimator::haveEstimate ( ) const

Returns true if updateLoss and getPeriod can give valid estimates

◆ reset() [1/4]

void TimestampEstimator::reset ( )

Resets this estimator to an initial state, reusing the same parameters

See the constructor documentation for parameter documentation

◆ reset() [2/4]

void TimestampEstimator::reset ( base::Time  window,
int  lost_threshold = 2 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ reset() [3/4]

void TimestampEstimator::reset ( base::Time  window,
base::Time  initial_period,
int  lost_threshold = 2 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ reset() [4/4]

void TimestampEstimator::reset ( base::Time  window,
base::Time  initial_period,
base::Time  min_latency,
int  lost_threshold = 2 
)

Changes the estimator parameters, and resets it to an initial state

See the constructor documentation for parameter documentation

◆ shortenSampleList()

void TimestampEstimator::shortenSampleList ( double  current)

Shortens the sample list so that the addition of time would not overflow the window. Calling this is strongly recommended if there is a chance of only calling updateLoss for long stretches of time

◆ update() [1/2]

base::Time TimestampEstimator::update ( base::Time  ts)

Updates the estimate and return the actual timestamp for +ts+

◆ update() [2/2]

base::Time TimestampEstimator::update ( base::Time  ts,
int64_t  index 
)

Updates the estimate and return the actual timestamp for +ts+, calculating lost samples from the index

◆ updateLoss()

void TimestampEstimator::updateLoss ( )

Updates the estimate for a known lost sample

◆ updateReference()

void TimestampEstimator::updateReference ( base::Time  ts)

Updates the estimate using a reference


The documentation for this class was generated from the following files: