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

Incorrect pitch and roll during head rotation #6

Open
pitboxx opened this issue Jan 2, 2023 · 9 comments
Open

Incorrect pitch and roll during head rotation #6

pitboxx opened this issue Jan 2, 2023 · 9 comments

Comments

@pitboxx
Copy link

pitboxx commented Jan 2, 2023

Hello and thanks for developing this driver!
Let me describe my problem.
I am using a homemade Arduino-based HMD device and I am faced with the problem of tracking head tilts to the right and left. The problem is incorrect display of head rotation during head rotation inside SteamVR Home (driver version 1.3 and SteamVR Version 1.24.7).
According to the results of the sketch, it looks good in symbolic form.
image
And translated into binary form
image
In SteamVR Home, while I'm standing in front of the screen, head tilts to the left and right are tracked correctly.
image
And the chin tilts also look correct
image
But if you turn your head to the right or left (yaw), and then tilt your head to the right (roll) looks like lowering your chin down (we have pitch instead of roll).
image
If you turn your head to the left, the same situation is observed. Tilting the head to the left becomes lowering the chin.
image
Turning the head back causes an inversion of the tilt of the head. For example, if the head is tilted to the right, the result is also a tilt, but only in the opposite direction.
image
It looks as if the coordinate system of head declaration does not rotate with HMD by yaw coordinate.
Please comment have you had any similar problems? And what could be the problem in your opinion?

@r57zone
Copy link
Owner

r57zone commented Jan 2, 2023

Hello, are you using MPU6050 sensor? or other?
It turns out you have the axises wrong? in the sketch, you can swap them, change the numbers 0 1 2 to others, for example, 0 2 1 and so on.

ypr[0] = TO_DEG(yaw);
ypr[1] = TO_DEG(pitch);
ypr[2] = TO_DEG(roll);

ypr[0] = TO_DEG(yaw);
ypr[2] = TO_DEG(pitch);
ypr[1] = TO_DEG(roll);
or etc

@pitboxx
Copy link
Author

pitboxx commented Jan 2, 2023

Thanks for the quick response. Yes, I have an MPU-9150 sensor. Yes, I know that the order of the axes can be changed. I have already adjusted the axes inside the sketch to get a normal head tilt. In the starting position (when I look at the STEAM screen in the first screenshot), the head tilts are tracked correctly. Problems arise only after turning the head to the sides by yawing (left or right).

@pitboxx
Copy link
Author

pitboxx commented Jan 2, 2023

Here is a piece of my sketch that is responsible for the output

#ifdef OUTPUT_READABLE_YAWPITCHROLL
           // display Euler angles in degrees
           mpu.dmpGetQuaternion(&q, fifoBuffer);
           mpu.dmpGetGravity(&gravity, &q);
           mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
           //Serial.print("ypr\t");
           ypr[0] = ypr[0] * 180/M_PI;
           //Serial.print(ypr[0]);
           //Serial.print("\t");
           ypr[1] = -ypr[1] * 180/M_PI;
           //Serial.print(ypr[1]);
           //Serial.print("\t");
           ypr[2] = -ypr[2] * 180/M_PI;            
           //Serial.println(ypr[2]);

           Serial.write((byte*) ypr, 12);
       #endif

@r57zone
Copy link
Owner

r57zone commented Jan 2, 2023

Maybe the sensor is on the wrong side? Perhaps the problem is this. You can try to rotate the sensor and reconfigure the axes for them.

@pitboxx
Copy link
Author

pitboxx commented Jan 3, 2023

I turned the sensor 90 degrees and replaced the pitch and roll axis with places and got the same result. The main problem is that when the head is rotated horizontally by 90 degrees, the pitch and roll axes coincide.
Here is a piece of my code

#ifdef OUTPUT_READABLE_YAWPITCHROLL
            // display Euler angles in degrees
            mpu.dmpGetQuaternion(&q, fifoBuffer);
            mpu.dmpGetGravity(&gravity, &q);
            mpu.dmpGetYawPitchRoll(ypr, &q, &gravity);
            //Serial.print("ypr\t");
            out_ypr[0] = ypr[0] * 180/M_PI;
            //Serial.print(out_ypr[0]);
            //Serial.print("\t");
            out_ypr[1] = -ypr[2] * 180/M_PI;
            //Serial.print(out_ypr[1]);
            //Serial.print("\t");
            out_ypr[2] = ypr[1] * 180/M_PI;            
            //Serial.println(out_ypr[2]);

            Serial.write((byte*) out_ypr, 12);
        #endif

I wonder if I'm the only one facing such a problem, or have there been some changes in SteamVR?
Could you check my scenario with your tracker and confirm that everything is working correctly for you?

@r57zone
Copy link
Owner

r57zone commented Jan 3, 2023

I don't have this problem with my GY 85 tracker

You can also try the OpenVR-OpenTrack driver, with the OpenTrack application and SteamVR Razer IMu

https://github.com/r57zone/OpenVR-OpenTrack
In OpenTrack, you need to select Input UDP 127.0.0.1 and remove the filter

https://github.com/r57zone/VR-tracking-apps/releases/download/1/Razor.IMU.SteamVR.zip

Maybe the axes will match.

@pitboxx
Copy link
Author

pitboxx commented Jan 10, 2023

I downloaded the driver code and tried to manipulate the tracker coordinates . The problem of incorrect roll value (when turning the head) was solved by moving the rotation around to the quaternion of the world relative to the tracker as shown in the picture.
image
Now, when turning 90 degrees to the right and left, the rol of the head looks as usual.
image
At the same time, moving on the numeric keypad also works correctly. The "8" key moves forward in the direction of view, and the "4" and "6" keys become the left and right step keys. I don't know how suitable this solution is for the GY-85 tracker, but I ordered one from Aliexpress and will be able to check it as soon as it is delivered.
It looks like the tracker's yaw rotation is considered zero relative to the world, but moving the yaw position tracking to the world quaternion normalized the situation.

@r57zone
Copy link
Owner

r57zone commented Jan 10, 2023

I will probably need to change the reading to a quaternion

@pitboxx pitboxx closed this as completed Jan 10, 2023
@pitboxx
Copy link
Author

pitboxx commented Oct 11, 2024

This is due to the gimbal lock for the pitch and roll axes. A solution to this problem is proposed in the pull-request

@pitboxx pitboxx reopened this Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants