Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
SoftwarePLL Class Reference

class SoftwarePLL implements synchronisation between ticks and timestamp. See https://github.com/michael1309/SoftwarePLL/blob/master/README.md for details. More...

#include <softwarePLL.h>

Public Member Functions

double AllowedTimeDeviation () const
 
void AllowedTimeDeviation (double val)
 
double extraPolateRelativeTimeStamp (uint32_t tick)
 
uint32_t ExtrapolationDivergenceCounter () const
 
void ExtrapolationDivergenceCounter (uint32_t val)
 
int findDiffInFifo (double diff, double tol)
 
uint64_t FirstTick () const
 
void FirstTick (uint64_t val)
 
double FirstTimeStamp () const
 
void FirstTimeStamp (double val)
 
bool getCorrectedTimeStamp (uint32_t &sec, uint32_t &nanoSec, uint32_t tick)
 
bool GetCorrectedTimeStamp (uint32_t &sec, uint32_t &nanoSec, uint32_t tick)
 Computes the timestamp of a measurement from sensor ticks. More...
 
bool getDemoFileData (std::string fileName, std::vector< uint32_t > &tickVec, std::vector< uint32_t > &secVec, std::vector< uint32_t > &nanoSecVec)
 
double InterpolationSlope () const
 
void InterpolationSlope (double val)
 
bool IsInitialized () const
 
void IsInitialized (bool val)
 
bool IsInitialized () const
 Returns the initialization status, i.e. true, if SoftwarePLL is initialized, or false otherwise (inconsistent or not enough samples in the fifo buffer) More...
 
bool pushIntoFifo (double curTimeStamp, uint32_t curtick)
 
bool UpdatePLL (uint32_t sec, uint32_t nanoSec, uint32_t curtick)
 Updates PLL internale State should be called only with network send timestamps. More...
 
bool updatePLL (uint32_t sec, uint32_t nanoSec, uint32_t curtick)
 Updates PLL internale State should be called only with network send timestamps. More...
 
 ~SoftwarePLL ()
 
 ~SoftwarePLL ()
 Destructor of class SoftwarePLL. More...
 

Static Public Member Functions

static SoftwarePLLinstance ()
 
static SoftwarePLLInstance (const std::string &id="", int fifo_length=7)
 Creates an instance of SoftwarePLL or returns an existing one, given its id. More...
 
static void testbed ()
 

Public Attributes

int packeds_droped = 0
 

Static Public Attributes

static const int fifoSize = 7
 

Protected Member Functions

double AllowedTimeDeviation () const
 Returns the max. allowed time difference between estimated and measured timestamp time in seconds. More...
 
void AllowedTimeDeviation (double val)
 Set the max. allowed time difference between estimated and measured receive timestamp in seconds. More...
 
double ExtraPolateRelativeTimeStamp (uint32_t tick)
 Extrapolates and returns the measurement timestamp in seconds relative to FirstTimeStamp. The timestamp of a measurement in seconds can be estimated from sensor ticks by ExtraPolateRelativeTimeStamp(tick) + FirstTimeStamp(). More...
 
uint32_t ExtrapolationDivergenceCounter () const
 Returns the counter of extrapolated divergences (number of times the estimated and measured receive timestamp differed more than AllowedTimeDeviation. More...
 
void ExtrapolationDivergenceCounter (uint32_t val)
 Sets the counter of extrapolated divergences (number of times the estimated and measured receive timestamp differed more than AllowedTimeDeviation. More...
 
uint64_t FirstTick () const
 Returns the first sensor tick in the fifo buffer. More...
 
void FirstTick (uint64_t val)
 Sets the first sensor tick in the fifo buffer. More...
 
double FirstTimeStamp () const
 Returns the first timestamp in the fifo buffer in seconds. More...
 
void FirstTimeStamp (double val)
 Sets the first timestamp in the fifo buffer in seconds. More...
 
double InterpolationSlope () const
 Returns the interpolated slope (gradient of the regression line) More...
 
void InterpolationSlope (double val)
 Sets the interpolated slope (gradient of the regression line) More...
 
void IsInitialized (bool val)
 Sets the initialization status, i.e. true, if SoftwarePLL is initialized, or false otherwise (inconsistent or not enough samples in the fifo buffer) More...
 
bool PushIntoFifo (double curTimeStamp, uint32_t curtick)
 Pushes measurement timestamp and sensor ticks to the fifo, updates tick fifo and clock (timestamp) fifo. More...
 

Private Member Functions

bool nearSameTimeStamp (double relTimeStamp1, double relTimeStamp2)
 
bool NearSameTimeStamp (double relTimeStamp1, double relTimeStamp2)
 
SoftwarePLLoperator= (const SoftwarePLL &)
 
SoftwarePLLoperator= (const SoftwarePLL &)
 
 SoftwarePLL ()
 
 SoftwarePLL (const SoftwarePLL &)
 
 SoftwarePLL (int fifo_length=7)
 
 SoftwarePLL (const SoftwarePLL &)
 
bool updateInterpolationSlope ()
 
bool UpdateInterpolationSlope ()
 

Private Attributes

double allowedTimeDeviation
 
double AllowedTimeDeviation_
 
double clockFifo [fifoSize]
 
std::vector< double > ClockFifo_
 
double dClockDiffFeedBack
 
double dTAvgFeedback
 
uint32_t extrapolationDivergenceCounter
 
uint32_t ExtrapolationDivergenceCounter_
 
const int FifoSize_
 
uint64_t firstTick
 
uint64_t FirstTick_
 
double firstTimeStamp
 
double FirstTimeStamp_
 
double interpolationSlope
 
double InterpolationSlope_
 
bool isInitialized
 
bool IsInitialized_
 
uint32_t lastcurtick = 0
 
uint32_t Lastcurtick_ = 0
 
uint32_t lastValidTick
 
double lastValidTimeStamp
 
uint32_t mostRecentNanoSec
 
uint32_t mostRecentSec
 
double mostRecentTimeStamp
 
int numberValInFifo
 
int NumberValInFifo_
 
uint32_t tickFifo [fifoSize]
 
std::vector< uint32_t > TickFifo_
 

Static Private Attributes

static std::map< std::string, SoftwarePLL * > _instances
 
static const double MaxAllowedTimeDeviation = 0.1
 
static const double MaxAllowedTimeDeviation_ = 0.1
 
static const uint32_t MaxExtrapolationCounter = 20
 
static const uint32_t MaxExtrapolationCounter_ = 20
 

Detailed Description

class SoftwarePLL implements synchronisation between ticks and timestamp. See https://github.com/michael1309/SoftwarePLL/blob/master/README.md for details.

Definition at line 20 of file softwarePLL.h.

Constructor & Destructor Documentation

SoftwarePLL::~SoftwarePLL ( )
inline

Definition at line 29 of file softwarePLL.h.

SoftwarePLL::SoftwarePLL ( )
inlineprivate

Definition at line 111 of file softwarePLL.h.

SoftwarePLL::SoftwarePLL ( const SoftwarePLL )
private
SoftwarePLL::~SoftwarePLL ( )

Destructor of class SoftwarePLL.

SoftwarePLL::SoftwarePLL ( int  fifo_length = 7)
inlineprivate

Definition at line 186 of file SoftwarePLL.h.

SoftwarePLL::SoftwarePLL ( const SoftwarePLL )
private

Member Function Documentation

double SoftwarePLL::AllowedTimeDeviation ( ) const
inline

Definition at line 66 of file softwarePLL.h.

void SoftwarePLL::AllowedTimeDeviation ( double  val)
inline

Definition at line 69 of file softwarePLL.h.

double SoftwarePLL::AllowedTimeDeviation ( ) const
inlineprotected

Returns the max. allowed time difference between estimated and measured timestamp time in seconds.

Returns
allowed time difference between estimated and measured timestamp

Definition at line 125 of file SoftwarePLL.h.

void SoftwarePLL::AllowedTimeDeviation ( double  val)
inlineprotected

Set the max. allowed time difference between estimated and measured receive timestamp in seconds.

Parameters
[in]valallowed time difference between estimated and measured timestamp

Definition at line 132 of file SoftwarePLL.h.

double SoftwarePLL::extraPolateRelativeTimeStamp ( uint32_t  tick)

Definition at line 90 of file softwarePLL.cpp.

double SoftwarePLL::ExtraPolateRelativeTimeStamp ( uint32_t  tick)
protected

Extrapolates and returns the measurement timestamp in seconds relative to FirstTimeStamp. The timestamp of a measurement in seconds can be estimated from sensor ticks by ExtraPolateRelativeTimeStamp(tick) + FirstTimeStamp().

Parameters
ticksensor ticks
Returns
measurement timestamp in seconds relative to FirstTimeStamp

Definition at line 72 of file SoftwarePLL.cpp.

uint32_t SoftwarePLL::ExtrapolationDivergenceCounter ( ) const
inline

Definition at line 72 of file softwarePLL.h.

void SoftwarePLL::ExtrapolationDivergenceCounter ( uint32_t  val)
inline

Definition at line 75 of file softwarePLL.h.

uint32_t SoftwarePLL::ExtrapolationDivergenceCounter ( ) const
inlineprotected

Returns the counter of extrapolated divergences (number of times the estimated and measured receive timestamp differed more than AllowedTimeDeviation.

Returns
counter of extrapolated divergences

Definition at line 139 of file SoftwarePLL.h.

void SoftwarePLL::ExtrapolationDivergenceCounter ( uint32_t  val)
inlineprotected

Sets the counter of extrapolated divergences (number of times the estimated and measured receive timestamp differed more than AllowedTimeDeviation.

Parameters
[in]valcounter of extrapolated divergences

Definition at line 146 of file SoftwarePLL.h.

int SoftwarePLL::findDiffInFifo ( double  diff,
double  tol 
)

Definition at line 99 of file softwarePLL.cpp.

uint64_t SoftwarePLL::FirstTick ( ) const
inline

Definition at line 48 of file softwarePLL.h.

void SoftwarePLL::FirstTick ( uint64_t  val)
inline

Definition at line 51 of file softwarePLL.h.

uint64_t SoftwarePLL::FirstTick ( ) const
inlineprotected

Returns the first sensor tick in the fifo buffer.

Returns
first sensor tick

Definition at line 83 of file SoftwarePLL.h.

void SoftwarePLL::FirstTick ( uint64_t  val)
inlineprotected

Sets the first sensor tick in the fifo buffer.

Parameters
[in]valfirst sensor tick

Definition at line 90 of file SoftwarePLL.h.

double SoftwarePLL::FirstTimeStamp ( ) const
inline

Definition at line 54 of file softwarePLL.h.

void SoftwarePLL::FirstTimeStamp ( double  val)
inline

Definition at line 57 of file softwarePLL.h.

double SoftwarePLL::FirstTimeStamp ( ) const
inlineprotected

Returns the first timestamp in the fifo buffer in seconds.

Returns
first timestamp

Definition at line 97 of file SoftwarePLL.h.

void SoftwarePLL::FirstTimeStamp ( double  val)
inlineprotected

Sets the first timestamp in the fifo buffer in seconds.

Parameters
[in]valfirst timestamp

Definition at line 104 of file SoftwarePLL.h.

bool SoftwarePLL::getCorrectedTimeStamp ( uint32_t &  sec,
uint32_t &  nanoSec,
uint32_t  tick 
)

Definition at line 183 of file softwarePLL.cpp.

bool SoftwarePLL::GetCorrectedTimeStamp ( uint32_t &  sec,
uint32_t &  nanoSec,
uint32_t  tick 
)

Computes the timestamp of a measurement from sensor ticks.

Parameters
[out]secEstimated system Timetamp (seconds)
[out]nanoSecEstimated system Timetamp (nanoseconds)
[in]ticksensor ticks
Returns
true if timestamp is computed, false otherwise (SoftwarePLL not initialized)

Definition at line 138 of file SoftwarePLL.cpp.

bool SoftwarePLL::getDemoFileData ( std::string  fileName,
std::vector< uint32_t > &  tickVec,
std::vector< uint32_t > &  secVec,
std::vector< uint32_t > &  nanoSecVec 
)
static SoftwarePLL& SoftwarePLL::instance ( )
inlinestatic

Definition at line 23 of file softwarePLL.h.

SoftwarePLL & SoftwarePLL::Instance ( const std::string &  id = "",
int  fifo_length = 7 
)
static

Creates an instance of SoftwarePLL or returns an existing one, given its id.

Parameters
ididentifier of the instance, f.e. "Sensor1", "TIM571".
fifo_lengthlength of fifo (buffer size, i.e. number of ticks in fifo). Applied only for new instances of SoftwarePLL, existing instance will keep their buffer size.
Returns
instance of a SoftwarePLL

Definition at line 28 of file SoftwarePLL.cpp.

double SoftwarePLL::InterpolationSlope ( ) const
inline

Definition at line 60 of file softwarePLL.h.

void SoftwarePLL::InterpolationSlope ( double  val)
inline

Definition at line 63 of file softwarePLL.h.

double SoftwarePLL::InterpolationSlope ( ) const
inlineprotected

Returns the interpolated slope (gradient of the regression line)

Returns
interpolated slope

Definition at line 111 of file SoftwarePLL.h.

void SoftwarePLL::InterpolationSlope ( double  val)
inlineprotected

Sets the interpolated slope (gradient of the regression line)

Parameters
[in]valinterpolated slope

Definition at line 118 of file SoftwarePLL.h.

bool SoftwarePLL::IsInitialized ( ) const
inline

Definition at line 42 of file softwarePLL.h.

void SoftwarePLL::IsInitialized ( bool  val)
inline

Definition at line 45 of file softwarePLL.h.

bool SoftwarePLL::IsInitialized ( ) const
inline

Returns the initialization status, i.e. true, if SoftwarePLL is initialized, or false otherwise (inconsistent or not enough samples in the fifo buffer)

Returns
initialization status

Definition at line 67 of file SoftwarePLL.h.

void SoftwarePLL::IsInitialized ( bool  val)
inlineprotected

Sets the initialization status, i.e. true, if SoftwarePLL is initialized, or false otherwise (inconsistent or not enough samples in the fifo buffer)

Parameters
[in]valinitialization status

Definition at line 76 of file SoftwarePLL.h.

bool SoftwarePLL::nearSameTimeStamp ( double  relTimeStamp1,
double  relTimeStamp2 
)
private

Definition at line 198 of file softwarePLL.cpp.

bool SoftwarePLL::NearSameTimeStamp ( double  relTimeStamp1,
double  relTimeStamp2 
)
private

Definition at line 153 of file SoftwarePLL.cpp.

SoftwarePLL& SoftwarePLL::operator= ( const SoftwarePLL )
private
SoftwarePLL& SoftwarePLL::operator= ( const SoftwarePLL )
private
bool SoftwarePLL::pushIntoFifo ( double  curTimeStamp,
uint32_t  curtick 
)

Definition at line 69 of file softwarePLL.cpp.

bool SoftwarePLL::PushIntoFifo ( double  curTimeStamp,
uint32_t  curtick 
)
protected

Pushes measurement timestamp and sensor ticks to the fifo, updates tick fifo and clock (timestamp) fifo.

Parameters
curTimeStampmeasurement timestamp in seconds (receive time)
curticksensor ticks
Returns
always true

Definition at line 51 of file SoftwarePLL.cpp.

void SoftwarePLL::testbed ( )
static

Definition at line 307 of file softwarePLL.cpp.

bool SoftwarePLL::updateInterpolationSlope ( )
private

Definition at line 211 of file softwarePLL.cpp.

bool SoftwarePLL::UpdateInterpolationSlope ( )
private

Definition at line 166 of file SoftwarePLL.cpp.

bool SoftwarePLL::UpdatePLL ( uint32_t  sec,
uint32_t  nanoSec,
uint32_t  curtick 
)

Updates PLL internale State should be called only with network send timestamps.

Parameters
[in]secSystem Timetamp from received network packed
[in]nanoSecSystem Timestamp from received network packed
[in]curticksensor ticks
Returns
PLL is in valid state (true)

Definition at line 81 of file SoftwarePLL.cpp.

bool SoftwarePLL::updatePLL ( uint32_t  sec,
uint32_t  nanoSec,
uint32_t  curtick 
)

Updates PLL internale State should be called only with network send timestamps.

Parameters
secSystem Timetamp from received network packed
nsecSystem Timestamp from received network packed
curtickmicro Seconds since scanner start from SOPAS Datagram
Returns
PLL is in valid state (true)

Definition at line 125 of file softwarePLL.cpp.

Member Data Documentation

std::map< std::string, SoftwarePLL * > SoftwarePLL::_instances
staticprivate

Definition at line 197 of file SoftwarePLL.h.

double SoftwarePLL::allowedTimeDeviation
private

Definition at line 97 of file softwarePLL.h.

double SoftwarePLL::AllowedTimeDeviation_
private

Definition at line 179 of file SoftwarePLL.h.

double SoftwarePLL::clockFifo[fifoSize]
private

Definition at line 90 of file softwarePLL.h.

std::vector<double> SoftwarePLL::ClockFifo_
private

Definition at line 176 of file SoftwarePLL.h.

double SoftwarePLL::dClockDiffFeedBack
private

Definition at line 95 of file softwarePLL.h.

double SoftwarePLL::dTAvgFeedback
private

Definition at line 94 of file softwarePLL.h.

uint32_t SoftwarePLL::extrapolationDivergenceCounter
private

Definition at line 109 of file softwarePLL.h.

uint32_t SoftwarePLL::ExtrapolationDivergenceCounter_
private

Definition at line 185 of file SoftwarePLL.h.

const int SoftwarePLL::fifoSize = 7
static

Definition at line 82 of file softwarePLL.h.

const int SoftwarePLL::FifoSize_
private

Definition at line 172 of file SoftwarePLL.h.

uint64_t SoftwarePLL::firstTick
private

Definition at line 98 of file softwarePLL.h.

uint64_t SoftwarePLL::FirstTick_
private

Definition at line 180 of file SoftwarePLL.h.

double SoftwarePLL::firstTimeStamp
private

Definition at line 96 of file softwarePLL.h.

double SoftwarePLL::FirstTimeStamp_
private

Definition at line 178 of file SoftwarePLL.h.

double SoftwarePLL::interpolationSlope
private

Definition at line 103 of file softwarePLL.h.

double SoftwarePLL::InterpolationSlope_
private

Definition at line 182 of file SoftwarePLL.h.

bool SoftwarePLL::isInitialized
private

Definition at line 93 of file softwarePLL.h.

bool SoftwarePLL::IsInitialized_
private

Definition at line 177 of file SoftwarePLL.h.

uint32_t SoftwarePLL::lastcurtick = 0
private

Definition at line 99 of file softwarePLL.h.

uint32_t SoftwarePLL::Lastcurtick_ = 0
private

Definition at line 181 of file SoftwarePLL.h.

uint32_t SoftwarePLL::lastValidTick
private

Definition at line 92 of file softwarePLL.h.

double SoftwarePLL::lastValidTimeStamp
private

Definition at line 91 of file softwarePLL.h.

const double SoftwarePLL::MaxAllowedTimeDeviation = 0.1
staticprivate

Definition at line 87 of file softwarePLL.h.

const double SoftwarePLL::MaxAllowedTimeDeviation_ = 0.1
staticprivate

Definition at line 173 of file SoftwarePLL.h.

const uint32_t SoftwarePLL::MaxExtrapolationCounter = 20
staticprivate

Definition at line 88 of file softwarePLL.h.

const uint32_t SoftwarePLL::MaxExtrapolationCounter_ = 20
staticprivate

Definition at line 174 of file SoftwarePLL.h.

uint32_t SoftwarePLL::mostRecentNanoSec
private

Definition at line 101 of file softwarePLL.h.

uint32_t SoftwarePLL::mostRecentSec
private

Definition at line 100 of file softwarePLL.h.

double SoftwarePLL::mostRecentTimeStamp
private

Definition at line 102 of file softwarePLL.h.

int SoftwarePLL::numberValInFifo
private

Definition at line 86 of file softwarePLL.h.

int SoftwarePLL::NumberValInFifo_
private

Definition at line 171 of file SoftwarePLL.h.

int SoftwarePLL::packeds_droped = 0

Definition at line 83 of file softwarePLL.h.

uint32_t SoftwarePLL::tickFifo[fifoSize]
private

Definition at line 89 of file softwarePLL.h.

std::vector<uint32_t> SoftwarePLL::TickFifo_
private

Definition at line 175 of file SoftwarePLL.h.


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


sick_scan
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Wed May 5 2021 03:05:48