private void Sensors_ReadingAvailable(Sensors.Reading reading) { OrientationTracker.Primary.UpdateWithReading(reading); //OrientationTracker.Secondary.UpdateWithReading(reading, -1, true); // uncomment if using two IMUs if ((DateTime.Now - last).TotalMilliseconds > 30) { EulerAngles orientation = OrientationTracker.Primary.EstimateOrientation().GetEulerAngles(); int resolution = 1; int yaw = resolution * (int)Math.Round(orientation.Yaw * 180 / Math.PI / resolution); int pitch = resolution * (int)Math.Round(orientation.Pitch * 180 / Math.PI / resolution); int roll = resolution * (int)Math.Round(orientation.Roll * 180 / Math.PI / resolution); if (RemoveGravityCheckbox.Checked) { reading = OrientationTracker.SubtractGravity(reading); } Invoke(new MethodInvoker(delegate { StatusBox.Text = ""; StatusBox.Text += "ax = " + reading.Accelerometer1.X + " m/s^2" + Environment.NewLine; StatusBox.Text += "ay = " + reading.Accelerometer1.Y + " m/s^2" + Environment.NewLine; StatusBox.Text += "az = " + reading.Accelerometer1.Z + " m/s^2" + Environment.NewLine; StatusBox.Text += "gx = " + reading.Gyroscope1.X + " deg / s" + Environment.NewLine; StatusBox.Text += "gy = " + reading.Gyroscope1.Y + " deg / s" + Environment.NewLine; StatusBox.Text += "gz = " + reading.Gyroscope1.Z + " deg / s" + Environment.NewLine; StatusBox.Text += "mx = " + reading.Magnetometer1.X + " gauss" + Environment.NewLine; StatusBox.Text += "my = " + reading.Magnetometer1.Y + " gauss" + Environment.NewLine; StatusBox.Text += "mz = " + reading.Magnetometer1.Z + " gauss" + Environment.NewLine; StatusBox.Text += yaw + Environment.NewLine + pitch + Environment.NewLine + roll; })); last = DateTime.Now; } }
private void Sensors_ReadingAvailable(Sensors.Reading reading) { OrientationTracker.Primary.UpdateWithReading(reading); //OrientationTracker.Secondary.UpdateWithReading(reading, -1, true); // uncomment if using two IMUs Quaternion quaternion = OrientationTracker.Primary.EstimateOrientation(); EulerAngles orientation = quaternion.GetEulerAngles(); int resolution = 10; int yaw = resolution * (int)Math.Round(orientation.Yaw * 180 / Math.PI / resolution); int pitch = resolution * (int)Math.Round(orientation.Pitch * 180 / Math.PI / resolution); int roll = resolution * (int)Math.Round(orientation.Roll * 180 / Math.PI / resolution); reading.Orientation1 = quaternion; if ((DateTime.Now - last).TotalMilliseconds > 30) { Invoke(new MethodInvoker(delegate { OrientationLabel.Text = yaw + ", " + pitch + ", " + roll; //OrientationLabel.Text = orientation.W.ToString("0.0") + ", " + orientation.X.ToString("0.0") + ", " + orientation.Y.ToString("0.0") + ", " + orientation.Z.ToString("0.0"); })); last = DateTime.Now; } TouchSegmentation.UpdateWithReading(reading); Logging.LogSensorReading(reading); sensorReadingHistory.Add(reading); while (sensorReadingHistory.Count > sensorReadingPreBuffer) { sensorReadingHistory.Take(); } if (touchDown) { gestureSensorReadings.Add(reading); } }