FORUMS
Remove All Ads from XDA

[XPOSED] VirtualSensor - Emulate a gyroscope from the accelerometer and compass

101 posts
Thanks Meter: 202
 
Post Reply Email Thread
Introduction

VirtualSensor is a module built on Xposed that creates several sensors on devices which do not have them. It does sensor fusion using the values from the accelerometer and the compass which are the two main requirements for this module.

There are currently 5 sensors emulated :
TYPE_ROTATION_VECTOR
TYPE_GYROSCOPE
TYPE_GEOMAGNETIC_ROTATION_VECTOR
TYPE_GRAVITY
TYPE_LINEAR_ACCELERATION
Being the most useful sensor for many applications, the gyroscope is the main sensor this project is about.

This module is born as an answer to personal frustration from not being able to use some applications after updating from my older Moto G (i.e. Photo Sphere) and later also as an answer to this thread.

Changelog
Code:
v1.5.1 - 02/08/2017:
This minor version fixes the module for Nougat devices.
See the changelog of v1.5.1 for the more information on what has changed for the major version 1.5.

v1.5 - 02/08/2017:
Finally a new release after (quite) a while. This release should fix the majority of bugs encountered on current and previous versions of Android.
With the precious help of people on Github, the cardboard hook has been (hopefully) improved.
The overall stability and reliability should be better now.
This release will stay marked as beta until relevant and good feedback is received, to please head over to Github if you can and report issues if any (or add to the exising issues to check wether they still exist)

v1.41 - 01/08/2016:
* Fixed the module, previous version broke it because of proguard minify, do not use version v1.4

v1.4 - 31/07/2016: /!\ This version is broken, avoid it /!\
* Added a check for already existing native sensors so that they don't get overridden by the module
* Now checks the values of the accelerometer and magnetic sensor against their accuracy. This means that the output values contain less noise without loosing too much precision
* Added a simple GUI to quickly get informations about the module. This part also calculates the values the gyroscope should return and compares them against the one the module actually returns
* Some hooks are now made on higher-level API (public available functions for apps), which means that specific device code should no longer break them
* Fixed a recurrent exception (ConcurrentModificationException)

v1.32 - 29/07/2016:
* Fix the mRequiredPermssion field no available on SDK < 20
Hotfix #2 for v1.3

v1.31 - 29/07/2016:
* Fixes the issue with SDK <= 18 where mStringType doesn't exist in the Sensor class
Hotfix for v1.3

v1.3 - 29/07/2016:
* Sensors are now added in a proper way. They should no longer accidentally override existing sensors / cause compatibility issues
* All gyroscope axes are fully functional !
* If it didn't work before for you on JellyBean-Lollipop, try now, it might (fixed the check for initialisation of SystemSensorManager)
* Started to work on a new filter system for the gyroscope mainly

v1.21 - 25/07/2016:
Hotfix for v1.2 to avoid crashes on JB devices.

v1.2 - 26/07/2016:
* Fixed compatibility with SDK18-22 (Android JellyBean 4.3 - Android Lolipop 5.1)
* Added a little more log
* Calculation for the gyroscope is now based on the calculated gravity sensor data, which (should) makes it work as intended in any orientation
* The virtual sensors now have a little more information in the created Sensor class, just to make sure this isn't an issue

v1.11 - 25/07/2016:
Hotfix for v1.1, fixes an exception raised in some cases when trying to get the accelerometer's min delay.

v1.1 - 25/07/2016: 
* Added support for all SDK versions from SDK16 to SDK23+, this means all android versions starting from Jelly Bean should be supported
* Added a lot of new sensors : TYPE_ROTATION_VECTOR, TYPE_GEOMAGNETIC_ROTATION_VECTOR, TYPE_GRAVITY and TYPE_LINEAR_ACCELERATION
* Still no support for Pokémon GO though, working on it
* Some exceptions fixed
* Code refactored a lot

v1.0 - 23/07/2016: 
Initial release.
Known issues
  • Right now, the Z-axis is not emulated as it always returned wrong values (Investigating this right now) Fixed
  • Some applications use the NDK instead of the SDK to access the sensors, the workaround is to hook them seperately, but that isn't done yet
  • There is some jitter even though the values are smoothed using a lowpass filter and averaged out

Disclaimer

Code:
Though it is unlikely this could happen given the modifications it does, the responsibility is yours for whatever happens after installing and using this module.
Download
Contributing

There is a Github project for this module so please do not hesitate to contribute to it. I'll be glad to share knowledge and code. Please know that I'm not (yet? ) a professional coder and that errors are quite likely to happen.

XDA:DevDB Information
VirtualSensor, Xposed for all devices (see above for details)

Contributors
Frazew
Source Code: https://github.com/Frazew/VirtualSensor

Xposed Package Name: fr.frazew.virtualgyroscope

Version Information
Status: Testing
Current Stable Version: v1.5.1
Stable Release Date: 2017-08-02

Created 2016-07-23
Last Updated 2017-08-02
The Following 67 Users Say Thank You to Frazew For This Useful Post: [ View ] Gift Frazew Ad-Free
23rd July 2016, 09:14 PM |#3  
Eskuero's Avatar
Recognized Developer
Thanks Meter: 2,286
 
More
I supposed you tested this with Pokemon GO, as is the reason of so many requests for a virtual gyroscope so I'll suppose is still nor working due my specific device.
Motorola Moto X Play, running CyanogenMod 13.
Thanks for your work!
The Following User Says Thank You to Eskuero For This Useful Post: [ View ]
23rd July 2016, 09:33 PM |#4  
Junior Member
Thanks Meter: 0
 
More
Thanks for chance to get normal VR experience
Works great with Lenovo Vibe P1 (this device has a jittering problem with its own pseudo-gyro). Tested with Youtube 360 videos. Works great for watching up/down and rotate. As well as you said z-axis is not working at all, so it's impossible to move point of view to the left/right. Can help you with testing on my device, if you want. I have Lenovo Vibe P1 with Android 6.0, TWRP and Root.
P.S. Is there any way to turn on z-axis for testing, for example by using your project at github. I'm not sure if I will understand there something, I was coding before only at C#, but I can try.
23rd July 2016, 09:34 PM |#5  
OP Senior Member
Thanks Meter: 202
 
More
Quote:
Originally Posted by OliverG96

I supposed you tested this with Pokemon GO, as is the reason of so many requests for a virtual gyroscope so I'll suppose is still nor working due my specific device.
Motorola Moto X Play, running CyanogenMod 13.
Thanks for your work!

I did not test it with Pokémon GO, however I think the hook will have to be made in the app itself. I'll look into it right now

EDIT: Pokémon GO uses the TYPE_ROTATION_VECTOR sensor. This sensor requires data from the gyroscope. I'm working right now on emulating it.
The Following 5 Users Say Thank You to Frazew For This Useful Post: [ View ] Gift Frazew Ad-Free
23rd July 2016, 09:37 PM |#6  
OP Senior Member
Thanks Meter: 202
 
More
Quote:
Originally Posted by Saratsin

Works great with Lenovo Vibe P1 (this device has a jittering problem with its own pseudo-gyro). Tested with Youtube 360 videos. Works great for watching up/down and rotate. As well as you said z-axis is not working at all, so it's impossible to move point of view to the left/right. Can help you with testing on my device, if you want. I have Lenovo Vibe P1 with Android 6.0, TWRP and Root.
P.S. Is there any way to turn on z-axis for testing, for example by using your project at github. I'm not sure if I will understand there something, I was coding before only at C#, but I can try.

Glad to see that it works ! I could make another build with the Z axis activated but I really need to look a bit more into it. The problem with it is that it seemed to return higher values than the other axes. This generally broke the calibration many apps do and though the z-axis worked, they would then ignore the small variations of the other axes.
In case you want to build it yourself, it's quite easy, just remove the multiplication by zero here : https://github.com/Frazew/VirtualSen...dMod.java#L156
The Following 2 Users Say Thank You to Frazew For This Useful Post: [ View ] Gift Frazew Ad-Free
23rd July 2016, 09:43 PM |#7  
Member
Thanks Meter: 5
 
More
Can't install it on Jelly bean 4.2.2 :/
23rd July 2016, 09:43 PM |#8  
kos25k's Avatar
Senior Member
Thanks Meter: 411
 
More
first a big THANKS!!!!!
I downloaded sensors tests app.before the module,gyroscope test wasn't there!after the module,voilla!!gyroscope test was there!I openned it and tested side by side with my xperia Z3 tablet.But values was muuuch different...It's ok,we all hope for possible future module updates!again THANK YOU!!!
23rd July 2016, 09:48 PM |#9  
OP Senior Member
Thanks Meter: 202
 
More
Quote:
Originally Posted by Dant3s

Can't install it on Jelly bean 4.2.2 :/

Right now the minimum SDK version is KitKat, that's just because the sensor methods are different on Jelly Bean and I haven't worked on it.
Now that there are people who can actually test it on Jelly Bean I'll make an update to add support for it
The Following 3 Users Say Thank You to Frazew For This Useful Post: [ View ] Gift Frazew Ad-Free
23rd July 2016, 10:10 PM |#10  
Member
Thanks Meter: 5
 
More
Quote:
Originally Posted by Frazew

Right now the minimum SDK version is KitKat, that's just because the sensor methods are different on Jelly Bean and I haven't worked on it.
Now that there are people who can actually test it on Jelly Bean I'll make an update to add support for it

Glad to hear that, thanks
23rd July 2016, 10:54 PM |#11  
Member
Thanks Meter: 34
 
More
have see this thread : Help module to simulate Gyroscope with Accelerometer and Compass by nicolobos77
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes