Hi Guillermo, thanks for your collaboration.
Regarding my issue. I didn't try low-pass filter, but I'm not sure
that it will make sense to use it. Let me explain:
Low-pass filter just reduce peaks and remove some white noise. For
each device it will reduce peaks with the same proportion,
and as a result I'll get the same difference in peaks for different
devices.
I mentioned that there's a sensor's "resolution" parameter and it also
different for linear accelerometer on Xoom and Sensation.
I hope it can help me, but I still have no answer what this parameter
means. Maybe someone here heard about that or google guys throw the
light upon it.
OK, what about your issue. Previously I made the similar actions with
transformations like you described.
What you need to do:
1. to handle device position against X axis. There're two states:
device lay down (on a table for example) and device in vertical
position.
You must implement and register OrientationEventListener. It has a
callback onOrientationChanged(int orientation) where orientation is a
degree value.
There's a hint -> (orientation ==
OrientationEventListener.ORIENTATION_UNKNOWN) in case device lays
down. So I hope there're no problems.
In code bellow I called it mInclinationType and made additional enum
for values: enum Incline {VERTICAL, HORIZONTAL }
2. to handle device position against Z axis. In other words rotation.
You can achieve it using getRotation() call from Display instance.
3. and finally to determine how to map axis for transformation based
on values above. This is my code for onSensorChanged() callback:
switch (mDisplay.getRotation()) {
case Surface.ROTATION_0:
if (mInclinationType == Incline.VERTICAL) {
SensorManager.remapCoordinateSystem(mR,
SensorManager.AXIS_X,
SensorManager.AXIS_Z, mRTransformed);
} else {
SensorManager.remapCoordinateSystem(mR,
SensorManager.AXIS_X,
SensorManager.AXIS_Y, mRTransformed);
}
break;
case Surface.ROTATION_90:
if (mInclinationType == Incline.VERTICAL) {
SensorManager.remapCoordinateSystem(mR,
SensorManager.AXIS_Z,
SensorManager.AXIS_MINUS_X,
mRTransformed);
} else {
SensorManager.remapCoordinateSystem(mR,
SensorManager.AXIS_Y,
SensorManager.AXIS_MINUS_X,
mRTransformed);
}
break;
case Surface.ROTATION_270:
if (mInclinationType == Incline.VERTICAL) {
SensorManager.remapCoordinateSystem(mR,
SensorManager.AXIS_MINUS_Z,
SensorManager.AXIS_X, mRTransformed);
} else {
SensorManager.remapCoordinateSystem(mR,
SensorManager.AXIS_MINUS_Y,
SensorManager.AXIS_X, mRTransformed);
}
break;
}
SensorManager.getOrientation(mRTransformed,
mOrientation);
Some comments:
here I missed case with Surface.ROTATION_180 because it wasn't
applicable for my HTC desire. You can simply add it by yorself :)
mInclinationType - my first parameter.
mR - rotation matrix got using accel and magnetic data
mRTransformed - array for transformed matrox
mOrientation - array for result (yaw, roll, pitch)
I hope it will be helpfull. Feel free if something unclear.
What about getRotationMatrix().
It requires gravity data. Values got from plain 3-x axis accelerometer
(not linear) are fine, because their contain gravity.
You also can achieve gravity values using separate GRAVITY sensor
which were introduced since 9 API version.
Thanks,
Dmitry
On 14 фев, 16:10, Guillermo Polonsky <[email protected]> wrote:
> Are you low filtering the values? That can help. For example you can create
> an array of 10 position, then each time the accelerometer/linear
> acceleration gives you a value you do something like this:
>
> accelVals = lowPass( currentEvent.values, accelVals );
>
> where lowPass method is:
>
> protected float[] lowPass( float[] input, float[] output ) {
> if ( output == null ) return input;
>
> for ( int i=0; i<input.length; i++ ) {
> output[i] = output[i] + ALPHA * (input[i] - output[i]);
> }
> return output;
>
> }
>
> and static final float ALPHA = 0.2f;
>
> Can you please share how you handled 1)?
>
> Right now I have a problem knowing if the device is with it's screen
> looking up, to the user, or the opposite of those, and the
> remapCoordinateSystem.
> Please have a look at my question:
>
> Hi all!
> What I'm trying to achieve is calculate if a runner is running,
> stopping, etc. (and I can't use the GPS), where the runner can have the
> device in different positions (portrait facing the user, portrait facing
> the user, upside down, not facing the users, etc.
>
> I must know which axle is the one parallel to the floor in order to
> check if there is any acceleration or deceleration and not check on other
> axle and get an acceleretion/deceleration when the device is really just
> "jumping" with the runner, meaning I checked the wrong axle.
>
> I'm trying to get the orientation of the device in every position
> it might be. I'm not using the TYPE_ORIENTATION sensor as it is deprecated,
> I'm using acceleration and magnetic sensor values or rotation_vector
> sensor, in that way I can get the rotation matrix, Once I have it, if the
> screen if facing the user I can get azimuth, pitch and roll remapping the
> coordinate system, knowing the X and Y axles with this table:
>
> *ROTATION_0*
>
> *X*
>
> *Y*
>
> *ROTATION_90*
>
> -Y****
>
> X****
>
> *ROTATION_180*
>
> -X****
>
> -Y****
>
> *ROTATION_270*
>
> Y****
>
> -X****
>
> I get the rotation with getDefaultDisplay().getRotation()
>
> Now, If the device if flat on the table, What will the getRotation
> retrieve? What if I rotate it while it's flat on the table? What should I
> be sending to the the remapCoordinateSystem?
>
> Is this ok?
>
> *ROTATION_0*
>
> *X*
>
> *Z*
>
> *ROTATION_90*
>
> Z****
>
> -X****
>
> *ROTATION_180*
>
> -X****
>
> -Z****
>
> *ROTATION_270*
>
> -Z****
>
> X****
>
> BTW, getRotationMatrix documentation says that I must send gravity values,
> but everyone is sending accelerometer values (which are acceleration +
> gravity),
>
> If the device has TYPE_GRAVITY sensor, Should I send its values instead
> TYPE_ACCELEROMETER sensor values?
>
> Thanks in advance! Guillermo.
>
> On Tue, Feb 14, 2012 at 4:05 AM, Dmitry Tupikin
> <[email protected]>wrote:
>
>
>
>
>
>
>
> > I'm working on Android navigation app which uses complex of sensors to
> > determine position changes. In some cases device cannot achieve GPS
> > signal for a while (tunnel or multilevel parking) and I want to
> > compensate these gaps using INS approach.
> > Yes I know that there're another approaches like cell-id or data got
> > from device's carrier, but currently I'm focused on sensors.
>
> > Well, INS approach can be divided into two big tasks:
> > 1. attitude determination (gyro or accelerometer + magnetometer or
> > some combination)
> > 2. velocity and distance calculation. Here I double integrate linear
> > accelerometer values.
>
> > Now I try to resolve the second task. I prepared all calculation and
> > made contrastive analysis of data got from linear accelerometer on
> > different Android devices: Sensation, Motorola Xoom and Nexus S. I put
> > all devices on a platform and moved the platform on 8 meeters with an
> > acceleration on Y axis.
> > After that I built graphics and they really confused me - all 3
> > graphics has the same amplitude but peak values are different.
> > For example at the same moment I have 0.2 m/s^2 on Xoom and 1.2 m/s^2
> > on Sensation.
> > Hence after calculation I had a big difference in distance.
>
> > Official documentation doesn't explain it. I surfed the web but didn't
> > find any answer about that issue.
>
> > So my question is: did someone faced to it? Or maybe you know an
> > advice which will help me to solve it?
>
> > In addition, android Sensor class has few parameters. I found that
> > Sensation and Xoom has different RESOLUITON values -
> > Sensor.getResolution().
> > Sensation - 1.0
> > Xoom - 0.009576807
>
> > I'm stack with it, so any help will be really good! Thanks in advance.
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en