Reply by May 20, 20152015-05-20
On Wednesday, May 20, 2015 at 8:05:20 AM UTC+12, sia4uin wrote:
> > > >Strictly speaking, you can't get pitch from acceleration, only > >direction of travel. If the direction of travel is restricted, like, > >for example, a train on a track or a truck, then the direction of > >travel should be correlated with pitch. > > > >For a helicopter or something like that, it may not be at all. > > > > > >Eric Jacobsen > >Anchor Hill Communications > >http://www.anchorhill.com > > Thank you Eric. > > I found that formula here > > http://stackoverflow.com/questions/7553417/complementary-filter-gyro-accel-with-android > > Also, how can I obtain gravity vector so I can subtract it from the > measured acceleration and obtain Linear Acceleration. > > Best Regards > > Sia > > > --------------------------------------- > Posted through http://www.DSPRelated.com
That one is all about accuracy of an accelerometer vs a gyro. one is good at low frequencies (accelerometer) and the other at high frequencies. So a filter (or two) is used to combine the readings into one to get the best of both sensors. It is a simple filter which low pass filters the accelerometer and high pass filters the gyro .
Reply by sia4uin May 20, 20152015-05-20
> >Plumb bob. > >Apologies for the flippant answer, but there is no genuine answer >without context. And even if you were to provide full context, it is >apparent that you would be helped more by studying the subject than by >having someone try to design a solution for you.
Thanks Greg. So ultimate task is to implement a Pedestrian Dead Reckoning (PDR) system. Now of course I want to study and understand each and every block the PDR system contains. So I though to start first with Orientation estimation. From the GoogleTalk video, I understood (may be incorrectly) that once I obtain accurate Orientation, I can estimate Gravity and then by subtracting Gravity from Raw Acceleration I can get Linear Acceleration. So after some search, I found online how to estimate Orientation via a Complementary Filter http://www.thousand-thoughts.com/2012/03/android-sensor-fusion-tutorial/ And since several function are from SensorManager, I found their implementation here https://android.googlesource.com/platform/frameworks/base/+/cdd0c59/core/java/android/hardware/SensorManager.java So I have implemented my own Matlab code to estimate Orientation from Accelerometer and Magnetometer data only (for now, later I will add Gyro). Please tell me if it makes sense. RotMatrix = GetRotationMatrix(ya,ym); % ya is Accel data and ym is Mag data Orientation = GetOrientation(RotMatrix) The above two function _GetRotationMatrix_ and _GetOrientation_ are as below. ------------------------------------------------------------------------- function RotMatrix = GetRotationMatrix(Accel, Mag) % Get Rotation Matrix from Acceleration and Magnetometer data % Obtained from https://android.googlesource.com/platform/frameworks/base/+/cdd0c59/core/java/android/hardware/SensorManager.java Ax = Accel(1); Ay = Accel(2); Az = Accel(3); Ex = Mag(1); Ey = Mag(2); Ez = Mag(3); Hx = Ey*Az - Ez*Ay; Hy = Ez*Ax - Ex*Az; Hz = Ex*Ay - Ey*Ax; normH = sqrt(Hx^2+Hy^2+Hz^2); Hx = Hx/normH; Hy = Hy/normH; Hz = Hz/normH; Ax = Ax/norm(Accel); Ay = Ay/norm(Accel); Az = Az/norm(Accel); Mx = Ay*Hz - Az*Hy; My = Az*Hx - Ax*Hz; Mz = Ax*Hy - Ay*Hx; RotMatrix = [ Hx Hy Hz Mx My Mz Ax Ay Az ]; ------------------------------------------------------------------------ ------------------------------------------------------------------------ function Orientation = GetOrientation(RotMatrix) % Get Orientation from Rotation Matrix % Obtained from https://android.googlesource.com/platform/frameworks/base/+/cdd0c59/core/java/android/hardware/SensorManager.java Orientation = zeros(1,3); RotMatrix = RotMatrix(:); Orientation(1) = atan2(RotMatrix(2), RotMatrix(5)); Orientation(2) = asin(-RotMatrix(8)); Orientation(3) = atan2(-RotMatrix(7),RotMatrix(9)); ------------------------------------------------------------------------- Then I pass the Orientation through a 1st Order Low Pass filter. Am I on the right track? Best Regards Sia --------------------------------------- Posted through http://www.DSPRelated.com
Reply by Greg Berchin May 20, 20152015-05-20
On Wed, 20 May 2015 09:49:14 -0500, "sia4uin" <105263@DSPRelated> wrote:

>What would be the quickest way to determine pitch, is there any quick >method which people use?
Plumb bob. Apologies for the flippant answer, but there is no genuine answer without context. And even if you were to provide full context, it is apparent that you would be helped more by studying the subject than by having someone try to design a solution for you.
Reply by sia4uin May 20, 20152015-05-20
>On Tue, 19 May 2015 15:16:21 -0500, "sia4uin" <105263@DSPRelated> >wrote: > >>So in the case of mobile device, where the y-axis is pointing ahead, >>x-axis is pointing sideways and z-axis is pointing up, will this >formula >>work ... > >The axis orientation is appropriate, but trying to use your formula in >the real world is extremely naive. It assumes that everything is >perfect >and free of disturbances. That only happens in homework problems.
Thanks Greg :) What would be the quickest way to determine pitch, is there any quick method which people use? Best Regards Sia --------------------------------------- Posted through http://www.DSPRelated.com
Reply by Greg Berchin May 20, 20152015-05-20
On Tue, 19 May 2015 15:16:21 -0500, "sia4uin" <105263@DSPRelated> wrote:

>So in the case of mobile device, where the y-axis is pointing ahead, >x-axis is pointing sideways and z-axis is pointing up, will this formula >work ...
The axis orientation is appropriate, but trying to use your formula in the real world is extremely naive. It assumes that everything is perfect and free of disturbances. That only happens in homework problems.
Reply by Greg Berchin May 20, 20152015-05-20
On Tue, 19 May 2015 15:16:21 -0500, "sia4uin" <105263@DSPRelated> wrote:

>So in the case of mobile device, where the y-axis is pointing ahead, >x-axis is pointing sideways and z-axis is pointing up, will this formula >work ...
The axis orientation is appropriate, but trying to use your formula in the real world is extremely naive. It assumes that everything is perfect and free of disturbances. That only happens in homework problems.
Reply by Greg Berchin May 20, 20152015-05-20
On Tue, 19 May 2015 15:16:21 -0500, "sia4uin" <105263@DSPRelated> wrote:

>So in the case of mobile device, where the y-axis is pointing ahead, >x-axis is pointing sideways and z-axis is pointing up, will this formula >work ...
The axis orientation is appropriate, but trying to use your formula in the real world is extremely naive. It assumes that everything is perfect and free of disturbances. That only happens in homework problems.
Reply by Greg Berchin May 20, 20152015-05-20
On Tue, 19 May 2015 15:16:21 -0500, "sia4uin" <105263@DSPRelated> wrote:

>So in the case of mobile device, where the y-axis is pointing ahead, >x-axis is pointing sideways and z-axis is pointing up, will this formula >work ...
The axis orientation is appropriate, but trying to use your formula in the real world is extremely naive. It assumes that everything is perfect and free of disturbances. That only happens in homework problems.
Reply by sia4uin May 20, 20152015-05-20
>> Found this video and it is very interesting and of course it is not >for >> novices like me. >> >> https://youtu.be/C7JQ7Rpwn2k?t15 >> >> How does he obtain Gravity to obtain Linear acceleration? > >He says _right in that video_ that it's nearly impossible to obtain a >decent gravity vector from the information available on the phone. > >There simply is not enough information available from the usual inertial > >sensors + compass to do navigation, unless the inertial sensors are >much, >much better than the ones found in a phone. > >-- >www.wescottdesign.com
Thank you Tim. But then he also says that by doing some fusion you can get estimate of Gravity. I found this link which uses Complementary filter instead of Kalman filter. http://www.thousand-thoughts.com/2012/03/android-sensor-fusion-tutorial/2/ He uses some inbuilt functions from Android which takes Accelerometer and Magnetometer as inputs and provides orientation. And then he applies Complementary filter on this orientation and Gyro data. Any idea what the Android function is doing when it combines Accelerometer and Magnetometer data? Best Regards sia --------------------------------------- Posted through http://www.DSPRelated.com
Reply by Tim Wescott May 20, 20152015-05-20
On Tue, 19 May 2015 13:58:48 -0500, sia4uin wrote:

> Hello All, > > Me again! > > I came across the following formula to calculate pitch from > accelerometer signals. > > pitch = atan2(Ay, sqrt(Ax^2+Az^2)) > > Is this correct?
As far as it goes, and assuming that y, in your coordinate system, is forward, and assuming that the pitch does not go beyond 180 degrees. So, correct and useless to boot. You need a 3-dimensional rotation vector (or 4, if you want to use quaternions).
> Now a slightly complicated stuff. > > Found this video and it is very interesting and of course it is not for > novices like me. > > https://youtu.be/C7JQ7Rpwn2k?t=1415 > > How does he obtain Gravity to obtain Linear acceleration?
He says _right in that video_ that it's nearly impossible to obtain a decent gravity vector from the information available on the phone. There simply is not enough information available from the usual inertial sensors + compass to do navigation, unless the inertial sensors are much, much better than the ones found in a phone. -- www.wescottdesign.com