Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!goblin1!goblin.stu.neva.ru!postnews.google.com!news2.google.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.posted.palinacquisition!news.posted.palinacquisition.POSTED!not-for-mail NNTP-Posting-Date: Thu, 31 Mar 2011 20:20:05 -0500 Date: Thu, 31 Mar 2011 18:20:04 -0700 From: Peter Duniho User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: Android Sensor Coordinates References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Message-ID: Lines: 96 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 50.46.118.188 X-Trace: sv3-bpsVON48Psd/lV2gPKaCkHfl6Iahv1LnAiEbpcjdP6nw7/ouglkCMjj19xy4RZ+ZuX2EoQgWPpCh+AM!WV+FktLsnYWy3C3DX5uP2fN8CKvtRVywV44ajgw1ypQi9Maw2GSB16n7pdbAj5L1hBqW7NDsXm/p!Ok2n+a4qIWzaSzsv2bigQ968PpoIXaBu5H+4vwtx0F8= X-Complaints-To: abuse@iinet.com X-DMCA-Complaints-To: abuse@iinet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 6101 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2684 On 3/31/11 5:03 PM, Lawrence D'Oliveiro wrote: > The diagram of the linear sensor coordinate system here > > seems to be wrong. > > I have a test program running on my HTC Desire (Android 2.2), showing me > values from the accelerometer. As it lies horizontally, face-up on my desk, > the Z value is positive (around 9.8, as you would expect). But that diagram > says that positive Z is up, not down. > > I tilt the phone to the left, and the X value increases. Tilt to the right, > it decreases. But the diagram says positive X is to the right, not the left. > > Tilt it up, the Y value increases. Hold it vertical, with the display upside > down, and the Y value shows negative. Again, completely the opposite to the > diagram. The accelerometer is something that measures acceleration, not tilt. You want an inclinometer if you want to measure tilt. Incredibly enough, the behavior you are seeing is documented on the same page you referred us to: In particular, the force of gravity is always influencing the measured acceleration: Ad = -g - ∑F / mass For this reason, when the device is sitting on a table (and obviously not accelerating), the accelerometer reads a magnitude of g = 9.81 m/s^2 Similarly, when the device is in free-fall and therefore dangerously accelerating towards to ground at 9.81 m/s^2, its accelerometer reads a magnitude of 0 m/s^2. But, if you would like a more elaborate explanation… As Patricia says, if the phone is flat, parallel to the surface of the planet, then it is being accelerated 9.81 m/s^2 upward (see above) relative to the planet (I suppose technically it's net acceleration relative to all gravity sources, but I doubt anything except Earth is significant). That's the acceleration it takes to exactly counteract the downward acceleration the planet causes. It is typical for 0 acceleration in all directions to be registered during freefall of an accelerometer. To see why this makes sense, consider the phone floating in an orbiting spacecraft (or even better, away from any measurable gravity sources). Now, quickly move the device in the positive direction of the documented Z axis. What value do you want the phone to report? A positive acceleration, of course. And note that if you were a very tiny person sitting inside the phone, and the phone were moved in that direction, you would perceive a force relative to your frame of reference that felt just like gravity pulling you in the other direction (i.e. you would be pressed against the back side of the phone). That force that your very tiny self mistakes for gravity is exactly the same as the gravity that the accelerometer _does_ feel when the phone is sitting still on a table. Basically, in a self-contained system, whether a phone or your own body, forces acting on elements in that system can be perceived only by those elements relative to the self-contained system. In free-fall, no force can be perceived, as all forces are acting on every part of the system equally. But when sitting still, the system's frame of reference is stationary, while gravity is still pulling on the piece that senses acceleration. That piece perceives the force as acceleration in the opposite direction of the pull. As far as tilting goes, when the phone is flat, I'd expect the X and Y axes to register as 0. When you tilt the phone, then those will start to experience a force because they are not completely perpendicular to the planet's gravity, and thus will start registering that force as well. Note that for the X and Y axes, the change in value is consistent with the Z axis. With the phone tilted to the left, the X axis is pointing in a direction that has a vertical component, away from gravity, and registers a positive force in that direction, balancing the force in the other direction that gravity is causing. Again, drop the phone in that orientation or any other, and the registered force will be 0. Finally note that this really is the only sensible approach for a 3-axis accelerometer. You can't get rid of the force pulling on the accelerometer, so either you just report it, or you include an offset so that the device reads 0 when it's flat. But the offset is only valid in a particular orientation; so you'd actually need an inclinometer so that you could calculate the offset required. It's much simpler and practical to just report the real force experienced by the accelerometer. Let the software figure out how best to interpret that (see the same doc page for a code example showing just that). Pete