Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Oiling my tablet
Message
From
29/04/2013 05:39:22
 
 
To
29/04/2013 05:31:26
General information
Forum:
Javascript
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01572116
Message ID:
01572122
Views:
37
>>>>Hi,
>>>>
>>>>Working on a web page that uses HTML5 DeviceOrientation which ties in to GeoLocation to provide 'bearing to destination'
>>>>
>>>>The problem I have is that most devices are very sensitive to device orientation - when I'm walking my indicator 'jitters' and because of this I want to dampen the incoming stream to provide a smoother display.
>>>>
>>>>I thought the obvious first step would be to maintain a buffer of x number of readings and use the average which should provide the desired result. But when the device is stationary no more input occurs and I need a way to settle on the final reading.
>>>>
>>>>Got a couple of approaches I might try but I'm wondering if anyone here can come up with a good algorithm..........
>>>
>>>If I understand what you're saying ...
>>>
>>>The latest reading is the correct one. Why not work with a timeout ?
>>>
>>>You receive one input (reading), store it - but don't display it
>>>The next input overwites the previous, etc
>>>When timeout
>>> - if there is input, display and clear the input
>>> - if there is no input, don't do anything
>>
>>Hmm.
>>
>>Firstly, although I haven't checked specifically, the readings are coming at least every 100ms (and probably quite a bit faster)
>>When walking and carrying the device in what is effectively a straight line (except when returning from the pub) the readings vary by +/- ~15 degrees.
>>Even if I display say every one second the latest reading is not likely to be accurate and the end result is that I'm pointed in the wrong direction for a longer period of time.
>>
>>I think I need to measure the number of events/sec to get a better idea on how to proceed.....
>>
>>Averaging over say ten readings does dampen the effect but when the device is stationary the exact (latest) reading would be preferable to the last average....
>>
>>FWIW this obviously isn't a JScript specific thing - a C# based solution could be adapted.
>
>
>What happens when the device is stationary ? Do still get readings or do they stop ?
>
>If you prefer an average - store the readings in a stack. After a sec (or half a sec), look how many readings there are in the stack.
>You may not need all the readings in the stack to calculate the average - maybe the last 5 or so and clear the rest of the stack
>
>As to the stationary device - if the readings keep coming - keep using the stack. But before you display anything new, compare that with the data that was displayed previously. If it's the same, don't display
>
>If you are stationary (and the readings keep coming), the readings will all be equal and the average will be equal to the last reading

I'm pretty sure that the readings stop if the device is stationary - which is what makes it harder. I'm thinking I need only average the stack when a new GPS reading comes in (which is far less frequent) - that would avoid the need for a separate timer. Also, I'm not sure whether it's a good idea to clear the stack after taking an average. Popping the oldest and pushing the newest (i.e. always maintaining a fixed length stack) might work better.

I'm going to get some timings (and verify that readings stop when stationary). I'll let you know the results......
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform