Question

We can retrieve the acceleration data from CMAcceleration.

It provides 3 values, namely x, y and , z.

I have been reading up on this and I seem to have gotten different explanation for these values.

Some say they are the acceleration values in respect to gravity.

Others have said they are not, they are the acceleration values in respect to the axis as they turn around on its axis.

Which is the correct version here? For example, does x represent the acceleration rate for pitch or does it for from left to right?

In addition, let say if we want to get the acceleration rate (how fast) for yaw, how could we be able to derive that value when the call back is feeding us constantly with values? Would we need to set up another timer for the calculation?


Edit (in response to @Kay):

Yes, it was basically it - I just wanted to make sure x, y, z and respectively pitch, roll and yaw and represented differently by the frame.

1.)

How are these related in certain situations? Would there be a need that besides getting a value, for example, for yaw that needs addition information from the use of x, y, z?

2.)

Can you explain a little more on this:

(deviceMotion.rotationRate.z - previousRotationRateZ) / (currentTime - previousTime)

Would we need to use a timer for the time values? And how would making use of the above generate an angular acceleration? I thought angular acceleration entail more complex maths.

3.)

In a real world situation, we can barely only rely on a single value from pitch, roll and yaw because that would be impossible to for us to make a rotation only on one axis (our hand is not that "stable". Especially after 5 cups of coffee...)

Let say I would like to get the values of yaw (yes, rotation on the z-axis) but at the time as yaw spins I wanted to check it against pitch (x-axis).

Yes, 2 motions combine here (imagine the phone is rotating around z with slight movement going towards and away from the user's face).

So: Is there is mathematical model (or one that is from your own personal experience) to derive a value from calculating values of different axis? (sample case: if the user is spinning on z-axis and at the same time also making a movement of x-axis - good. If not, not a good motion we need). Sample case just off the top of my head.

I hope my sample case above with both yaw and pitch makes sense to you. If not, please feel free to cite a better use case for explanation.

4.)

Lastly time. How can we get time as a reference frame to check how fast a movement is since the last? Should we provide a tolerance (Example: "less than 1/50 of a second since last movement - do something. If not, do nothing.")? Where and when do we set a timer?

Was it helpful?

Solution

The class reference of CMAccelerometerData says:
X-axis acceleration in G's (gravitational force)

The acceleration is measured in local coordinates like shown in figure 4-1 in the Event Handling Guide. It's always a translation und must not be confused with radial or circular motions which are measured in angles.

Anyway, every rotation even with a constant angular velocity is related to a change in the direction and thus an acceleration is reported as well s. Circular Motion

What do you mean by get the acceleration rate (how fast) for yaw?

Based on figure 4-2 in Handling Rotation Rate Data the yaw rotation occurs around the Z axis. That means there is a continuous linear acceleration in the X,Y plane. If you are interested in angular acceleration, you need to take CMDeviceMotion.rotationRate and divide it by the time delta e.g.:

(deviceMotion.rotationRate.z - previousRotationRateZ) / (currentTime - previousTime)

Update:
It depends on what you want to do and which motions you are interested in to track. I hope you don't want to get the exact device position in x,y,z when doing a translation as this is impossible. The orientation i.e. the rotation relativ to g can be determined very well of course.

  1. I think in >99% of all cases you won't need additional information from accelerations when working with angles.
  2. Don't use your own timer. CMDeviceMotion inherits from CMLogItem and thus provides a perfect matching timestamp of the sensor data or respectivly the interpolated time for the result of the sensor fusion algorithm.
    I assume that you don't need angular acceleration.
  3. You are totally right even without coffee ;-) If you look at the motions shown in this video there is exactly the situation you describe. Maths and algorithms were the result of some heavy R&D and I am bound to NDA.
    But the most use cases are covered with the properties available in CMAttitude. Be cautious with Euler angles when doing calculation because of Gimbal Lock
  4. Again this totally depends on what you are up to.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top