41 std::getline(str,
line);
43 std::stringstream lineStream(
line);
47 while (std::getline(lineStream, cell,
';'))
52 if (!lineStream && cell.empty())
65 data.readNextRow(str);
73 for (
int i = 0; i <
fifoSize - 1; i++)
102 double minAllowedDiff = (1.0 - tol) * diff;
103 double maxAllowedDiff = (1.0 + tol) * diff;
108 if ((diffTime >= minAllowedDiff) && (diffTime <= maxAllowedDiff))
138 double start =
sec + nanoSec * 1E-9;
159 bool timeStampVerified =
false;
160 double delta_time_abs = 0;
163 timeStampVerified =
true;
169 if (timeStampVerified ==
false)
201 sec = (uint32_t)(curtick / 1000000);
202 nanoSec = (uint32_t)(1000 * (curtick % 1000000));
219 sec = (uint32_t) corrTime;
220 double frac = corrTime -
sec;
221 nanoSec = (uint32_t) (1E9 * frac);
236 tick = 1000000 * (uint64_t)systemtime_sec + (uint64_t)systemtime_nanosec / 1000;
246 double relTicks = 1.0e6 * relSystemTimestamp;
251 double systemTimestamp = (double)systemtime_sec + 1.0e-9 * (
double)systemtime_nanosec;
254 double relSystemTimestamp = systemTimestamp - this->
FirstTimeStamp();
258 uint32_t tick_offset = (uint32_t)(0xFFFFFFFF &
FirstTick());
259 tick = (uint64_t)std::round(relTicks + tick_offset);
266 uint64_t lidar_ticks = 0;
268 tick = (uint32_t)lidar_ticks;
274 delta_time_abs = fabs(relTimeStamp1 - relTimeStamp2);
292 std::vector<uint64_t> tickFifoUnwrap;
293 std::vector<double> clockFifoUnwrap;
296 uint64_t tickOffset = 0;
297 clockFifoUnwrap[0] = 0.00;
298 tickFifoUnwrap[0] = 0;
302 uint64_t tickDivisor = 0x100000000;
310 tickOffset += tickDivisor;
322 sum_xy += tickFifoUnwrap[i] * clockFifoUnwrap[i];
323 sum_x += tickFifoUnwrap[i];
324 sum_y += clockFifoUnwrap[i];
325 sum_xx += tickFifoUnwrap[i] * tickFifoUnwrap[i];
329 double m = (
fifoSize * sum_xy - sum_x * sum_y) / (
fifoSize * sum_xx - sum_x * sum_x);
335 double yesti = m * tickFifoUnwrap[i];
336 double abs_delta_time = 0;
360 bool SoftwarePLL::getDemoFileData(std::string fileName, std::vector<uint32_t>& tickVec,std::vector<uint32_t>& secVec, std::vector<uint32_t>& nanoSecVec )
362 std::ifstream file(fileName);
369 while (file >> row) {
372 uint32_t tickVal = (uint32_t)std::stoi(row[0]);
373 uint32_t secVal = (uint32_t)std::stoi(row[1]);
374 uint32_t nanoSecVal = (uint32_t)std::stoi(row[2]);
375 tickVec.push_back(tickVal);
376 secVec.push_back(secVal);
377 nanoSecVec.push_back(nanoSecVal);
391 std::cout <<
"Running testbed for SofwarePLL" << std::endl;
392 uint32_t curtick = 0;
397 uint32_t nanoSec = 0;
398 double tickPerSec = 1E6;
399 uint32_t tickInc = 1000;
402 std::vector<uint32_t> tickVec;
403 std::vector<uint32_t> secVec;
404 std::vector<uint32_t> nanoSecVec;
407 bool testWithDataFile =
true;
408 if (testWithDataFile)
411 maxLoop = (int)tickVec.size();
414 for (
int i = 0; i < maxLoop; i++)
416 if (testWithDataFile)
418 curtick = tickVec[i];
420 nanoSec = nanoSecVec[i];
426 double deltaT = tickInc / tickPerSec;
427 nanoSec += (int) (deltaT * 1E9);
438 printf(
"Before correction: %3d.%09d\n",
sec, nanoSec);
439 uint32_t org_sec =
sec;
440 uint32_t org_nanoSec = nanoSec;
444 bool corrected =
false;
445 if ((nanoSec != org_nanoSec) || (
sec != org_sec))
449 printf(
"After correction : %3d.%09d %s %s\n",
sec, nanoSec, bRet ?
"OK " :
"DISMISS",
450 corrected ?
"MODI." :
"OK ");
457 #ifdef softwarePLL_MAINTEST
458 int main(
int argc,
char **argv)
460 printf(
"Test for softwarePLL-Class\n");