/* * Desc: Used by the MoveServer to parse 'b' packets to the controller. * msg format: b msgNo controller tx ty tz ux uy trackingMove */ public Boolean updatePositionData(String[] positionData) { int c = int.Parse(positionData[2]); if (c == controllerNumber) { if (!active) { active = true; } // Used to set the controllers properties // Set our new values from the packet. Vector3 prevPosRaw = positionRaw; positionRaw.Set(float.Parse(positionData[3]) / 100f, float.Parse(positionData[4]) / 100f, float.Parse(positionData[5]) / 100f); //Debug.Log(positionRaw.ToString()); positionNorm.Set(float.Parse(positionData[6]), float.Parse(positionData[7]), 0); currentlyTracked = positionData[8] == "0" ? false : true; // Process the new values. double newTime = System.DateTime.Now.Ticks * .0000001; if (currTime_b != -1) { delta_t_b = newTime - currTime_b; } currTime_b = newTime; // Store the last smoothed position for velocity calc. Vector3 prevPosSmooth = positionSmoothed.getSmoothedVector(); positionSmoothed.updateRaw(positionRaw); positionNormSmooothed.updateRaw(positionNorm); // Calculate velocity. velocityRaw.Set((float)((positionRaw.x - prevPosRaw.x) / delta_t_b), (float)((positionRaw.x - prevPosRaw.x) / delta_t_b), (float)((positionRaw.x - prevPosRaw.x) / delta_t_b)); if (prevPosSmooth != null) { Vector3 posSmooth = positionSmoothed.getSmoothedVector(); velocitySmoothed.Set((float)((posSmooth.x - prevPosSmooth.x) / delta_t_b), (float)((posSmooth.x - prevPosSmooth.x) / delta_t_b), (float)((posSmooth.x - prevPosSmooth.x) / delta_t_b)); } return(true); } return(false); }
public Vector3 getPositionNormSmooth() { return(positionNormSmooothed.getSmoothedVector()); }
public Vector3 getMagnetometerSmooth() { return(magnetometerSmoothed.getSmoothedVector());; }
public Vector3 getAccelerometerSmooth() { return(accelerometerSmoothed.getSmoothedVector()); }
public Vector3 getGyroscopeSmooth() { return(gyroscopeSmoothed.getSmoothedVector()); }