SagaPDev / Godot-SDL-Gyro

Add Gamepad Gyro Funtionality to Godot
MIT License
22 stars 2 forks source link

Calabrating has a tendancy to drift #13

Open TheGlobalGuest opened 1 month ago

TheGlobalGuest commented 1 month ago

when I was testing the Gyro controls an tried to impliment calabrating i noticed a slight drift would acour nomater how still you where...

before calibrating: no drifting at all. i could place the dualshock down and it wouldn't drift

calbrate 1: held dualshock straigth drifts slowly

calbrate 2: rotate dualshock constant spin in the rotating direction

calbrate 3: placed the dualshock on the floor ever so slightly drifts

calbrate 4: violent shook the dualshock rapid spinning

https://github.com/user-attachments/assets/67184a24-fc54-41a7-91c4-072dcb1e1b71

i origaly thought this was because of my dualshock until i noticed there was no drift when i didn't calibrate.

SagaPDev commented 1 month ago

Keep in mind the controller must be not moving and on an even surface before you start the calibration process do not move the device during this process, and only handle de device again after you stop de process the longer the time you give it to calibrate the more accurate the readings

TheGlobalGuest commented 1 month ago

I left it calibrating for 2 minuets and untouched. There still was some slight drift after...

i know this sound nit-picky but over time drift can distort the player's sence of the gyro controls.

https://github.com/user-attachments/assets/f1264309-26cc-4ec7-8449-0a7bba5c3984

SagaPDev commented 1 month ago

https://github.com/user-attachments/assets/4a958f5f-0a74-416b-9e76-b8ce2602825c

unfortunately i cannot reproduce, as you can see some drift is present at the beginning when opening the project, but after 3 sec calibration the drift goes away, i can see you have significant drift after the calibration, does it behave the same in my example project?

TheGlobalGuest commented 1 month ago

I tested your project and the drifting still ocourred. But its harder to tell because of the model.

i've also tried another dualshock and got similar results

https://github.com/user-attachments/assets/d2f5c08f-ab27-4e85-addc-8ad92cbf0c2b

TheGlobalGuest commented 1 month ago

I've noticed that the controls in general have tendncy to drift...

In the vid I left the controler to the side and haven't touched it in the whole project run time (until the end) and there still is a slight viable drift.

I have DS4windows mouse gyro controls enabled and yet I can leave the controler to the side witout the mouse drifting at all. so i don't think the drifting is an issue because of the dualshock i have

https://github.com/user-attachments/assets/a8d4cea4-7c05-455b-acd2-ccfc709b9029

also in the vid you shown there still is a slight drift like i'm currently suffering through (is visible because of the pixels changing)

SagaPDev commented 1 month ago

Maybe some manual dampening is needed, 3d-controller-overlay slowly recenter the 3d model overtime when the controller is quiet

In the motion helpers library there is an auto calibration function but i haven't managed to get it to work

Also the DualShock 3, does not have enough sensors to work with this library

TheGlobalGuest commented 1 month ago

any updates?

SagaPDev commented 1 month ago

i sat down today to figure this out

SagaPDev commented 1 month ago

@TheGlobalGuest addons.zip ok this is a newer build of the addon in which i binded the autocalibration function of gamepadMotionHelpers

you can call Gyro.set_auto_calibration() on your ready() function to enable auto calibration, if the controll is steady it will start calibrating automatically this has the added benefit of making the values remain steady under minimum movement

even with the auto calibration enabled you can trigger a manual calibration as always

test and let me know if it works for you

TheGlobalGuest commented 1 month ago

Tried it and it nolonger drifts now!

https://github.com/user-attachments/assets/452fdbff-bb4b-4c93-a5dc-f2b2b1df7e68

Gyro.Calibrate() still tends to drift until auto_calibrate kicks in, this ends up leaving the orentation slightly slanted.

https://github.com/user-attachments/assets/a328a58e-a02c-412c-976a-bd69b306ffdf

SagaPDev commented 1 month ago

Great 👍 And yes, it drifts a little before the calibration kicks in, I think we can take note of similar games where it asks the player to calibrate their control prior to passing the values to the 3D model

I will be enabling more functions to facilitate this and make it more seamless

TheGlobalGuest commented 1 month ago

I've actualy made my own calibration system and it works with no drift! it isn't what I would call "elegent" script wise but it definitely works.

in a nutshell: It applies an offest to the final rotation(A). this rotation(A) counteracts the gyrocontrols and only stops counteracting when calibrating stops.

this makes also makes it so i can orient my controler in any way and still have it work fine!

https://github.com/user-attachments/assets/14f3fff7-a406-419e-8bde-1e1efcdb4ca0

SagaPDev commented 1 month ago

Most elegant solution are the ones that works for you and your project, i thinks is a similar approach to 3d-controller-overlay

By the way, i wanted to ask, are you using a Dualshock 4 right ? are you experiencing any troubles using/reading buttons in engine while the gyro is working? i have some a reports at #11 and any info is appreciated

TheGlobalGuest commented 1 month ago

dualshock 4 inputs work fine for me.

https://github.com/user-attachments/assets/a4dbc663-ca88-460e-acd9-38cb7f9ed0c7

compleatly different but rotating too fast tends to offset the rotation more than normal. but i feel like thats to be expected when working with gyrocontrols

https://github.com/user-attachments/assets/675cd67d-77e4-444e-b039-2630ff11b903

SagaPDev commented 3 weeks ago

compleatly different but rotating too fast tends to offset the rotation more than normal. but i feel like thats to be expected when working with gyrocontrols

Yeah it is normal when using motion for this kind of absolute orientation tracking, according to GamepadMotionHelpers: Sensor Fusion , magnetometers, like ones found on modern phones could be used to compensate and correct values but no modern controllers have them