AndersMalmgren / FreePIE

Programmable Input Emulator
644 stars 144 forks source link

Wrong yaw data (X axis drift) [SOLVED] #46

Closed Gpinchon closed 9 years ago

Gpinchon commented 9 years ago

Hi, I'm having an issue with FreePIE on Android, the yaw value seems to be going crazy. Everytime I move y head on the pitch axis (even slightly) the yaw value increases (or decreases) very fast, even if I stop moving my head. Gyroscope Explorer indicates that the X, Y and Z values are normal and stable, the only abnormal value I noticed was when activating "Fusion", the "FusedGyroscopeCalibratedSensor" seems to drift slowly on the X axis... So, perhaps the app should use the "uncalibrated" data... By the way, I'm using an HTC One with Custom Sense ROM and latest firmware so it's not a Gyroscope's driver issue.

AndersMalmgren commented 9 years ago

How does the phone behave in games that uses the IMU? IS it only the FreePIE having this issue?

Gpinchon commented 9 years ago

Well, I've been testing several apps, some are acting normal, some others are drifting, every apps must not be getting the same data, that's very strange... I've been looking on the Internet and drifting seems to be an issue with HTC One. Apparently, the accelerometer and the gyroscope are working properly, however the final orientation data drifts slowly, this must be a software issue from HTC (these guys can't make proper drivers...) So, I don't know if there is anything that could be done to fixe that perhaps adding the possibility to use Gyro+Accelerometer and ignore magnetic field (the only remaining orientation sensor I couldn't test)...

[EDIT] After doing some test, it's the Magnetic Sensor that is causing the drift, even after calibration (drawing an 8 in the air with the phone), I've been looking around and there are no solutions neither from HTC or the community, so, I guess I can't use FreePIE with my HTC One...

I've found this : https://github.com/SilunWang/Anti-noise-Compass/wiki It is quite interresting and could correct the drift... Even if I don't know if I am the only one getting drift or not, and the drifting doesn't seem to be FreePIE's fault...

Gpinchon commented 9 years ago

So, after searching why FreePIE randomly worked and suddenly started drifting, I've found out that the app was not closing properly. Because of that, if the app crashes for example, there will be two process interfering with each other, causing wrong data to be sent... For now the only workaround I've found is to kill the app every time you want to quit it. Just to make sur the instance does not duplicate itself.

The solution would be to do so (just an advice) The user hits back -> app asks if user wants to close, if yes, kill process. The user hits home -> put the app in background. Also, I think the Android app really needs to be protected from instance duplication. ;-)

AndersMalmgren commented 9 years ago

Never heard anyone having this problem :) which version are you using? The one from latest installer? We have a new version in the works that uses a service instead, try it here please

https://dl.dropboxusercontent.com/u/33026505/com.freepie.android.imu.apk

Gpinchon commented 9 years ago

Yes, I was using the latest from installer. Thanks, I'll test the new version, from what I saw in debug mod, there doesn't seem to be any drift. I'll try it a bit later with opentrack. ^_^

Perhaps the issue comes from HTC way of managing apps, if an app is reduced, the task manager can decide to "stop" it (however, it's not really stopped as the app is able to keep sending and receiving data) and if you hit the app shortcut it will simply launch a new instance. It can happen with Facebook for example. I am not sure how this state is called, it's somewhere between "killed" and "in background"

[EDIT] So, after trying, it still randomly drifts, I successfuly had it working for an hour or so, then it started randomly drifting, I've tried with several smartphones, from Samsung, Wiko and HTC and all of them start drifting at some point... However, I am not sure if the issue is coming from FreePIE or Opentrack, I've opened an issue about the same problem on Opentrack's Github but I still got no answer at the moment... I think the issue might be caused by the magnetic sensor being recalibrated by the head's movement, if it is the reason of the issue, then there is no solution, except perhaps finding a solution to avoid using magnetic sensor (aka compass).

Oh, and happy new year by the way ! ;-)

lansings commented 8 years ago

Hello, I have the same problem. I'm using an Xiaomi Mi4. In other apps, like android VR apps or TrinusVR/Riftcat everything is ok, but i cant use freepie (v 1.9.629, 1.8, 1.5) because X axis "works" like Gpinchon have described