MCPcopy Create free account
hub / github.com/MIT-SPARK/Kimera-VIO / getInputPacket

Method getInputPacket

src/dataprovider/DataProviderModule.cpp:34–160  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32 stereo_matching_params_(stereo_matching_params) {}
33
34DataProviderModule::InputUniquePtr DataProviderModule::getInputPacket() {
35 // Look for a left frame inside the queue.
36 bool queue_state = false;
37 Frame::UniquePtr left_frame_payload = nullptr;
38 if (PIO::parallel_run_) {
39 queue_state = left_frame_queue_.popBlocking(left_frame_payload);
40 } else {
41 queue_state = left_frame_queue_.pop(left_frame_payload);
42 }
43
44 if (!queue_state) {
45 LOG_IF(WARNING, PIO::parallel_run_)
46 << "Module: " << name_id_ << " - queue is down";
47 VLOG_IF(1, !PIO::parallel_run_)
48 << "Module: " << name_id_ << " - queue is empty or down";
49 return nullptr;
50 }
51
52 CHECK(left_frame_payload);
53 const Timestamp& timestamp = left_frame_payload->timestamp_;
54
55 // Look for the synchronized right frame inside the queue.
56 Frame::UniquePtr right_frame_payload = nullptr;
57 PIO::syncQueue(timestamp, &right_frame_queue_, &right_frame_payload);
58 CHECK(right_frame_payload);
59
60 // Extract imu measurements between consecutive frames.
61 static Timestamp timestamp_last_frame = 0;
62 if (timestamp_last_frame == 0) {
63 // TODO(Toni): wouldn't it be better to get all IMU measurements up to this
64 // timestamp? We should add a method to the IMU buffer for that.
65 VLOG(1) << "Skipping first frame, because we do not have a concept of "
66 "a previous frame timestamp otherwise.";
67 timestamp_last_frame = timestamp;
68 return nullptr;
69 }
70
71 ImuMeasurements imu_meas;
72 CHECK_LT(timestamp_last_frame, timestamp);
73 utils::ThreadsafeImuBuffer::QueryResult query_result =
74 utils::ThreadsafeImuBuffer::QueryResult::kDataNeverAvailable;
75 bool log_error_once = true;
76 while (
77 (query_result = imu_data_.imu_buffer_.getImuDataInterpolatedUpperBorder(
78 timestamp_last_frame,
79 timestamp,
80 &imu_meas.timestamps_,
81 &imu_meas.acc_gyr_)) !=
82 utils::ThreadsafeImuBuffer::QueryResult::kDataAvailable) {
83 VLOG(1) << "No IMU data available. Reason:\n";
84 switch (query_result) {
85 case utils::ThreadsafeImuBuffer::QueryResult::kDataAvailable: {
86 LOG(FATAL) << "We should not be inside this while loop if IMU data is "
87 "available...";
88 break;
89 }
90 case utils::ThreadsafeImuBuffer::QueryResult::kQueueShutdown: {
91 LOG(INFO)

Callers

nothing calls this directly

Calls 4

StereoFrameClass · 0.85
popBlockingMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected