Gyroscope sensor: what is the axis around which the device's rotating? - sensors

i am coding 1 app which is same app "iHandy Level Free" on google play.
i am using gyroscope sensor, but i don't know what is the axis around which the device's rotating ? because when i rotate, tilt device, 3 values x, y, z are change too.
thanks

The Android follows ENU(east, North, UP ), have a look at this Application Note : http://www.st.com/st-web-ui/static/active/jp/resource/technical/document/application_note/DM00063297.pdf
convention , so you will get a bigger value for the axis around which the device is being rotated.
It is not possible to get a Zero value around any axis no matter how gently you move the device .You are bound get some angular rate around the tationary axis (which you are assuming to be stationary)

Related

Find the north using Quaternions, Gyro and Compass

This question is about an algorithm, not a specific language.
I have a mobile device, with the following axis -
When the device is pointed perpendicular to the ground (Positive Z facing up), I get an accurate reading of the compass in degrees with the angle being between north and the positive Y of the device.
So if I hold the device and point it west, I will get either the value 270 or the value -90 (not quite sure how to figure out which one I'll get).
When I hold the device with Y pointing towards the sky, the compass is no longer accurate BUT I can use the device accelerometer to figure out when that is the case AND I can use the gyro to figure out what the rotation of the device is.
So, when I get an accurate reading of the compass, I am saving a parameter called "lastAccurateAttitude", which is the Quaternion from the gyro.
I also save "lastAccurateHeading" as the angle from north.
What I am attempting to do is use lastAccurateHeading, lastAccurateAttitude and the current attitude, to calculate the angle between the north and the negative z axis of the device.
Right now, I am stuck on the math, so I would appreciate some help.
If possible, I would love for this to also work when either x, -x, y or -y of the device are pointing upwards. (The north would still be calculated compared to -z).

Orientation from magnetometer data

I saw lot of topics with the same title but answers are different.
I have a magnetometer in my phone which give me the components of magnetic field in direction of X, Y, Z.
Which of the following angles can be determined using datas of magnetometer?
Roll, pitch, yaw? And how?
Thank you,
Robert
With a magnetometer alone convention would say you could calulate pitch and yaw. Assuming the z axis of the magnetometer points north. If the device was pointed perpendicular to the north vector then it would be able to calculate roll. As I understand it.

Using python with OpenGL

I got my rotation values from OPI0 to my pc and now i want to get a object to rotate in that direction where my gyroscope is facing (degree values from 180 to -180) Im fairly new to Python.
glRotatef(1, xrot, yrot, zrot) Only sets the rotation + the current rotation.
But what i actually want to have is that if it is on 180 degrees, i want to place it to 180 degrees. This could be archieved by getting the current rotation, testing if its smaller or largen and then adjust the rotation or setting the rotation with a command to the degree value.
So my main questions are:
Is there a command to set the rotation value of the created object?
Is there a way to read the current rotation value?
Well, if you
glLoadIdentity()
before
glRotatef()
then it should always rotate to the specified degrees, instead of relatively rotating.
Depending on how and where you've setup your camera and object translation, you might have to refactor your code a bit, because of the identity (it will clear all other transformations you done before).

Game Programming - Billboard issue in front of 3D object

I'm starting to develop a poc with the main features of a turn-based RPG similar to Breath of Fire 4, a mixture of 3D environment with characters and items such as billboards.
I'm using an orthographic camera with an angle of 30 degrees on the X axis, I did my sprite to act as a billboard with the pivot in the center, the problem occurs when the sprite is nearing a 3D object such as a wall.
Check out the image:
I had tried the solution leaving the rotation matrix of the billboard "upright", worked well, but of course, depending on the height and angle of the camera toward the billboard it gets kinda flattened, I also changed the pivot to the bottom of the sprite but this problem appears with objects in front of the sprite too. I was thinking that the solution would be to create a fragment shader that relies on the depth texture of some previous pass, I tried to think in how to do it with shaders but I could not figure it out. Could you help me with some article or anything that puts me in the right direction? Thank you.
See what I am trying to achieve on this video.
You had got the right approach. Use the upright matrix, and scale up Z of billboards preparing flattened Z by your camera. The Z scaling should be about 1.1547. It is (1 / cos30), which makes billboards look like original size from the camera with the angle of 30 degrees. It seems a tricky way but developers of BoF4 on the video might use the same solution too.

Position calculation of small model of a car using Accelerometer + Gyroscope

I wish to calculate position of a small remote controlled car (relative to starting position). The car moves on a flat surface for example: a room floor.
Now, I am using an accelerometer and a gyroscope. To be precise this board --> http://www.sparkfun.com/products/9623
As a first step I just took the accelerometer data in x and y axes (since car moves on a surface) and double integrated the data to get position. The formulae I used were:
vel_new = vel_old + ( acc_old + ( (acc_new - acc_old ) / 2.0 ) ) * SAMPLING_TIME;
pos_new = pos_old + ( vel_old + ( (vel_new - vel_old ) / 2.0 ) ) * SAMPLING_TIME;
vel_old = vel_new;
pos_old = pos_new;
acc_new = measured value from accelerometer
The above formulae are based on this document: http://perso-etis.ensea.fr/~pierandr/cours/M1_SIC/AN3397.pdf
However this is giving horrible error.
After reading other similar questions on this forum, I found out that I need to subtract the component of Gravity from above acceleration values (everytime from acc_new) by using gyroscope somehow. This idea is very well explained in Google Tech Talks video Sensor Fusion on Android Devices: A Revolution in Motion Processing at time 23:49.
Now my problem is how to subtract that gravity component?
I get angular velocity from gyroscope. How do I convert it into acceleration so that I can subtract it from the output of accelerometer?
It won't work, these sensors are not accurate enough to calculate the position.
The reason is also explained in the video you are referring to.
The best you could do is to get the velocity based on the rpm of the wheels. If you also know the heading that belongs to the velocity, you can integrate the velocity to get position. Far from perfect but it should give you a reasonable estimate of the position.
I do not know how you could get the heading of the car, it depends on the hardware you have.
I'm afraid Ali's answer is quite true when it comes to those devices. However why don't you try searching arduino dead reckoning which will cover stories of people trying similar boards?
Here's a link that appeared after a search that I think may help you:
Converting IMU to INS
Even it seems like all of them failed you may come across workarounds which will decrease errors to acceptable amounts or calibrate your algorithm with some other sensor to put it back in track as the squared error of acceleration along with gyros white noise destroying accuracy.
One reason you have a huge error is that the equation appears to be wrong.
Example: To get updated vel,use.. Velnew=velold+((accelold+accelnew)/2)*sampletime.
Looks like you had an extra accel term in the equation. Using this alone will not correct all the error....need to as you say correct for influence of gravity and other things.

Resources