Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
PacketStamper Class Reference

Supplies functionality for timestamping data packets. More...

#include <packetstamper.h>

Classes

struct  DataPair
 

Public Member Functions

 PacketStamper ()
 Default constructor. More...
 
void resetTosEstimation ()
 Reset the Time Of Sampling estimation parameters. More...
 
int64_t stampPacket (XsDataPacket &pack, XsDataPacket const &highest)
 Create 64 bit counter for a packet. More...
 

Static Public Member Functions

static int64_t calculateLargePacketCounter (int64_t frameCounter, int64_t lastCounter, int64_t boundary)
 Calculate the new large packet counter value based on frameCounter and the lastCounter. More...
 
static int64_t calculateLargeSampleTime (int64_t frameTime, int64_t lastTime)
 Calculate the new large sample time value based on frameTime and the lastTime. More...
 

Static Public Attributes

static const int64_t AWINDABOUNDARY = 0x100000000LL
 32 bit MT Sample Counter boundary More...
 
static const int64_t MTSCBOUNDARY = 0x00010000LL
 16 bit MT Sample Counter boundary More...
 
static const int64_t SC8BOUNDARY = 0x00000100LL
 8 bit Sample Counter boundary More...
 

Protected Member Functions

void estimateClockParameters ()
 Estimate the clock parameters based on the available data points. More...
 
void estimateTos (XsDataPacket &pack)
 Estimate the time of sampling for the supplied packet pack and update it. More...
 
int64_t estimateTosInternal (int64_t pid, int64_t toa)
 Estimate the time of sampling for the supplied pid. More...
 
bool rejectOutlier ()
 Remove the worst outlier from the known data points. More...
 

Protected Attributes

std::list< DataPairm_dataPoints
 The filtered history of interesting data items. More...
 
DataPair m_latest
 Latest known data (later data may arrive with a lower pid, which will not be put in this item) More...
 
DataPair m_linearize
 The very first item received, used to normalize to 0,0 so we have less computational issues with large numbers. More...
 
double m_rate
 The estimated clock rate per pid. More...
 
int m_rejectionCountdown
 A countdown value that is used after the input sanity check rejects input to reject subsequent samples as well. More...
 
double m_toa0
 The recomputed Time Of Arrival of PID 0. More...
 

Detailed Description

Supplies functionality for timestamping data packets.

This class can analyze a data packet and create a proper packet id for it.

Definition at line 73 of file packetstamper.h.

Constructor & Destructor Documentation

◆ PacketStamper()

PacketStamper::PacketStamper ( )

Default constructor.

Definition at line 83 of file packetstamper.cpp.

Member Function Documentation

◆ calculateLargePacketCounter()

int64_t PacketStamper::calculateLargePacketCounter ( int64_t  frameCounter,
int64_t  lastCounter,
int64_t  boundary 
)
static

Calculate the new large packet counter value based on frameCounter and the lastCounter.

Wraparound is at the given boundary

Parameters
[in]frameCounterThe frame counter
[in]lastCounterThe last counter
[in]boundarythe boundary at which to assume a wrap-around
Returns
The computed packet counter value
Note
If lastCounter < 0, returns frameCounter

Definition at line 106 of file packetstamper.cpp.

◆ calculateLargeSampleTime()

int64_t PacketStamper::calculateLargeSampleTime ( int64_t  frameTime,
int64_t  lastTime 
)
static

Calculate the new large sample time value based on frameTime and the lastTime.

Wraparound is at 864000000 (1 day @ 10kHz)

Parameters
[in]frameTimeThe frame time
[in]lastTimeThe last time
Returns
The computed packet counter value
Note
If lastTime < 0, returns frameTime

Definition at line 175 of file packetstamper.cpp.

◆ estimateClockParameters()

void PacketStamper::estimateClockParameters ( )
protected

Estimate the clock parameters based on the available data points.

Uses a least-square estimation to fit a line through the known dataset and then shifts the line down to ensure the TOA >= ETOS constraint holds

Definition at line 203 of file packetstamper.cpp.

◆ estimateTos()

void PacketStamper::estimateTos ( XsDataPacket pack)
protected

Estimate the time of sampling for the supplied packet pack and update it.

Definition at line 191 of file packetstamper.cpp.

◆ estimateTosInternal()

int64_t PacketStamper::estimateTosInternal ( int64_t  pid,
int64_t  toa 
)
protected

Estimate the time of sampling for the supplied pid.

This function will estimate the time of samplinmg based on the supplied PID. If both PID and TOA are acceptable values, they will be used to update the estimation parameters.

The current algorithm expects the values to be estimated to be constant for the lifetime of the object.

Parameters
pidThe packet ID to estimate the time of sampling for.
toaThe time of arrival associated with this pid
Returns
The estimated time of sampling.

Definition at line 284 of file packetstamper.cpp.

◆ rejectOutlier()

bool PacketStamper::rejectOutlier ( )
protected

Remove the worst outlier from the known data points.

Only items that are more than the estimated rate off from the current estimation are considered outliers

Returns
true if anything was rejected, false otherwise

Definition at line 252 of file packetstamper.cpp.

◆ resetTosEstimation()

void PacketStamper::resetTosEstimation ( )

Reset the Time Of Sampling estimation parameters.

Definition at line 89 of file packetstamper.cpp.

◆ stampPacket()

int64_t PacketStamper::stampPacket ( XsDataPacket pack,
XsDataPacket const &  highestPacket 
)

Create 64 bit counter for a packet.

Wrap when new XsDataPacket is too far away from the previous XsDataPacket in time. Use half cache size as reasonable time difference When infinite cache, simply wrap when new is lower than old

Parameters
packThe XsDataPacket that needs its 64-bit sample counter updated
highestPacketThe highest packet available for the current device, it will be updated if the new counter is higher than the stored value.
Returns
The computed counter for the packet.

Definition at line 133 of file packetstamper.cpp.

Member Data Documentation

◆ AWINDABOUNDARY

const int64_t PacketStamper::AWINDABOUNDARY = 0x100000000LL
static

32 bit MT Sample Counter boundary

Definition at line 79 of file packetstamper.h.

◆ m_dataPoints

std::list<DataPair> PacketStamper::m_dataPoints
protected

The filtered history of interesting data items.

Definition at line 102 of file packetstamper.h.

◆ m_latest

DataPair PacketStamper::m_latest
protected

Latest known data (later data may arrive with a lower pid, which will not be put in this item)

Definition at line 100 of file packetstamper.h.

◆ m_linearize

DataPair PacketStamper::m_linearize
protected

The very first item received, used to normalize to 0,0 so we have less computational issues with large numbers.

Definition at line 101 of file packetstamper.h.

◆ m_rate

double PacketStamper::m_rate
protected

The estimated clock rate per pid.

Definition at line 105 of file packetstamper.h.

◆ m_rejectionCountdown

int PacketStamper::m_rejectionCountdown
protected

A countdown value that is used after the input sanity check rejects input to reject subsequent samples as well.

Definition at line 106 of file packetstamper.h.

◆ m_toa0

double PacketStamper::m_toa0
protected

The recomputed Time Of Arrival of PID 0.

Definition at line 104 of file packetstamper.h.

◆ MTSCBOUNDARY

const int64_t PacketStamper::MTSCBOUNDARY = 0x00010000LL
static

16 bit MT Sample Counter boundary

Definition at line 80 of file packetstamper.h.

◆ SC8BOUNDARY

const int64_t PacketStamper::SC8BOUNDARY = 0x00000100LL
static

8 bit Sample Counter boundary

Definition at line 81 of file packetstamper.h.


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


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:22