Page 1 of 1

attitude, banking, roll

Posted: Tue Jul 08, 2008 10:19 am
by box1737
Hello,

I see in the Optitrack Rigid Body application real-time tracking data for heading, bank, and attitude. However, I do not see data fields for these values in the sRigidBodyData struct that is received by the sample listener. Are these values not streamed?

Thanks,
Brandon

Re: attitude, banking, roll

Posted: Tue Jul 08, 2008 3:21 pm
by beckdo
Here's a function that can do the conversion for you. Does this help?

Code: Select all


void GetEulers(float qx, float qy, float qz, float qw, float *angle1,float *angle2, float *angle3)
{
    float &heading = *angle1;
    float &attitude = *angle2;
    float &bank = *angle3;

	double test = qx*qy + qz*qw;
	if (test > 0.499) { // singularity at north pole
		heading = (float) 2.0f * atan2(qx,qw);
		attitude = 3.14159265f/2.0f;
		bank = 0;

        RadiansToDegrees(&heading);
        RadiansToDegrees(&attitude);
        RadiansToDegrees(&bank);
		return;
	}
	if (test < -0.499) { // singularity at south pole
		heading = (float) -2.0f * atan2(qx,qw);
		attitude = - 3.14159265f/2.0f;
		bank = 0;

        RadiansToDegrees(&heading);
        RadiansToDegrees(&attitude);
        RadiansToDegrees(&bank);
		return;
	}
    double sqx = qx*qx;
    double sqy = qy*qy;
    double sqz = qz*qz;
    heading = (float) atan2((double)2.0*qy*qw-2.0*qx*qz , (double)1 - 2.0*sqy - 2.0*sqz);
	attitude = (float)asin(2.0*test);
	bank = (float) atan2((double)2.0*qx*qw-2.0*qy*qz , (double)1.0 - 2.0*sqx - 2.0*sqz);

    RadiansToDegrees(&heading);
    RadiansToDegrees(&attitude);
    RadiansToDegrees(&bank);
}

void RadiansToDegrees(float *value)
{
    *value = (*value)*(180.0f/3.14159265f);
}


Re: attitude, banking, roll

Posted: Wed Jul 23, 2008 10:45 am
by box1737
Thanks! That function gave me the rotation data I needed.

Re: attitude, banking, roll

Posted: Tue Aug 19, 2008 8:53 am
by Queeny
I am trying to get pitch roll and yaw values?
Is heading=pitch, attitude=roll and bank=yaw?

Re: attitude, banking, roll

Posted: Tue Aug 19, 2008 10:08 am
by VincentG
I believe it is -----

Yaw - Heading
Pitch - Attitude
Roll - Bank

Re: attitude, banking, roll

Posted: Tue Aug 19, 2008 10:15 am
by Queeny
I just want to make sure: are you talking about the parameters of the RB_GetRigidBodyLocation (...) call in the RB API?

Re: attitude, banking, roll

Posted: Tue Aug 19, 2008 11:30 am
by beckdo
yes

Re: attitude, banking, roll

Posted: Tue Aug 19, 2008 11:42 am
by Queeny
thanks