Movement via accelerometer is ALWAYS choppy

Put your problem here if it does not fit any of the other categories.

Movement via accelerometer is ALWAYS choppy

Postby CodeX » Thu Apr 07, 2011 2:41 am

I'm pulling my hair out here... I am trying to move an image back and forth across the screen on the x-axis only using the accelerometer... It "works" but it looks like hell, it does not move at a constant rate, or at least it does not appear to, it slides along then suddenly jumps ahead or stalls and then jumps ahead... This also ties in to the question I posted here about my framerate jumping all over the place a few days ago that no one had an answer for I believe...

I am using Verlet Integration to integrate the accelerometer data with time in order to (I thought) counteract any variability in the accelerometer sampling frequency or display update frequency:
http://en.wikipedia.org/wiki/Verlet_integration

I use a nanosecond timer to record the last physics+drawing update and compare it to the current time each iteration of the main loop so that I can only update physics/graphics when enough time has passed (to limit the framerate to ~50fps)... the problem is the framerate jumps all over the damn place, fluctuating between 2 digit and 3 digit numbers ( < 50fps - > 100fps) even when using a nanosecond accurate timer... what is going on?

Either way, the variable frame rate should not affect the movement of this object via the accelerometer because that is calculated entirely independently of the display updates.... If I can't get smooth movement from the accelerometer I am going to give up on developing games for this platform, I had no trouble like this on the iPhone...
CodeX
Freshman
Freshman
 
Posts: 4
Joined: Tue Apr 05, 2011 12:52 am

Top

Re: Movement via accelerometer is ALWAYS choppy

Postby CodeX » Thu Apr 07, 2011 2:58 am

I really don't want to have to use a Kalman filter or something for this... I suppose I should check the SNR but I'm hoping it's something else that's wrong.
CodeX
Freshman
Freshman
 
Posts: 4
Joined: Tue Apr 05, 2011 12:52 am

Re: Movement via accelerometer is ALWAYS choppy

Postby CodeX » Thu Apr 07, 2011 3:27 am

One more update:

I confirmed it is not the accelerometer... First I tried using a running average of 25 accelerometer readings which decreased the noise substantially but had no effect on the problem I am talking about. So I decided to bypass the accelerometer altogether and give my object a constant velocity and guess what? Its movement was still very "choppy" as it scrolled across the screen. So now I believe that the movement itself is actually smooth, but the variable framerate is leading to the appearance of choppy movement... which sucks because I have no idea what to do about the framerate.

But, for future reference, using a high pass filter and running average of about 20 samples produced very nice accelerometer control... if I could just fix this framerate issue I would be golden.
CodeX
Freshman
Freshman
 
Posts: 4
Joined: Tue Apr 05, 2011 12:52 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot] and 18 guests