Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 11-27-2008, 03:54 AM   #1 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 41
HoofSC is an unknown quantity at this point
Default Accelerometer and iPhone Velocity?

Hi,

Been searching for days, and can't wrap my head around the findings.

Has anyone here been able to parse the <acceleration.x, acceleration.y, acceleration.z> over the update (time) interval, and been able to measure the velocity (magnitude only) of the iPhone as you "wave" it through space?

I am trying to accomplish the effect of the Wii remote in the game "Boom Blox":

Once locked on a target (direction component) by holding the trigger, you swing the remote back and then FORWARD and let go (an iPhone "event") in order to "RELEASE" the bowling ball or baseball at a variable VELOCITY.

I'm curious to know any (inexpensive) approach to calculating a magnitude based on the "speed" you WAVE the wand through space (using acceleration data)...

Does any one have any ideas? Thx in advance...
HoofSC is offline   Reply With Quote
Old 01-18-2009, 11:44 PM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Lewisville, TX
Posts: 236
ukneeq is on a distinguished road
Send a message via AIM to ukneeq
Default

I was just wondering if you ever came up with a solution to your post? I'm wondering how to calculate the speed that the iphone is moved for a certain amount of time. Thanks!
ukneeq is offline   Reply With Quote
Old 02-05-2009, 03:16 PM   #3 (permalink)
New Member
 
Join Date: Jul 2008
Posts: 7
kbaer is on a distinguished road
Default

I am also interested.
kbaer is offline   Reply With Quote
Old 02-05-2009, 03:22 PM   #4 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,070
scotopia is on a distinguished road
Default

I tried doing this the old school physics way and got horrific results; you should be able to find the thread on it.
scotopia is offline   Reply With Quote
Old 02-05-2009, 03:25 PM   #5 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 188
jsonli is on a distinguished road
Default

I was never great at calculus, but I think you want to integrate the acceleration data to arrive at velocity.

I wouldn't know how to do that though. Why don't you fudge it, and sum all the acceleration vectors together (minus gravity), and then take the magnitude of that vector.
jsonli is offline   Reply With Quote
Old 02-05-2009, 03:49 PM   #6 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,070
scotopia is on a distinguished road
Default

Quote:
Originally Posted by jsonli View Post
I was never great at calculus, but I think you want to integrate the acceleration data to arrive at velocity.

I wouldn't know how to do that though. Why don't you fudge it, and sum all the acceleration vectors together (minus gravity), and then take the magnitude of that vector.

I tried to do something close to what you suggest; but it boiled down to the fact that the iPhone accelerometer is not that accurate and has many phantom spikes on axis that shouldn't have them (see my other post where I created a nigh-frictionless environment to prove this). When you integrate faulty values the errors magnify hugely = mess. I actually wanted displacement = double mess.
scotopia is offline   Reply With Quote
Old 02-05-2009, 04:12 PM   #7 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 188
jsonli is on a distinguished road
Default

Quote:
Originally Posted by scotopia View Post
I tried to do something close to what you suggest; but it boiled down to the fact that the iPhone accelerometer is not that accurate and has many phantom spikes on axis that shouldn't have them (see my other post where I created a nigh-frictionless environment to prove this). When you integrate faulty values the errors magnify hugely = mess. I actually wanted displacement = double mess.
Well, if that's the case you'll need to filter out these phantom spikes no matter what method is used to interpret the data.
jsonli is offline   Reply With Quote
Old 02-05-2009, 04:16 PM   #8 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,070
scotopia is on a distinguished road
Default

Quote:
Originally Posted by jsonli View Post
Well, if that's the case you'll need to filter out these phantom spikes no matter what method is used to interpret the data.
What I am saying is that the accelerometer data is too inaccurate and seemingly random to filter it in a logical way. I am physics professor and know how to do these things; it just doesn't work right with the iPhone's accelerometer. Perhaps if I wanted to spend months dedicated to create algorithms that factor in the iPhone's wonky readings (not even to mention that every iPhone is miscalibrated differently!) I'd be able to get something halfway terrible; but I'm not currently willing to spend that time.

As far as I understand any attempt to do this in a small scale way (not calculating avg velocity driving in your car etc) has failed; if you can do it that would be amazing and I wish you luck!
scotopia is offline   Reply With Quote
Old 02-05-2009, 04:24 PM   #9 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 188
jsonli is on a distinguished road
Default

Quote:
Originally Posted by scotopia View Post
What I am saying is that the accelerometer data is too inaccurate and seemingly random to filter it in a logical way. I am physics professor and know how to do these things; it just doesn't work right with the iPhone's accelerometer. Perhaps if I wanted to spend months dedicated to create algorithms that factor in the iPhone's wonky readings (not even to mention that every iPhone is miscalibrated differently!) I'd be able to get something halfway terrible; but I'm not currently willing to spend that time.

As far as I understand any attempt to do this in a small scale way (not calculating avg velocity driving in your car etc) has failed; if you can do it that would be amazing and I wish you luck!
I think this depends on your goals. If you're trying to calculate displacement/position accurately, the accumulated error is probably too great. The OP simply wants magnitude of velocity though, and I think that is achievable.
jsonli is offline   Reply With Quote
Old 02-05-2009, 04:38 PM   #10 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,070
scotopia is on a distinguished road
Default

Quote:
Originally Posted by jsonli View Post
I think this depends on your goals. If you're trying to calculate displacement/position accurately, the accumulated error is probably too great. The OP simply wants magnitude of velocity though, and I think that is achievable.
True, you could probably get it roughly; but if you want to detect just "waving through space" can't you do that with the raw accel data just fine?
scotopia is offline   Reply With Quote
Old 02-05-2009, 04:39 PM   #11 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 188
jsonli is on a distinguished road
Default

Quote:
Originally Posted by scotopia View Post
True, you could probably get it roughly; but if you want to detect just "waving through space" can't you do that with the raw accel data just fine?
Pretty much, yeah.
jsonli is offline   Reply With Quote
Old 02-05-2009, 04:57 PM   #12 (permalink)
Registered Member
 
Join Date: Dec 2008
Posts: 495
exorcyze is on a distinguished road
Default

Yeah, all things considered you essentially want velocity = distance / time. If I was going to approach it, I would say getting the samples from the accelerometer with a threshold ( ie +- 0.4 or more ) and getting the average of those would be a decent indicator of force - you could use those to fudge in for "distance". On your backswing, start counting time when they pass that threshold in the one direction and throwing the values into an array on each reading. Once it passes the threshold in the other direction, count that as a forward stroke, stop the first time, start the second timer and start putting values onto the other array.

When they release the button, do your averages and use the total time on each to get an effective velocity. For something like bowling or golf you could even discount the backwards velocity, as you only need to know that they _had_ a windup.

Wouldn't be perfect, but probably enough of an approximation for most game applications - and with the averaging those spikes shouldn't have such a negative effect, especially if you up your sample rate.
__________________
My Apps on AppStore : gScale (guitar scales reference), eMaze, eMaze Lite, eTimesheet
exorcyze is offline   Reply With Quote
Old 02-05-2009, 05:00 PM   #13 (permalink)
Registered Member
 
scotopia's Avatar
 
Join Date: Oct 2008
Posts: 2,070
scotopia is on a distinguished road
Default

Quote:
Originally Posted by exorcyze View Post
Yeah, all things considered you essentially want velocity = distance / time. If I was going to approach it, I would say getting the samples from the accelerometer with a threshold ( ie +- 0.4 or more ) and getting the average of those would be a decent indicator of force - you could use those to fudge in for "distance". On your backswing, start counting time when they pass that threshold in the one direction and throwing the values into an array on each reading. Once it passes the threshold in the other direction, count that as a forward stroke, stop the first time, start the second timer and start putting values onto the other array.

When they release the button, do your averages and use the total time on each to get an effective velocity. For something like bowling or golf you could even discount the backwards velocity, as you only need to know that they _had_ a windup.

Wouldn't be perfect, but probably enough of an approximation for most game applications - and with the averaging those spikes shouldn't have such a negative effect, especially if you up your sample rate.

Ex you nailed it; this is exactly what I have done in a previous app
scotopia is offline   Reply With Quote
Old 11-05-2011, 12:21 PM   #14 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 1
toublanc is on a distinguished road
Default

Did anyone found a solution ?
I'm quite interested in creating a positioning system with accelerometer, gyroscope and compass and i'm having the same problem...
toublanc is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 356
15 members and 341 guests
7twenty7, blasterbr, Clouds, dre, EvilElf, iAppDeveloper, jeroenkeij, jimmyon122, Mah6447, Morrisone, n00b, pungs, Sami Gh, stanny, toon4413
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,667
Threads: 94,121
Posts: 402,900
Top Poster: BrianSlick (7,990)
Welcome to our newest member, host number one
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:45 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0