helios icon indicating copy to clipboard operation
helios copied to clipboard

Inconsistency in quaternion to roll, pitch, yaw conversion and vice versa in InterpolatedMovingPlatform

Open zoltantorok opened this issue 9 months ago • 6 comments

The problem I noticed that roll and pitch angles are swapped in the trajectory output compared to the trajectory input converted by using RotationSpec::ARINC_705 in InterpolatedMovingPlatform::InterpolatedMovingPlatform

How to reproduce Add the following log lines to InterpolatedMovingPlatform::InterpolatedMovingPlatform() and use an interpolated trajectory.

        case InterpolationScope::POSITION_AND_ATTITUDE:
            doStepUpdates = [&] (double const t) -> void{
                arma::Col<double> const x = tf->eval(t); //roll,pitch,yaw,x,y,z

                auto q = calcAttitude(x);
                double r, p, y;
                _getRollPitchYaw(r, p, y, q);
                stringstream ss;
                ss << "t = " << t << "\nroll, pitch, yaw = " << x[0] * 180 / M_PI << ", " << x[1] * 180 / M_PI << ", " << x[2] * 180 / M_PI << "\n" <<
                    "q = " << q << "\n" <<
                    "roll, pitch, yaw = " << r * 180 / M_PI << ", " << p * 180 / M_PI << ", " << y * 180 / M_PI;
                logging::INFO(ss.str());


                setPosition(glm::dvec3(x[3], x[4], x[5]));
                setAttitude(calcAttitude(x));
            };

This produces the following log lines in my case: roll, pitch, yaw = -0.551372, -4.36025, 91.3625 q = [0.698005, 0.0300172, -0.0238576, 0.715066] roll, pitch, yaw = -4.36025, -0.551372, 91.3625

If necessary, provide simulation XML files, XML code snippets or pyhelios code snippets. I assume that the bug can be reproduced using any configuration. Just make sure to use an external trajectory.

Your environment (please complete the following information):

  • OS: Windows 11
  • HELIOS++/pyhelios version (or Git revision) that exhibits the issue 1.3.0

Ideas for possible solutions (Optional) It seems that the roll, pitch, yaw angle conversion to quaternion using RotationSpec::ARINC_705 is incosistent with the quaternion to Euler ZYX conversion.

zoltantorok avatar May 31 '24 13:05 zoltantorok