How To Get Input From Accelerometer
Jul 1, 2013How to do something when the user shakes the phone ?
I need to know how to get the input from the accelerometer..?
How to do something when the user shakes the phone ?
I need to know how to get the input from the accelerometer..?
I am developing a game. In which the user controls movement using the accelerometer. Sounds effects can also be enabled. However when laying the phone flat down and playing the game without the accelerometer gives nice 0,0,0 values. However when play WITH SOUNDS on, i get a buch of weird values: while the phone is NOT moving.
This is really a big bug that makes life hard for Game Developers. I tried to take an avarge of the last 5 values from the sensor.. but this is not enough.. The harder the sounds plays: the higher the weird sensor values. When using the headphones: almost no weird values. Seems that sounds interferes with the accelerometer sensor.
I would like to show a custom input field (specifically, one containing only 9-0 and two extra buttons containing decimal separator (, or .) and a delete button). I could create a custom IME, but (as far as I know) that would have to be set by the user as the system-wide input method. Is there a way to implement an input method and bind it to a specific input field?
View 1 Replies View Relatedmy problem is this, i have my main class and a second class that displays the values of the accelerometer on a textview.. however if i call my accelerometer class this is what happens, my application starts with no problems however no buttons work from my main class.. it seems to me that the accelerometer class runs above my main class thats why i have this problem.. what i did is i created a new activity on my manifest and called my accelerometer class from my main class using->
Intent i = new Intent(this, AccelerometerClass.class);
startActivity(i);
Maybe there is a way to just take the values from the accelerometer class,wihout calling the class itself ???? what i mean is take the x,y,z(int) values from accelerometer class and set them on a text from the main class..
I'm designing a game for Android and I would like to use the accelerometer for some aspects of control. Has anyone come across a tutorial or example for something like this?
View 1 Replies View RelatedMy accelerometer is not reading the angle of the phone right. When I play Teeter I have to keep the phone on a sharpe angle to keep the ball still, and I feel I have to rotate it extra to go into landscape mode. Now the question is... how do I readjust the accelerometer?
View 6 Replies View RelatedWhere can I find a simple example application that uses the Accelerometer Sensor?
I've seen the Open Intents applications, but I'd rather use the raw Android API, at least until I understand it a little better. I'm surprised at the lack of documentation.
I want to know how to calculate the accelerometer movement.When i place the mobile horizontally in idle state and similarly when i place the mobile in hands,So there accelerometer value change when it is place horizontally or while it is in hand vertically.How To Identify them,Any Sample Codes will be useful.
View 1 Replies View RelatedI'm working on adding a calibration feature to an accelerometer-driven game. For the calibration, I need a single value from the accelerometer. Should I register a listener, get the first value it gives me, and unregister it, or is there a better way to get just one value?
View 2 Replies View RelatedHere's the code:
package com.android.DidYuKnow;
import java.util.Random;
import android.app.Activity;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.widget.TextView;
[URL]
The problem is that nothing appears in my textview after shaking the phone.
I've been playing with the data given by the accelerometer,trying to work out how I can gauge a shake from front to back or side to side. This all seems straightforward enough.But I'd love to know the direction of the shake. So, if the user is shaking backwards and forwards, I want to know if the device is moving away from the user, or back towards him/her. I can't find any way of telling this.
View 6 Replies View RelatedI have just got a Android 2.1 enabled device. I am looking out for the Best 3D Car Racing Game which works on Motion Accelerometer. Of course a free version is what I am looking out for.
View 5 Replies View RelatedIf it could turn to the right as opposed to the left, typing on the landscape keyboard would be much easier. The botton of the phone would not get in the way. Just wondering.
View 1 Replies View RelatedI'm tinkering around with trying to build a speedometer using only the accelerometer for use when I go snowboarding. I can read values from the accelerometer but I'm not sure how I would derive the velocity. I was thinking of taking the square root of (X^2 + Y^2 + Z^2) where X, Y, and Z are the values reported by the accelerometer in each axis but that only would only give me the amplitude of acceleration at any given instant. I could multiple that by the sampling frequency to get my instantaneous velocity but this approach fails when I'm moving at a constant speed.
View 2 Replies View RelatedI wanted to get the frequency of accelerometer output. How many readings can I get per second? And to what precision do I get?
View 5 Replies View RelatedI know this question is definitely solved somewhere many times already, please enlighten me if you know of their existence,
Quick rundown:
I want to compute from a 3 axis accelerometer the gravity component on each of these 3 axes.
I have used 2 axes free body diagrams to work out the accelerometer's gravity component in the world X-Z, Y-Z and X-Y axes. But the solution seems slightly off, it's acceptable for extreme cases when only 1 accelerometer axis is exposed to gravity, but for a pitch and roll of both 45 degrees, the combined total magnitude is greater than gravity (obtained by Xa^2+Ya^2+Za^2=g^2; Xa, Ya and Za are accelerometer readings in its X, Y and Z axis).
More detail:
The device is a Nexus One, and have a magnetic field sensor for azimuth, pitch and roll in addition to the 3-axis accelerometer.In the world's axis (with Z in the same direction as gravity, and either X or Y points to the north pole, don't think this matters much?), I assumed my device has a pitch (P) on the Y-Z axis, and a roll (R) on the X-Z axis. With that I used simple trig to get:
Sin(R)=Ax/Gxz
Cos(R)=Az/Gxz
Tan(R)=Ax/Az
There is another set for pitch, P.Now I defined gravity to have 3 components in the world's axis, a Gxz that is measurable only in the X-Z axis, a Gyz for Y-Z, and a Gxy for X-Y axis.Gxz^2+Gyz^2+Gxy^2=2*G^2 the 2G is because gravity is effectively included twice in this definition. Oh and the X-Y axis produce something more exotic I'll explain if required later.From these equations I obtained a formula for Az, and removed the tan operations because I don't know how to handle tan90 calculations (it's infinity?).So my question is, anyone know whether I did this right/wrong or able to point me to the right direction?
I have a code snippet to detect accelerometer movements. It works some times by properly detecting slight movements, but sometimes it detects movements when I kept my device idle too. Are there any problems with built-in accelerometer detection on Android?
I use an HTC G-1 device. My code snippet is below. How do I resolve it so I can detect small device movements but not detect anything when the device is idle?
CODE:..............
i dont have an android phone write now.But in my application i need to use accelerometer values..so i need an a simulator capable of it.
View 2 Replies View RelatedWe are writing an application that uses acceleration sensor data to plot phone's movement in 3D. We are finding gross inconsistencies in the actual data output by the sensor. Also, sampling rates vary greatly from 8 to 200 millis. (using System.currentTimeMillis())
Specifically, when we try to draw a circle with G1 flat on the table all the time (filtering out gravity accel 9.8), most of the time we would get a plot of phone's position that is not a circle at all. Lots of times, it would be close to a straight line. Sometimes, it would start drawing an arc, but would not close the circle shooting off in a random direction.
We tried to eliminate the time variable, by substituting a constant time sampling rate (10 millis) to calculate phones position, but the result was very close to what we had before (shapewise). Also, the acceleration in Z direction when the phone is displaced lying flat on a table (XY plane) varies too by +/- 2 units which is a lot.
I do not think it is an error in our code, as we have checked it many times. If there were an error indeed and the accelerometer worked properly, we would see a consistently wrong depiction of the phone's movement. Unfortunately, repeating the same movement (circle) would produce sometimes wildly differently shaped plots.
It all comes down to us wanting to know if that is indeed the case that the G1 accelerometer is very unreliable and inconsistent device when used for more or less precise measurements? Is there some documentation/facts paper that would tell us just how reliable accelerometer is?
To be able to do some accurate calculations that I want for my app, I need to be able to get an accelerometer reading every 100ms. I haven't found a way to do this on android, it seems like the only way to get accelerometer readings is to put a listener that can listen at different intervals. Basically, is there a way to get a reading at exact intervals?
View 2 Replies View RelatedI am looking to root my brothers phone to fix the lag issue...I have a couple questions though first...
His GPS is off by almost 30+ feet...it never comes in closer (My Droid X will go in to almost 5 feet or less.). I don't know a LOT about the Vibrants root/lag fix...
Also his accelerometer is off by about 7 degrees (through Android Sensor Data app).
So my question is...does the lag fix have any form of fix for the radios/accelerometer sensors in there as well? Also do you have the stock sbf in case the phone does need to go back in to return it to stock?
It seems trivial to use GPS in a background service, but how can you do the same with the accelerometer? Everything I've tried seems to require a context, but a background service doesn't have a context?
View 5 Replies View RelatedI am recently doing a graduate research on the accelerometer in mobile devices. Accelerometer is a MEMs device built in almost every smart phone nowadays. I am interested in finding what information does the hardware accelerometer report that the software knows the raw values X, Y, Z to detect the orientation in which the phone is held?
View 1 Replies View Relatedthe remapCoordinateSystem method remaps the axis for sensor readings, but I want to remap the coordinate system to any angle, for example: new coordinate system is say relative to earth's coordinate system, 20 degrees clockwise to earth's X axis, and 10 degrees to earth's Y axis, while Z is derived from X and Y axis.
View 2 Replies View RelatedCurrently it seems that locking the screen automatically turns off the accelerometer. I looked around for quite a while and didnt find any solution for that. Is that intentional? It would be really helpful to know if this is how it is or if I just didnt find the solution for that so far.thank you for any help on that (and as I said, even "doesnt work right now/on purpose/.
View 5 Replies View RelatedAs I understand it, there seems to have been a change in the OS that prevents the accelerometer from running when the screen turns off and the phone CPU goes into its power saving state.Can this be confirmed?I have gotten around this by using a wake lock, but this is a much less than ideal solution as it drains a lot of battery.If the accelerometer was disabled in low power mode to save the battery, it may very well have the opposite effect in many cases, such as mine.A partial wake lock seems to be required to keep it running, which is obviously much worse than if just the accelerometer were running without the need for the wake lock.Are there any other workarounds anyone knows of to getting accelerometer values while the phone is in low power mode?Also, are there any plans to change this in future versions of the OS?If there are no plans to change this, I would definitely like to petition for this to be changed.
View 14 Replies View Relatedremoving the g factor from accelerometer readings. I am using SensorEventListener with onSensorChanged() method for getting Sensor.TYPE_ACCELEROMETER data. I need only pure acceleration values in all directions. So at any state if the device is stable (or in constant speed), it should give (0.0,0.0,0.0) roughly.
Currently, depending on its pitch and roll, it gives me variable output depending on the g forces acting on each axis. I hope there is some formula to remove this, as I also get orientation values (pitch and roll) from Sensor.TYPE_ORIENTATION listener. I had used some but didn't work.
I am developing a small application for learning purpose which will move image when accelerometer readings change. I want a mapping of accelerometer values to screen coordinates. I am using trial and error method rite now. But it seems that it will not help. Is there any algorithm??
View 2 Replies View RelatedCan it be determined that where a person is i.e is he walking ? is he in elevator ? or is he climbing up the stairs ? using android's accelerometer or is there any other way to calculate such in android ?
View 2 Replies View RelatedDoes anyone know how to convert the accelerometer readings from g's to degrees?For example, if I want to use the x-axis readings and measure the tilt of the phone, flat would be 0g = 0 degrees and a 90 degree tilt to the right would be 1g (9.80665 m/sec^2).I can't come up with a formula for say 20 degrees or 45 degrees. Any help would be greatly appreciated.
View 2 Replies View Related