diff --git a/include/mynteye/types.h b/include/mynteye/types.h index da5f672..94cfff6 100644 --- a/include/mynteye/types.h +++ b/include/mynteye/types.h @@ -441,9 +441,11 @@ struct MYNTEYE_API ImgData { * IMU data. */ struct MYNTEYE_API ImuData { + /** Imu serial number */ + std::uint32_t serial_number; /** accel or gyro flag:1 for accel,2 for gyro,3 for both */ std::uint8_t flag; - /** IMU timestamp in 0.01ms */ + /** IMU timestamp in 1us */ std::uint64_t timestamp; /** IMU accelerometer data for 3-axis: X, Y, Z. */ double accel[3]; diff --git a/src/internal/motions.cc b/src/internal/motions.cc index 3828b54..871cdde 100644 --- a/src/internal/motions.cc +++ b/src/internal/motions.cc @@ -47,18 +47,19 @@ void Motions::SetMotionCallback(motion_callback_t callback) { // static_cast(-seg.offset) > packet.timestamp) { // LOG(WARNING) << "Imu timestamp offset is incorrect"; // } + imu->serial_number = seg.serial_number; imu->timestamp = seg.timestamp; imu->flag = seg.flag; imu->temperature = seg.temperature / 326.8f + 25; - if(imu->flag == 1) { + if (imu->flag == 1) { imu->accel[0] = seg.aceel_or_gyro[0] * 12.f / 0x10000; imu->accel[1] = seg.aceel_or_gyro[1] * 12.f / 0x10000; imu->accel[2] = seg.aceel_or_gyro[2] * 12.f / 0x10000; imu->gyro[0] = 0; imu->gyro[1] = 0; imu->gyro[2] = 0; - } else if(imu->flag == 2) { + } else if (imu->flag == 2) { imu->accel[0] = 0; imu->accel[1] = 0; imu->accel[2] = 0; @@ -68,7 +69,7 @@ void Motions::SetMotionCallback(motion_callback_t callback) { } else { imu->Reset(); } - + std::lock_guard _(mtx_datas_); motion_data_t data = {imu}; motion_datas_.push_back(data);