public static void SimToolSendData(Transform player) { var roll = GetRoll(player); var pitch = GetPitch(player); var yaw = GetYaw(player); //Debug.Log("Roll " + roll); //Debug.Log("Pitch " + pitch); simtools = new SimtoolsTelemetry(pitch, roll, yaw); }
//these functins actually retrieve the telemetry data #region Retreve Telemetry Data public void FixedUpdate() { //don't do anything if the gameobject is null because that will throw exceptions if (player != null) { //start OLD CODE Quaternion deltaRot = Quaternion.Inverse(lastRot) * player.transform.localRotation; float roll = lastRoll + deltaRot.eulerAngles.z; if (roll > 180) { roll = roll - 360; } float realPitch = deltaRot.eulerAngles.x; if (realPitch > 180) { realPitch = realPitch - 360; } float pitch = lastPitch + realPitch * Mathf.Cos(Mathf.Deg2Rad * roll); // (deltaRot.eulerAngles.x * player.transform.up.y); float yaw = lastYaw + deltaRot.eulerAngles.y; // ---------------------------------- OVER-RIDE PITCH, ROLL, and YAW VALUES --------------------------------------------------- // To Do: clean up old code above //end OLD CODE pitch = GetPitch(player.transform); yaw = GetYaw(player.transform); roll = GetRoll(player.transform); //attempt to calculate the delta quaternion for angular velocity... Vector3 deltaPos = player.transform.position - lastPos; Vector3 deltaV = deltaPos - lastVel; float heave = transform.InverseTransformDirection(deltaV).y; float sway = transform.InverseTransformDirection(deltaV).z; float surge = transform.InverseTransformDirection(deltaV).x; float deltaPitch = (float)Math.Round(deltaRot.eulerAngles.x, 2); float deltaRoll = (float)Math.Round(deltaRot.eulerAngles.z, 2); float deltaYaw = (float)Math.Round(deltaRot.eulerAngles.y, 2); lastRot = player.transform.rotation; lastPos = player.transform.position; lastVel = deltaPos; simtools = new SimtoolsTelemetry(pitch, roll, yaw, heave, sway, surge, deltaPitch, deltaRoll, deltaYaw); } return; }
// initialization void Start() { // create an endpoint remoteEndPoint = new IPEndPoint(IPAddress.Parse(IP), port); // create a udp client client = new UdpClient(); // create a simtools object simtools = new SimtoolsTelemetry(); //Initialize rotation OldRotation = transform.rotation; // start the simtools coroutine StartCoroutine("SimtoolStart"); }
// this function handles sending data public static void SimToolSendData(float roll, float pitch, float yaw) { simtools = new SimtoolsTelemetry(pitch, roll, yaw); }