sky-map-team / stardroid

Sky Map (formerly Google Sky Map, open sourced in 2012)
https://play.google.com/store/apps/details?id=com.google.android.stardroid&hl=en
Apache License 2.0
922 stars 232 forks source link

Use Gyroscope when available #5

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
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 commented 9 years ago
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 commented 9 years ago
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 commented 9 years ago
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 commented 9 years ago
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 commented 9 years ago
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 commented 9 years ago
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 commented 9 years ago

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:

jaydeetay commented 8 years ago

Implemented in the latest version (1.9.0b).