public void infoUpdated(PLTConnection pltConnection, PLTInfo pltInfo) { // TODO work in progress switch (pltInfo.m_serviceType) { case PLTService.MOTION_TRACKING_SVC: PLTMotionTrackingData trackingdata = (PLTMotionTrackingData)pltInfo.m_data; //DebugPrint(MethodInfo.GetCurrentMethod().Name, "Motion Tracking Update received:\r\n" + // "raw q0: " + trackingdata.m_rawquaternion[0] + "\r\n" + // "raw q1: " + trackingdata.m_rawquaternion[1] + "\r\n" + // "raw q2: " + trackingdata.m_rawquaternion[2] + "\r\n" + // "raw q3: " + trackingdata.m_rawquaternion[3]); DebugPrint(MethodInfo.GetCurrentMethod().Name, "Motion Tracking Update received:\r\n" + "heading: " + trackingdata.m_orientation[0] + "\r\n" + "pitch: " + trackingdata.m_orientation[1] + "\r\n" + "roll: " + trackingdata.m_orientation[2]); break; case PLTService.SENSOR_CAL_STATE_SVC: PLTSensorCal sensorcaldata = (PLTSensorCal)pltInfo.m_data; DebugPrint(MethodInfo.GetCurrentMethod().Name, "Sensor calibration update received:\r\n" + "Gyros calibrated?: " + sensorcaldata.m_isgyrocal + "\r\n" + "Magnetometer calibrated?: " + sensorcaldata.m_ismagnetometercal); break; } }
public void infoUpdated(PLTConnection pltConnection, PLTInfo pltInfo) { switch (pltInfo.m_serviceType) { case PLTService.MOTION_TRACKING_SVC: PLTMotionTrackingData tracking = (PLTMotionTrackingData)pltInfo.m_data; PlantronicsMessage msg = new PlantronicsMessage( pltInfo.m_serviceType.ToString(), "heading" ); msg.Payload.Add("orientation", (int)tracking.m_orientation[0] + "," + (int)tracking.m_orientation[1] + "," + (int)tracking.m_orientation[2]); BroadcastMessage(msg ); break; case PLTService.SENSOR_CAL_STATE_SVC: PLTSensorCal calinfo = (PLTSensorCal)pltInfo.m_data; if (calinfo.m_isgyrocal != m_gyrocal) { PlantronicsMessage msg2 = new PlantronicsMessage(pltInfo.m_serviceType.ToString(), "gyrocalibinfo" ); msg2.Payload.Add("gyrocalibrated", calinfo.m_isgyrocal.ToString()); BroadcastMessage( msg2 ); } m_gyrocal = calinfo.m_isgyrocal; break; } }
internal void HeadsetTrackingUpdateGUI(PLTMotionTrackingData headsetdata) { try { HeadingSlider.Dispatcher.Invoke(new Action(delegate() { // Put orientation into GUI Heading_Label.Content = Math.Round(headsetdata.m_orientation[0]) + "°"; Pitch_Label.Content = Math.Round(headsetdata.m_orientation[1]) + "°"; Roll_Label.Content = Math.Round(headsetdata.m_orientation[2]) + "°"; HeadingSlider.Value = headsetdata.m_orientation[0]; Pitch_Slider.Value = headsetdata.m_orientation[1]; Roll_Slider.Value = headsetdata.m_orientation[2]; // Put headset headtracking firmware version number into GUI // (NOTE: will be available in connection object // once you have received the first headtracking update from headset) UpdateVersionInfoGUI(); // for debug: raw report from headset packetlabel.Content = headsetdata.m_rawreport; m_lastheading = headsetdata.m_orientation[0]; m_lastpitch = headsetdata.m_orientation[1]; m_lastroll = headsetdata.m_orientation[2]; })); } catch (Exception) { } }
// receives headtracking angles in degrees back from PLT Labs API public void HeadsetTrackingUpdate(PLTMotionTrackingData headsetData) { // need to reverse heading and pitch sign? headsetData.m_orientation[0] = -headsetData.m_orientation[0]; //headsetData.m_orientation[1] = -headsetData.m_orientation[1]; // define some constants for maths calculation to convert head angles into pixel offsets for screen const double c_distanceToScreen = 850; // millimeters const double c_pixelPitch = 0.25; // millimeters double headtrack_offset_millimeters; // temporary variable to hold headset offset //if (m_worn) //{ // assume distance from screen is 1 meter and that pixel size is 0.25mm headtrack_offset_millimeters = c_distanceToScreen * Math.Tan(headsetData.m_orientation[0] * Math.PI / 180.0); // x = d * tan(theta) headtrack_xoffset = (int)(headtrack_offset_millimeters / c_pixelPitch); headtrack_offset_millimeters = c_distanceToScreen * Math.Tan(headsetData.m_orientation[1] * Math.PI / 180.0); // y = d * tan(theta) headtrack_yoffset = (int)(headtrack_offset_millimeters / c_pixelPitch); //} //else //{ // headtrack_xoffset = 0; // headtrack_yoffset = 0; //} }
public void infoUpdated(PLTConnection pltConnection, PLTInfo pltInfo) { if (pltInfo != null && pltInfo.m_data != null) { switch (pltInfo.m_serviceType) { case PLTService.SENSOR_CAL_STATE_SVC: PLTSensorCal caldata = (PLTSensorCal)pltInfo.m_data; m_calibrated = caldata.m_isgyrocal; break; case PLTService.MOTION_TRACKING_SVC: PLTMotionTrackingData motiondata = (PLTMotionTrackingData)pltInfo.m_data; HeadsetTrackingUpdate(motiondata); break; case PLTService.WEARING_STATE_SVC: PLTWearingState weardata = (PLTWearingState)pltInfo.m_data; m_worn = weardata.m_worn; if (weardata.m_worn && !weardata.m_isInitialStateEvent) { // headset was put on // lets auto calibrate m_autoputoncalibratetimer.Start(); } break; } } }
public void infoUpdated(PLTConnection pltConnection, PLTInfo pltInfo) { // make sure we have some data... if (pltInfo != null && pltInfo.m_data != null) { switch (pltInfo.m_serviceType) { case PLTService.MOTION_TRACKING_SVC: PLTMotionTrackingData trackingdata = (PLTMotionTrackingData)pltInfo.m_data; //DebugPrint(MethodInfo.GetCurrentMethod().Name, "Motion Tracking Update received:\r\n" + //"raw q0: " + trackingdata.m_rawquaternion[0] + "\r\n" + //"raw q1: " + trackingdata.m_rawquaternion[1] + "\r\n" + //"raw q2: " + trackingdata.m_rawquaternion[2] + "\r\n" + //"raw q3: " + trackingdata.m_rawquaternion[3]); // great we got some angles - lets update the GUI! HeadsetTrackingUpdateGUI(trackingdata); break; case PLTService.MOTION_STATE_SVC: // NOTE: this service is not yet available, no data will come here break; case PLTService.SENSOR_CAL_STATE_SVC: PLTSensorCal caldata = (PLTSensorCal)pltInfo.m_data; UpdateCalibrationGUI(caldata); break; case PLTService.PEDOMETER_SVC: PLTPedometerCount peddata = (PLTPedometerCount)pltInfo.m_data; m_lastpedometercount = peddata.m_pedometercount; if (m_lastpedometerreset == -1) { m_lastpedometerreset = m_lastpedometercount; } UpdatePedometerGUI(); break; case PLTService.TAP_SVC: UpdateTapInfoGUI((PLTTapInfo)pltInfo.m_data); break; case PLTService.WEARING_STATE_SVC: PLTWearingState wearingstate = (PLTWearingState)pltInfo.m_data; DebugPrint(MethodInfo.GetCurrentMethod().Name, "Wearing State Update received:\r\n" + "Is Worn?: " + wearingstate.m_worn + "\r\n" + "Initial State?: " + wearingstate.m_isInitialStateEvent); if (wearingstate.m_worn && !wearingstate.m_isInitialStateEvent) { // they have put headset on, start the auto calibrate timer // to zero angles in 2 seconds time m_autoputoncalibratetimer.Start(); } break; case PLTService.FREE_FALL_SVC: UpdateFreeFallGUI((PLTFreeFall)pltInfo.m_data); break; case PLTService.PROXIMITY_SVC: PLTProximity proximitystate = (PLTProximity)pltInfo.m_data; DebugPrint(MethodInfo.GetCurrentMethod().Name, "Proximity State Update received:\r\n" + "Proximity State: " + proximitystate.m_proximity); break; case PLTService.CALLERID_SVC: PLTCallerId callerid = (PLTCallerId)pltInfo.m_data; DebugPrint(MethodInfo.GetCurrentMethod().Name, "Caller Id Update received:\r\n" + "Caller Id: " + callerid.m_callerid + "\r\n" + "Line type: " + callerid.m_calltype); break; case PLTService.CALLSTATE_SVC: PLTCallStateInfo callinfo = (PLTCallStateInfo)pltInfo.m_data; DebugPrint(MethodInfo.GetCurrentMethod().Name, "Call State Update received:\r\n" + "Call State Event Type: " + callinfo.m_callstatetype + "\r\n" + "Call Status: " + callinfo.m_callstate + "\r\n" + "Internal Call Id: " + callinfo.m_callid + "\r\n" + "Call Source: " + callinfo.m_callsource + "\r\n" + "Was Incoming?: " + callinfo.m_incoming); break; case PLTService.DOCKSTATE_SVC: PLTDock dockedstate = (PLTDock)pltInfo.m_data; DebugPrint(MethodInfo.GetCurrentMethod().Name, "Docked State Update received:\r\n" + "Docked State: " + dockedstate.m_isdocked + "\r\n" + "Is Initial State?: " + dockedstate.m_isinitialstatus); break; case PLTService.CHARGESTATE_SVC: UpdateBatteryLevelGUI((PLTBatteryState)pltInfo.m_data); break; } } else { // no data... DebugPrint(MethodInfo.GetCurrentMethod().Name, "WARNING: no data for service subscription:\r\n" + "SERVICE: " + (pltInfo != null ? pltInfo.m_serviceType.ToString() : "null")); } }