softwarePLL.h
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 #ifndef SOFTWARE_PLL_H
3 #define SOFTWARE_PLL_H
4 
5 #ifdef _MSC_VER
6 #pragma warning(disable : 4996)
7 #endif
8 
9 #include <map>
10 #include <string>
11 #include <iostream>
12 #include <fstream> // std::ifstream
13 #include <cstring>
14 #include <sstream> // std::stringstream
15 #include <vector>
16 #include <cstdlib>
17 #include <iomanip>
18 #include <ctime>
19 #include <cstdint>
20 
22 {
23 public:
25  {
26  static SoftwarePLL _instance;
27  return _instance;
28  }
29 
31  {}
32 
33  bool pushIntoFifo(double curTimeStamp, uint64_t curtick);// update tick fifo and update clock (timestamp) fifo;
34  double extraPolateRelativeTimeStamp(uint64_t tick);
35 
36  bool getCorrectedTimeStamp(uint32_t &sec, uint32_t &nanoSec, uint32_t tick);
37  bool getCorrectedTimeStamp(uint32_t &sec, uint32_t &nanoSec, uint64_t tick);
38 
39  bool convSystemtimeToLidarTimestamp(uint32_t systemtime_sec, uint32_t systemtime_nanosec, uint32_t& tick);
40  bool convSystemtimeToLidarTimestamp(uint32_t systemtime_sec, uint32_t systemtime_nanosec, uint64_t& tick);
41 
42  bool getDemoFileData(std::string fileName, std::vector<uint32_t> &tickVec, std::vector<uint32_t> &secVec,
43  std::vector<uint32_t> &nanoSecVec);
44 
45  static void testbed();
46 
47  bool IsInitialized() const
48  {
50  {
51  return (offsetTimestampFirstLidarTick > 0);
52  }
54  {
55  return true; // no initialization required
56  }
57  else
58  {
59  return isInitialized;
60  }
61  }
62 
63  void IsInitialized(bool val)
64  { isInitialized = val; }
65 
66  uint64_t FirstTick() const
67  { return firstTick; }
68 
69  void FirstTick(uint64_t val)
70  { firstTick = val; }
71 
72  double FirstTimeStamp() const
73  { return firstTimeStamp; }
74 
75  void FirstTimeStamp(double val)
76  { firstTimeStamp = val; }
77 
78  double InterpolationSlope() const
79  { return interpolationSlope; }
80 
81  void InterpolationSlope(double val)
82  { interpolationSlope = val; }
83 
84  double AllowedTimeDeviation() const
85  { return allowedTimeDeviation; }
86 
87  void AllowedTimeDeviation(double val)
88  { allowedTimeDeviation = val; }
89 
92 
93  void ExtrapolationDivergenceCounter(uint32_t val)
95 
96  bool updatePLL(uint32_t sec, uint32_t nanoSec, uint32_t curtick);
97  bool updatePLL(uint32_t sec, uint32_t nanoSec, uint64_t curtick);
98 
99  int findDiffInFifo(double diff, double tol);
100 
101  static const int fifoSize = 7;
102  size_t packets_dropped = 0; // just for printing statusmessages when dropping packets
103  size_t packets_received = 0; // just for printing statusmessages when dropping packets
104  double max_abs_delta_time = 0; // just for printing statusmessages when dropping packets
105 
107  {
109  }
110 
111 private:
113  static const double MaxAllowedTimeDeviation;
114  static const uint32_t MaxExtrapolationCounter;
115  uint64_t tickFifo[fifoSize]; // = { 0 };
118  // uint64_t lastValidTick; // = 0;
119  bool isInitialized; // = false;
120  double dTAvgFeedback; // = 0.0;
121  double dClockDiffFeedBack; // = 0.0;
124  uint64_t firstTick;
125  uint64_t lastcurtick = 0;
126  uint32_t mostRecentSec;
130 
132  {
133  TICKS_TO_SYSTEM_TIMESTAMP = 0, // default: convert lidar ticks in microseconds to system timestamp by software-pll
134  TICKS_TO_MICROSEC_OFFSET_TIMESTAMP = 1, // optional tick-mode: convert lidar ticks in microseconds to timestamp by 1.0e-6*(curtick-firstTick)+firstSystemTimestamp
135  TICKS_TO_LIDAR_TIMESTAMP = 2 // optional tick-mode: convert lidar ticks in microseconds directly into a lidar timestamp by sec = tick/1000000, nsec = 1000*(tick%1000000)
136  // Note: Using tick_to_timestamp_mode = 2, the timestamps in ROS message headers will be in lidar time, not in system time. Lidar and system time can be very different.
137  // Using tick_to_timestamp_mode = 2 might cause unexpected results or error messages. We recommend using tick_to_timestamp_mode = 2 for special test cases only.
138  };
143 
144  bool nearSameTimeStamp(double relTimeStamp1, double relTimeStamp2, double& delta_time_abs);
145 
147 
149 
151  {
153  numberValInFifo = 0;
154  isInitialized = false;
155  }
156 
157  // verhindert, dass ein Objekt von au�erhalb von N erzeugt wird.
158  // protected, wenn man von der Klasse noch erben m�chte
159  SoftwarePLL(const SoftwarePLL &); /* verhindert, dass eine weitere Instanz via
160  Kopier-Konstruktor erstellt werden kann */
161  SoftwarePLL &operator=(const SoftwarePLL &); //Verhindert weitere Instanz durch Kopie
162 };
163 
164 
165 #endif
SoftwarePLL::extrapolationDivergenceCounter
uint32_t extrapolationDivergenceCounter
Definition: softwarePLL.h:148
SoftwarePLL
class SoftwarePLL implements synchronisation between ticks and timestamp. See https://github....
Definition: softwarePLL.h:21
SoftwarePLL::AllowedTimeDeviation
double AllowedTimeDeviation() const
Definition: softwarePLL.h:84
SoftwarePLL::SoftwarePLL
SoftwarePLL()
Definition: softwarePLL.h:150
SoftwarePLL::getDemoFileData
bool getDemoFileData(std::string fileName, std::vector< uint32_t > &tickVec, std::vector< uint32_t > &secVec, std::vector< uint32_t > &nanoSecVec)
SoftwarePLL::~SoftwarePLL
~SoftwarePLL()
Definition: softwarePLL.h:30
SoftwarePLL::updatePLL
bool updatePLL(uint32_t sec, uint32_t nanoSec, uint32_t curtick)
Definition: softwarePLL.cpp:191
SoftwarePLL::lastcurtick
uint64_t lastcurtick
Definition: softwarePLL.h:125
SoftwarePLL::packets_received
size_t packets_received
Definition: softwarePLL.h:103
SoftwarePLL::max_abs_delta_time
double max_abs_delta_time
Definition: softwarePLL.h:104
SoftwarePLL::firstTimeStamp
double firstTimeStamp
Definition: softwarePLL.h:122
SoftwarePLL::instance
static SoftwarePLL & instance()
Definition: softwarePLL.h:24
SoftwarePLL::FirstTick
uint64_t FirstTick() const
Definition: softwarePLL.h:66
SoftwarePLL::ticksToTimestampMode
TICKS_TO_TIMESTAMP_MODE ticksToTimestampMode
Definition: softwarePLL.h:139
SoftwarePLL::TICKS_TO_TIMESTAMP_MODE
TICKS_TO_TIMESTAMP_MODE
Definition: softwarePLL.h:131
SoftwarePLL::setTicksToTimestampMode
void setTicksToTimestampMode(int val)
Definition: softwarePLL.h:106
SoftwarePLL::convSystemtimeToLidarTimestamp
bool convSystemtimeToLidarTimestamp(uint32_t systemtime_sec, uint32_t systemtime_nanosec, uint32_t &tick)
Definition: softwarePLL.cpp:264
SoftwarePLL::getCorrectedTimeStamp
bool getCorrectedTimeStamp(uint32_t &sec, uint32_t &nanoSec, uint32_t tick)
Definition: softwarePLL.cpp:226
SoftwarePLL::AllowedTimeDeviation
void AllowedTimeDeviation(double val)
Definition: softwarePLL.h:87
SoftwarePLL::dClockDiffFeedBack
double dClockDiffFeedBack
Definition: softwarePLL.h:121
SoftwarePLL::InterpolationSlope
void InterpolationSlope(double val)
Definition: softwarePLL.h:81
SoftwarePLL::mostRecentTimeStamp
double mostRecentTimeStamp
Definition: softwarePLL.h:128
SoftwarePLL::isInitialized
bool isInitialized
Definition: softwarePLL.h:119
SoftwarePLL::ExtrapolationDivergenceCounter
void ExtrapolationDivergenceCounter(uint32_t val)
Definition: softwarePLL.h:93
SoftwarePLL::packets_dropped
size_t packets_dropped
Definition: softwarePLL.h:102
SoftwarePLL::numberValInFifo
int numberValInFifo
Definition: softwarePLL.h:112
SoftwarePLL::offsetTimestampFirstSystemMicroSec
uint32_t offsetTimestampFirstSystemMicroSec
Definition: softwarePLL.h:141
SoftwarePLL::MaxExtrapolationCounter
static const uint32_t MaxExtrapolationCounter
Definition: softwarePLL.h:114
SoftwarePLL::mostRecentNanoSec
uint32_t mostRecentNanoSec
Definition: softwarePLL.h:127
SoftwarePLL::offsetTimestampFirstSystemSec
uint32_t offsetTimestampFirstSystemSec
Definition: softwarePLL.h:140
SoftwarePLL::operator=
SoftwarePLL & operator=(const SoftwarePLL &)
SoftwarePLL::FirstTimeStamp
void FirstTimeStamp(double val)
Definition: softwarePLL.h:75
SoftwarePLL::lastValidTimeStamp
double lastValidTimeStamp
Definition: softwarePLL.h:117
SoftwarePLL::allowedTimeDeviation
double allowedTimeDeviation
Definition: softwarePLL.h:123
SoftwarePLL::ExtrapolationDivergenceCounter
uint32_t ExtrapolationDivergenceCounter() const
Definition: softwarePLL.h:90
sec
uint32_t sec(const rosTime &time)
Definition: sick_ros_wrapper.h:174
SoftwarePLL::TICKS_TO_MICROSEC_OFFSET_TIMESTAMP
@ TICKS_TO_MICROSEC_OFFSET_TIMESTAMP
Definition: softwarePLL.h:134
SoftwarePLL::testbed
static void testbed()
Definition: softwarePLL.cpp:389
SoftwarePLL::clockFifo
double clockFifo[fifoSize]
Definition: softwarePLL.h:116
SoftwarePLL::TICKS_TO_SYSTEM_TIMESTAMP
@ TICKS_TO_SYSTEM_TIMESTAMP
Definition: softwarePLL.h:133
SoftwarePLL::nearSameTimeStamp
bool nearSameTimeStamp(double relTimeStamp1, double relTimeStamp2, double &delta_time_abs)
Definition: softwarePLL.cpp:272
SoftwarePLL::offsetTimestampFirstLidarTick
uint64_t offsetTimestampFirstLidarTick
Definition: softwarePLL.h:142
SoftwarePLL::mostRecentSec
uint32_t mostRecentSec
Definition: softwarePLL.h:126
SoftwarePLL::FirstTimeStamp
double FirstTimeStamp() const
Definition: softwarePLL.h:72
SoftwarePLL::extraPolateRelativeTimeStamp
double extraPolateRelativeTimeStamp(uint64_t tick)
Definition: softwarePLL.cpp:91
SoftwarePLL::MaxAllowedTimeDeviation
static const double MaxAllowedTimeDeviation
Definition: softwarePLL.h:113
SoftwarePLL::tickFifo
uint64_t tickFifo[fifoSize]
Definition: softwarePLL.h:115
SoftwarePLL::FirstTick
void FirstTick(uint64_t val)
Definition: softwarePLL.h:69
SoftwarePLL::TICKS_TO_LIDAR_TIMESTAMP
@ TICKS_TO_LIDAR_TIMESTAMP
Definition: softwarePLL.h:135
SoftwarePLL::IsInitialized
bool IsInitialized() const
Definition: softwarePLL.h:47
sick_scan_base.h
SoftwarePLL::firstTick
uint64_t firstTick
Definition: softwarePLL.h:124
SoftwarePLL::updateInterpolationSlope
bool updateInterpolationSlope()
Definition: softwarePLL.cpp:285
SoftwarePLL::interpolationSlope
double interpolationSlope
Definition: softwarePLL.h:129
SoftwarePLL::pushIntoFifo
bool pushIntoFifo(double curTimeStamp, uint64_t curtick)
Definition: softwarePLL.cpp:70
SoftwarePLL::dTAvgFeedback
double dTAvgFeedback
Definition: softwarePLL.h:120
SoftwarePLL::findDiffInFifo
int findDiffInFifo(double diff, double tol)
Definition: softwarePLL.cpp:99
SoftwarePLL::fifoSize
static const int fifoSize
Definition: softwarePLL.h:101
SoftwarePLL::IsInitialized
void IsInitialized(bool val)
Definition: softwarePLL.h:63
SoftwarePLL::InterpolationSlope
double InterpolationSlope() const
Definition: softwarePLL.h:78


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:12