Ejemplo n.º 1
0
 void INotifyDelegate.OnIMUDataUpdate(string deviceId, float[] acc, float[] gyro, float[] mag, float[] quat)
 {
     if (sensorEventDict.ContainsKey(deviceId))
     {
         var accVal  = new Vector3(acc[0], acc[1], acc[2]);
         var gyroVal = new Vector3(gyro[0], gyro[1], gyro[2]);
         var magVal  = new Vector3(mag[0], mag[1], mag[2]);
         var quatVal = new Quaternion(quat[0], quat[1], quat[2], quat[3]);
         var raw     = new SensorData {
             acc = accVal, gyro = gyroVal, mag = magVal, quat = quatVal
         };
         var imu = new IMUData {
             timeUtc = DateTime.UtcNow, raw = raw, unity = raw.ToUnityWorld()
         };
         var device = sensorEventDict[deviceId];
         context?.Post(_ => {
             device.NotifyUpdateAccel(accVal);
             device.NotifyUpdateGyro(gyroVal);
             device.NotifyUpdateCompass(magVal);
             device.NotifyUpdateQuaternion(quatVal);
             device.NotifyUpdateIMU(imu);
         }, null);
     }
 }
Ejemplo n.º 2
0
 void IIMUEventDelegate.NotifyUpdateIMU(IMUData imu)
 {
     IMUSensorUpdateEvent?.Invoke(imu);
 }