MCPcopy Create free account
hub / github.com/brytsknguyen/slict / SyncData

Method SyncData

src/SensorSync.cpp:498–640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

496 }
497
498 void SyncData()
499 {
500 while (true)
501 {
502 /* #region Probing the key buffers ----------------------------------------------------------------------*/
503
504 // Case 0: If any buffer is empty, then loop until all have data
505 if (merged_cloud_buf.empty() || ImuEmpty())
506 {
507 std::this_thread::sleep_for(std::chrono::milliseconds(10));
508 continue;
509 }
510
511 // Case 1: If latest imu data is still earlier than the earliest
512 // feature message, then wait for these measurements to catch up:
513
514 // |___________[mfc]___mfc___mfc____________
515 // |_imu_[imu]______________________________
516 // |----------------------------------------> t+
517 if (merged_cloud_buf.front().endTime > ImuEndTime())
518 {
519 std::this_thread::sleep_for(std::chrono::milliseconds(10));
520 continue;
521 }
522
523 // Case 2: If earliest imu data is later than the earliest mfc's
524 // end time, then discard the earliest cloud message.
525 // This should only occur at the beginning
526
527 // |_[mfc]___mfc___mfc__mfc________________
528 // |_____________________[imu]_imu_imu_____
529 // |---------------------------------------> t+
530 if (merged_cloud_buf.front().endTime < ImuStartTime())
531 {
532 printf(KYEL "Popping mfc. Start: %.3f, End: %.3f. Size: %d\n" RESET,
533 merged_cloud_buf.front().startTime,
534 merged_cloud_buf.front().endTime,
535 merged_cloud_buf.front().cloud->size());
536
537 merged_cloud_buf_mtx.lock();
538 merged_cloud_buf.pop_front();
539 merged_cloud_buf_mtx.unlock();
540 continue;
541 }
542
543 // Case 3: A regular scenario, extract all imu measurement in the scan period
544
545 // |________mfc___mfc___mfc________________
546 // |_imu_imu_imu_imu_______________________
547 // |---------------------------------------> t+
548
549 // Extract the cloud packet
550 CloudPacket merged_cloud = merged_cloud_buf.front();
551 merged_cloud_buf_mtx.lock();
552 merged_cloud_buf.pop_front();
553 merged_cloud_buf_mtx.unlock();
554
555 slict::FeatureCloud msg;

Callers

nothing calls this directly

Calls 4

emptyMethod · 0.80
publishCloudFunction · 0.70
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected