Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Gyroscope when available #5

Closed
GoogleCodeExporter opened this issue Jun 9, 2015 · 9 comments
Closed

Use Gyroscope when available #5

GoogleCodeExporter opened this issue Jun 9, 2015 · 9 comments

Comments

@GoogleCodeExporter
Copy link

This is more of an enhancement request :) It would be nice if somebody could 
work on improving tracking by using the gyroscope in devices where it's 
available or a more complicated predictive filter (Kalman?)


Original issue reported on code.google.com by nkatza...@gmail.com on 24 Jan 2012 at 4:40

@GoogleCodeExporter
Copy link
Author

I agree. :-)

I think the first step is to switch the code to use the new sensor API instead 
of using the raw sensor values. We should be able to get the roll, pitch, and 
yaw directly from the API. Then using the gyro should be much easier.

The filtering is a whole other issue. :-) We did a lot of experiments back in 
the day and tried multiple filters. The filter we are currently using was the 
best at the time, but I think its a bit too jittery on modern devices. I'm 
pretty sure that I can dig up the other filtering code to try again. It was way 
less jittery, but a lot slower. The right answer might be to add a setting 
somewhere where the user can adjust the sensitivity. I don't want to overwhelm 
the users, though.

Original comment by kevin.se...@gmail.com on 24 Jan 2012 at 12:34

@GoogleCodeExporter
Copy link
Author

There are kalman filters for Gyro+Accelerometer+Magnetometer as far as I know 
but..   somebody rather knowledgeable would be needed to get on board for this.

Memsense Kalman Filter (no source though)
http://www.memsense.com/index.php/Product-Pages/kalman-filter-library.html

Original comment by nkatza...@gmail.com on 24 Jan 2012 at 1:30

@GoogleCodeExporter
Copy link
Author

ICS already implements a Kalman Filter if an Gyro-Sensor is available. At least 
on the Nexus S. Just use Sensor.TYPE_ROTATION_VECTOR.

Original comment by wozniak....@gmail.com on 23 May 2012 at 4:02

@GoogleCodeExporter
Copy link
Author

Hey all, I'm learning android development and decided it would be fun to try to 
hack in gyroscope support to SkyMap. I decided to ultimately use the 
ROTATION_VECTOR sensor, which should implement a fused 
accelerometer/magnetometer/gyroscope on ICS and later (though I think it might 
be manufacturer-specific). Testing it on my samsung jellybean phone it works 
really well though, with a fast, smooth response.

There's a new option in preferences to switch between it and the original 
sensor, and it should fall back to the original sensors when ROTATION_VECTOR is 
not available (pre-gingerbread).

Patch is attached. You can download the debug-signed apk at 
http://nullidea.org/Stardroid-debug.apk (you'll have to uninstall the old 
SkyMap first) -- enjoy!

Original comment by penguin...@gmail.com on 6 May 2013 at 1:13

Attachments:

@GoogleCodeExporter
Copy link
Author

Ugh... except in my apk, all the stars and constellations are mislabeled. Is 
there something wrong with the published code?

Original comment by penguin...@gmail.com on 6 May 2013 at 6:54

@GoogleCodeExporter
Copy link
Author

Oh lol apparently the star database uses hard-coded offsets into the string 
resource or something. So when I added a new string it offset everything by 
one. Here's a new patch that puts the new string at the end so you don't have 
to re-compile the star binary files (which I haven't really figured out how to 
do). I also uploaded the fixed apk to the URL above.

Original comment by penguin...@gmail.com on 6 May 2013 at 7:19

Attachments:

@GoogleCodeExporter
Copy link
Author

Tested the patch on an older Huawei phone (2.3.X), after some testing it seems 
to marginally improve things. Much more important though is to set sensor speed 
to fast.

On a moto-g the "fused" option is unavailable.

Original comment by rdzid...@gmail.com on 12 Jan 2014 at 11:40

@barbeau
Copy link
Contributor

barbeau commented Jun 18, 2015

FWIW, here's what I consider to be a fairly solid implementation of the ROTATION_VECTOR sensor licensed under Apache 2.0 - full disclosure, I implemented it.

The onSensorChanged() method:
https://github.com/barbeau/gpstest/blob/master/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java#L561

Here's the initial setup in onResume():
https://github.com/barbeau/gpstest/blob/master/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java#L229

...and teardown in onPause():
https://github.com/barbeau/gpstest/blob/master/GPSTest/src/main/java/com/android/gpstest/GpsTestActivity.java#L264

It supports:

  • Back to API level 8 (Froyo) - uses Sensor.TYPE_ORIENTATION on devices that don't support Sensor.TYPE_ROTATION_VECTOR
  • Orientation changes - remaps the coordinate system accordingly
  • Correction for magnetic north
  • A workaround for a Samsung-specific bug that causes a crash on certain Samsung devices (see Bug with getRotationMatrixFromVector() on certain devices barbeau/gpstest#39 for details)

@jaydeetay
Copy link
Member

Implemented in the latest version (1.9.0b).

thomassth pushed a commit to thomassth/stardroid-kotlin that referenced this issue Nov 21, 2021
thomassth pushed a commit to thomassth/stardroid-kotlin that referenced this issue Nov 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants