56 int64_t t_start = _apps_time_monotonic_ns();
61 imu_data_t *arr = pipe_validate_imu_data_t(data, bytes, &n_packets);
75 std::cout <<
"number of IMU packets: " << n_packets << std::endl;
77 if (!arr || n_packets <= 0)
86 std::vector<ov_core::ImuData> imu_batch;
87 imu_batch.reserve(n_packets);
89 for (
int i = 0; i < n_packets; ++i)
93 ov_core::ImuData sample;
94 sample.timestamp = arr[i].timestamp_ns * 1e-9;
95 sample.wm = Eigen::Vector3d(arr[i].gyro_rad[0], arr[i].gyro_rad[1], arr[i].gyro_rad[2]);
96 sample.am = Eigen::Vector3d(arr[i].accl_ms2[0], arr[i].accl_ms2[1], arr[i].accl_ms2[2]);
102 if (time_diff > 1000000)
109 imu_batch.push_back(std::move(sample));
112 if (imu_batch.empty())
117 std::lock_guard<std::mutex> lk(
reset_mtx);
126 int imu_batch_size = (
imu_model == IMU_MODEL_BMI270) ? 800 : 330;
131 int64_t t_end = _apps_time_monotonic_ns();
132 double dt_ms = (double)(t_end - t_start) / 1e6;
135 printf(
"WARNING: IMU callback took too long: %8.3f ms\n", dt_ms);
140 std::lock_guard<std::mutex> lk(
reset_mtx);
194 pipe_client_set_helper_thread_priority(
IMU_CH, THREAD_PRIORITY_RT_HIGH);
196 int flags = CLIENT_FLAG_EN_SIMPLE_HELPER;
199 IMU_RECOMMENDED_READ_BUF_SIZE * 2) != 0)
201 fprintf(stderr,
"failed to open imu client pipe\n");