How to get velocity from variable accelerometer(in simple linar motion)? - iphone

I want compute the current iphone motion velocity anytime based on accelerometer, the accelerometer is variable. Anyone can give any idea?

It's basically impossible. The only way is to integrate the acceleration, but that magnifies the inaccuracy of the iPhone's not very accurate accelerometer, and because you don't have an independent orientation sensor (the iPhone uses gravity to figure that out!), you can't distinguish lateral acceleration from tilting the phone.
How people do this in the real world is to measure velocity using something else like GPS, and use the accelerometer to interpolate.

Related

Which sensor is used in Unity Gyroscope.userAcceleration API

Does anyone know if Unity's API Gyroscope.userAcceleration (https://docs.unity3d.com/ScriptReference/Gyroscope-userAcceleration.html) is using gyroscope sensor to work or accelerometer?
Edit my answer:
Gyroscope.userAcceleration uses the acceleration data from the gyroscope and the accelerometer sensor of your device. (refers to linear acceleration, not rotational)
So it seems the Gyroscope class performs some sort of sensor fusion.
AccelerometerInput uses the build in accelerometer sensor of your device.
I believe it must use the accelerometer, since gyroscope cannot measure accelleration (while accelerometer can be used to extract rotation to a certain degree), userAcceleration just takes out the constant part (gravity aka earth acceleration) out, so when the device is not being moved user acceleration is zero even if actual data from the accelerometer contains gravity

How do I get absolute acceleration in unity?

I want to define a coordinate system when unity starts based on the phone, but then have that stay constant forever on after, so that when I then measure acceleration, it disregards how the phone is tilted (where it is facing) and instead just measures how it is moved. Is there an api for this? The normal Input.acceleration or gyro doesn't work.
Using Gyroscope.userAcceleration; is the possible solution. It measures the acceleration that user provides to the device i.e, it discards the effect of gravity.

iPhone/iPad gyroscope

I never really understand the applications of the gyroscope on the iPhone/iPad, does it serve the similar function as the accelerometer but like an improvement to the accelerometer? What is the practical use of it?
"An accelerometer is a direct measurement of orientation, while a gyro is a measurement of the time rate of change of orientation." (1) By combing the output of the two sensors, called sensor fusion, one can determine the orientation of the device precisely and fast.
If you only use accelerometer with a low-pass filter, you still get a reasonable estimate for the orientation but it will lag.
Here is an excellent live demo of both (Google Tech Talk), starting at 21:50.
Gyroscope measures orientation, where accelerometer measures movement. Both have useful applications (gyroscope: Which direction am I driving towards? Accelerometer: Did I just shake my device?)
The accelerometer tells you the difference in the force being experienced by the device and the force it would experience if it were in free fall. So if the device is static, the accelerometer tells you which way up is. When it's being shaken around, you get a summation of up plus the direction of the shake. Hence the accelerometer can detect some rotation, but not around the gravity vector and only if the device is otherwise static.
The gyroscope tells you the velocity at which the device is being rotated. So you can integrate values coming from it to keep track of orientation. That works across all axes and irrespective of device movement.

Transform device orientation to world frame in objective c

I'd like to transform the yaw, pitch and roll of the iPhone from the body frame to the world frame, i.e. azimuth, pitch and roll. On Android this is easily done with the
SensorManager.remapCoordinateSystem(), SensorManager.getOrientation methods as detailed here: http://blog.mysticlakesoftware.com/2009/07/sensor-accelerometer-magnetics.html
Are similar methods available for the iPhone or can someone point me in the right direction how to do this transformation?
Thanks
The accelerometer is good enough to get gravity direction vector in device coordinate system. That is in case when device calms down.
The next step for full device orientation is to use CLLocationManager and get the true north vector in device coordinate system.
With the normalized true north vector and gravity vector you can easily get all other directions using the dot and cross vectors product.
The accelerometer (UIAccelerometer) will give you a vector from the device's accelerometer chip straight down. If you can assume that the device is being held fairly steady (i.e., that you're not reading acceleration from actual movement), then you can use simple trig (acos(), asin()) to determine the device's orientation.
If you're worried that the device might be moving, you can wait for several accelerometer readings in a row that are nearly the same. You can also filter out any vector with a length that's ± TOLERANCE (as you define it) from 1.0
In more general terms, the device has no way of knowing its orientation, other than by "feeling gravity", which is done via the accelerometer. The challenges you'll have center around the fact that the accelerometer feels all acceleration, of which gravity is only one possible source.
If you're targeting a device with a gyroscope (iPhone 4 at the time of writing), the CoreMotion framework's CMMotionManager can supply you with CMDeviceMotion updates. The framework does a good job of processing the raw sensor data and separating gravity and userAcceleration for you. You're interested in the gravity vector, which can define the pitch and roll with a little trig. To add yaw, (device rotation around the gravity vector) you'll also need to use the CoreLocation framework's CLLocationManager to get compass heading updates.

Spinning iphone based on ground

I am rotate iphone based on the ground
But the UIAcceleration values of (x&y&z) are same . Can you tell me exactly what happens here ?
Also i want know how to its calculate UIAcceleration values of(x&y&z) ?
I am really interested to work with UIAcceleration values.
Can anyone help me?
Thanks in advance.....
The UIAcceleration value can only detect acceleration relative to the orientation of the device.
By rotating the iPhone, in its frame of reference there is a constant gravity force (along the z axis) and a constant centrifugal force (on the xy-plane), so the UIAcceleration will not change.
You cannot distinguish acceleration due to gravity or linear acceleration or rotation by the accelerometer. You need other devices e.g. the compass (magnetometer) to detect a rotational change.