private void ReceiveAsyncMessage(object sender, SpheroDeviceMessenger.MessengerEventArgs eventArgs) { // Handler method for the streaming data. This code copies the data values SpheroDeviceSensorsAsyncData message = (SpheroDeviceSensorsAsyncData)eventArgs.Message; SpheroDeviceSensorsData sensorsData = message.Frames[0]; // There can be some discontinuation with vision data coming in, and what we requested, // so check if the data actually exists SpheroAttitudeData attitudeData = sensorsData.AttitudeData; if (attitudeData != null) { SpheroYaw = sensorsData.AttitudeData.Yaw; } SpheroQuaternionData quaternionData = sensorsData.QuaternionData; if (quaternionData != null) { SpheroQuaternion = new Quaternion(sensorsData.QuaternionData.Q1, sensorsData.QuaternionData.Q2, sensorsData.QuaternionData.Q3, sensorsData.QuaternionData.Q0); } }
public SpheroDeviceSensorsData(SpheroDeviceMessageDecoder decoder) { accelerometerData = (SpheroAccelerometerData)decoder.DecodeObject("accelerometerData"); attitudeData = (SpheroAttitudeData)decoder.DecodeObject("attitudeData"); quaternionData = (SpheroQuaternionData)decoder.DecodeObject("quaternionData"); backEMFData = (SpheroBackEMFData)decoder.DecodeObject("backEMFData"); locatorData = (SpheroLocatorData)decoder.DecodeObject("locatorData"); gyroData = (SpheroGyroData)decoder.DecodeObject("gyroData"); }