r57zone / OpenVR-ArduinoHMD

OpenVR driver for Arduino DIY HMD / OpenVR самодельного Arduino шлема

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect pitch and roll during head rotation

pitboxx opened this issue · comments

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?

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

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).

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

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.

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?

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.

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.

I will probably need to change the reading to a quaternion