I am creating an Android game that uses the accelerometer for X-axis and Y-axis movement in landscape orientation. The X-axis works as expected, however the Y-axis is causing an issue.
For the Y-axis to work properly, the Y-axis needs to be at 0 (The phone is perfectly screen-up.) This is an issue because I don't expect users to be hunched over their phones to play properly.
I attempted to correct this by taking the initial reading of the Y-axis orientation and subtracting that from the following Y-axis readings, but if the user begins the game at -10 (Phone screen directly facing them) the phone will not register any further tilting back.
Does anyone know a better way to handle this situation? Thank you all for the help thus far!
It's possible. Check out Allowing both landscape options and accelerometer with libgdx
and a fix for accelerometer reading
Related
I'm trying to get the values of Magnetic Field on each axis using my mobile phone, it seems that the results that I get from magnetometer sensors depend on the phone reference (see 1). So every time I rotate or move my phone, I get different values.
I tried to fix a reference so I can get constant values. For the moment, I can get the 3 angles: yaw pitch and roll. I'm conviced that by calculating a certain rotation matrix with those angles, I will arrive to fix that issue. Have you had a similar problem ?
phone axis
Thank you and have a good day :)
Sorry if the title is hard to understand, I don't know how else to phrase it.
Accelerometer data on android is relative to the screen's orientation and tilt (TYPE_ACCELEROMETER) I am trying to make an app in which accelerometer data is constant regardless of how the user is holding his device. I think I'd have to calculate angle of tilt from the gravitational force affecting the XYZ values and somehow go from there as well as use the compass to lock the X axis to north (or any other direction). Anyone have some ideas/tips?
Thanks!
I have been set a project for college that needs to make use of the Android Gyroscope Functionality, the problem is, my application is quite simple in that it just displays information about a sports event to the user (e.g. current games, stadium info, team stats etc).
I initially thought that I could make use of the Gyroscope to change my layout to a different style depending on the orientation of the screen (portrait and landscape) but from what I know now, it seems that this isn't really something that the Gyroscope is used for? correct me if i'm wrong?
My question is, what could I use the gyroscope for for a simple like I mentioned?
Android already handles portrait and landscape orientation so as you mentioned there is no need to use gyroscope for this. I believe its the most popular usage is for a game controller when you should rotate your device to do something.
But sure you can use it for something similar in your app. Like to display an image always horizontally despite of the device rotation.
Dear programmers/scripters/engineers/other people,
The problem:
I'm currently developing an augmented reality application for an Android 3.2 tablet and having some issues with getting an accurate compass reading. I need to know exactly the (z) direction the tablet is facing, measured from the north. It doesn't matter if it's in degrees or radians.
What I currently have tried:
I used the magnetometer and accelerometer to calculate the angle. It has one big disadvantage. If you rotate 90 degrees, the sensors will measure a larger or a smaller angle. Even when I'm in an open field far away from metal or any magnetic objects. Even the declination doesn't solve it.
Using the gyroscope would be an option. I have tried to measure the rotating speed and store the measured units into a variable to know the exact view direction. There seems to be an factor that causes distortion though. I found out that fast rotations distort the accurate direction measurement. The gyro's drift wasn't that much troublesome. The application checks the other sensors for any movement. If none is detected, the gyro's rotation change won't be taken into account.
The rotation vector works okay. It has some issues like the gyroscope. If you move slowly and stop at a suddenly moment, it will drift away for a few seconds. Another problem is that it will be inaccurate with quick rotations depending on the speed and how many turns you've made. (You don't want to know how my co-workers are looking at me when I'm swinging the tablet in all directions...)
Sensor.Orientation, not much to say about. It is deprecated for some reason so I won't use it. A lot of examples on the internet are using this sensor and it's probably the same thing as the magnetic/accelerometer combination.
So I'm currently out of idea's. Could you help me with brain storming / solution solving?
Thanks in advance, yours sincerely, Roland
EDIT 1:
I am willing to provide the code I have tried.
I'm summing up our comments:
its clear from this video that the sensors on phones are not very accurate to begin with. Also interesting to read is this
it its important that the user calibrates the sensors by doing a figure 8 motion holding the phone flat. An App can programmatically check if such a calibration is necessary and notify the user. See this question for details
To eliminate jitter the values obtained from the sensors need to be filtered by a low pass filter of some kind. This has also been discussed on StackOverflow.
The orientation obtained is not the true north. To obtain the true north one must use GeomagneticField
I was wondering if there is a way to find out the size of a persons finger when they touch an android device. I want to know this so i can change the sensitivity of certain objects in my game.
A solution for devices that don't offer the touch.getSize() function, you can have on the start screen a high resolution plot of 2d points. On touch, detect the ones touched and there you can have a pretty accurate area of how big the finger is.