public void GyroSensorDara(Vector3 gyroData) { float gyro_scale_val = 0; float cur_time = Time.time; gx = gyroData.x; gy = gyroData.y; gz = gyroData.z; MWData gyroCalibratedData = new MWData(); if (gyroDataCounter == 0) { gyro_scale_val = 0; cur_time = 0; gyroCalibratedData.GS_x = 0; gyroCalibratedData.GO_x = 0; lastGO = gyroCalibratedData.GO_x; gyroCalibratedData.GT_x = 0; lastGT = gyroCalibratedData.GT_x; last_time_gyro = Time.time; } if (gyroDataCounter > 0) { cur_time = Time.time; gyro_scale_val = (cur_time - last_time_gyro) * 1.0f; last_time_gyro = cur_time; gyroCalibratedData.GTotal_x = lastGTotal + gyroData.x; lastGTotal = gyroCalibratedData.GTotal_x; gyroCalibratedData.GS_x = (gyroData.x); //* gyro_scale_val; angle = lastGO + 360 * gyroCalibratedData.GS_x / 35200; if (angle > 360) { angle -= 360; } if (angle < 0) { angle += 360; } gyroCalibratedData.GO_x = angle; lastGO = gyroCalibratedData.GO_x; gyroCalibratedData.GT_x = lastGT + gyroCalibratedData.GS_x; lastGT = gyroCalibratedData.GT_x; } //if (gyroDataCounter == 100) { // gyro_x_offset = gyroCalibratedData.GTotal_x / 100; //} float orientAngle; if ((gyroCalibratedData.GO_x > 335 && gyroCalibratedData.GO_x < 361) || (gyroCalibratedData.GO_x > -1 && gyroCalibratedData.GO_x < 16)) { orientAngle = 12f; } else if (gyroCalibratedData.GO_x > 15 && gyroCalibratedData.GO_x < 61) { orientAngle = 1.5f; } else if (gyroCalibratedData.GO_x > 60 && gyroCalibratedData.GO_x < 104) { orientAngle = 3f; } else if (gyroCalibratedData.GO_x > 105 && gyroCalibratedData.GO_x < 151) { orientAngle = 4.5f; } else if (gyroCalibratedData.GO_x > 150 && gyroCalibratedData.GO_x < 196) { orientAngle = 6f; } else if (gyroCalibratedData.GO_x > 195 && gyroCalibratedData.GO_x < 241) { orientAngle = 7.5f; } else if (gyroCalibratedData.GO_x > 240 && gyroCalibratedData.GO_x < 286) { orientAngle = 9f; } else if (gyroCalibratedData.GO_x > 285 && gyroCalibratedData.GO_x < 336) { orientAngle = 10.5f; } else { orientAngle = 0f; } if (shouldLogData) { GyroHistoricalData.Add(gyroCalibratedData); string gyroLogData = "Unity:: Device Serial : " + deviceSerialNo + " -- " + gyroDataCounter + "," + cur_time + "," + gyro_scale_val + "," + gyroData.x + "," + gyroData.y + "," + gyroData.z + "," + gyroCalibratedData.GS_x + "," + gyroCalibratedData.GO_x + "," + gyroCalibratedData.GT_x + "," + orientAngle; linkManager.UpdateGyroLogNotification(gyroLogData); Debug.Log("Gyro Data send "); gyroDataCounter++; } }