App – User orientation tracking using iPhone gyroscope
Course: Fall 2012 – CGT 411: Contemporary Problems in Applied Computer Graphics (Senior Design)
Role: Lead Developer/Architecture Designer in team of five
Introduction:
During our senior design, we needed a way of tracking user orientation. After research, we found that iPhone 4 and later has built-in gyroscope and Charlie Roberts had written a perfect app for transmitting iPhone gyroscope data using Open Sound Control protocol. We modified our Unity Open Sound Control client so it would also receive OSC messages from iPhone.
Demo Video:
Sample Unity 3D Client Code:
// Update is called once per frame void Update () { if (oscClient == null) return; else { OscBundle oscPack = (OscBundle)oscClient.Receive (); if (oscPack != null) { TimeSpan latency = TimeSpan.FromSeconds (Time.deltaTime); if (oscPack.DateTime.Year != 1) latency = DateTime.Now.Subtract (oscPack.DateTime); if (GUI_FPS != null) GUI_FPS.guiText.text = "FPS: " + (int)(1f / Time.deltaTime) + " Ping: " + latency.Milliseconds.ToString () + "ms"; foreach (OscElement oscElement in oscPack.Elements) { if (oscElement != null) { //Debug.Log("Receiving data from: " + oscElement.Address); string[] key = oscElement.Address.Split ('/'); if (oscElement.Args.Length == 6 && key.Length == 2) { if (key [1] == "gyro") { this.transform.localRotation = Quaternion.Euler (new Vector3 (0, 180f -(float)oscElement.Args [4] * 360f, 0)); } } } } } } }