Wednesday 2 October 2013

Step One - Will it work?


Before I spend too much time on this project I wanted to test out some unknowns to see if the whole thing is possible. My first concern, will the HDMI output on the iPhone work without too much latency? To test this I quickly fired up real racing 3 and connected the Oculus to the HDMI lightning adapter on the phone.  I put on the oculus, closed one eye (to stop going cross-eyed), and did a lap. I'm pleased to say that it worked better than expected! The framerate was great, the iPhone was outputting at full 1080p (downscaled by the rift) so pixelation wasn't bad. The control latency was the same as playing on the iPhone screen. Real racing is controlled by the accelerometer so I find there is some latency there, probably due to averaging/filtering. The important thing was it seemed the same as the native screen. So I can tick that off as working.
Next I wanted to see If I can power all the kit from a cheap USB battery extender I have. I plugged everything in, apart from the iPhone (it has its own battery), and for a second it seemed to work. Then everything went dead! Dam I've bricked my Oculus dev kit! Or so I thought! Turns out that the battery extender turns itself off if it doesn't detect enough load on the USB ports! So the kit was drawing so little power it just turned itself off. I presume this is to save power when it thinks devices are charged. I simply plugged in the iPhone and that tipped the balance to keep it on. I left it for 45mins running off the battery extender, it dropped from 3/4 full to half. Could that mean I will have three hours of mobile playtime! Thats great for such a cheap extender. So I think we're looking good on the power front.


Here comes my first development step. I decided to get data from a PS3 move navigation controller into an iPhone app. Why not an xbox controller you ask? Well I really want to use the iPhone itself as part of the control mechanism, so the navigation controller is a perfect partner to that. I will post more about using the iPhone as a controller later (I have big plans for this). But why do the controller first? Get on and do the Oculus you say? Since their both USB HID (human interface device) they have quite a lot in common. After quickly downloading some PS3 controller sample code, I was able to hack together something that worked. Drum roll please.... I give you a USB controller to iPhone bridge... This is exciting in itself, imagine being able to plug in any USB controller to your iPhone, making a non-wireless controller wireless at the same time. Combine this with Apple TV or the HDMI adaptor and you have a mini games console! I think I'll write an iPhone controller SDK for this.
Here comes the bad news.. The datarate I'm getting via the Bluetooth LE transfer is pretty low. It doesn't look like I will be able to send the full dataset from the oculus rift. There maybe other work I can do to improve the rates but that will require some work on a lower level. For now I will do the sensor fusion on the Arduino and just send the roll pitch and yaw. I should be able to send that at 30-60 frames per second along with the controller data. Now we're cooking.