separating compass heading from orientation?

Hi,

Apologies in advance - this is another fairly large change request :(

I've been looking at incorporating the compass heading into the DeviceOrientation data, as the specification says they should be. If you don't know, iOS 4.2 added support for DeviceOrientation but the data are not real-world accurate - it is from a frame of reference which the developer must keep track of. In other words, the alpha value is not your compass heading.

Luckily, we added the 'absolute' property to the event to indicate this situation, so if the feature were to be implemented the developer could notice the change.

However, I think that we should NOT require the alpha to be a compass heading, and separate heading out either completely or into new properties on the event.

The problem is that compasses are prone to being inaccurate. Especially compared to modern gyroscope hardware. Consider the following scenario: I'm playing a game where I control the player by turning my device. I don't care about my real-world heading - I'm using orientation just for control. All of a sudden, the compass decides that my heading has changed (a source of interference has been removed). What should the system do? If it changes the DeviceOrientation events, the player might jump off a cliff even though I didn't move. But it can't ignore the change in heading.

If you have a gyroscope, then it might be possible to detect that you haven't actually moved. But that has other issues - you can't always tell whether the new or old compass heading is the most accurate. In fact, they might be equally inaccurate.

Then there is the issue that compasses have a slight lag. This would also be very annoying in games that don't care about heading. I don't see much downside in separating the compass from the orientation. Developers can still use the compass to make augmented reality or navigation apps, and can also use the gravity to get more accurate orientation.

In summary, conforming to the specification would make some of the Web apps that are using DeviceOrientation worse.

My proposal would be to add the following to DeviceOrientationEvent:

readonly attribute double? compassHeading; // heading in degrees from magnetic north
readonly attribute double? compassAccuracy; // degrees
readonly attribute boolean? compassCalibrated; // as it is already specified

There's also this specification, but I can't tell if it has been abandoned:

http://dev.w3.org/2009/dap/system-info/compass.html

(I don't like the callbackishness of that spec compared to the event approach in device orientation, but I can see its use in non-DOM contexts)

Dean

Received on Tuesday, 22 February 2011 01:48:22 UTC