Hello,
I was wondering how is calcualted or read on the Thingy firmware the variable w for the quaternion used in the Gyroscope readings.
Looking into m_motion.c in the handler drv_motion_evt_handler() I see the snippet below, where `data.w = p_quat[0]` happens, but I cannot track down where the p_quat[0] is calculated.
Could you give me some pointers?
Thanks!
case DRV_MOTION_EVT_QUAT: { APP_ERROR_CHECK_BOOL(size == sizeof(int32_t) * 4); ble_tms_quat_t data; int32_t * p_quat = (int32_t *)p_data; data.w = p_quat[0]; data.x = p_quat[1]; data.y = p_quat[2]; data.z = p_quat[3]; #if NRF_LOG_ENABLED static const uint8_t QUAT_ELEMENTS = 4; double f_buf; char buffer[QUAT_ELEMENTS][7]; for (uint8_t i = 0; i < QUAT_ELEMENTS; i++) { f_buf = (double)p_quat[i]; f_buf = f_buf/(1<<30); sprintf(buffer[i], "% 1.3f", f_buf); } NRF_LOG_DEBUG("DRV_MOTION_EVT_QUAT: w:%s x:%s y:%s z:%s\r\n", nrf_log_push(buffer[0]), nrf_log_push(buffer[1]), nrf_log_push(buffer[2]), nrf_log_push(buffer[3])); #endif (void)ble_tms_quat_set(&m_tms, &data); } break;