attitude, banking, roll

Post Reply
box1737
Posts: 4
Joined: Tue Jul 08, 2008 10:10 am

attitude, banking, roll

Post 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
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: attitude, banking, roll

Post 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);
}

box1737
Posts: 4
Joined: Tue Jul 08, 2008 10:10 am

Re: attitude, banking, roll

Post by box1737 »

Thanks! That function gave me the rotation data I needed.
Queeny
Posts: 26
Joined: Tue Jun 03, 2008 10:06 am

Re: attitude, banking, roll

Post by Queeny »

I am trying to get pitch roll and yaw values?
Is heading=pitch, attitude=roll and bank=yaw?
VincentG
Posts: 7728
Joined: Mon Jul 17, 2006 5:00 am
Location: Corvallis, Oregon

Re: attitude, banking, roll

Post by VincentG »

I believe it is -----

Yaw - Heading
Pitch - Attitude
Roll - Bank
Queeny
Posts: 26
Joined: Tue Jun 03, 2008 10:06 am

Re: attitude, banking, roll

Post by Queeny »

I just want to make sure: are you talking about the parameters of the RB_GetRigidBodyLocation (...) call in the RB API?
beckdo
Posts: 520
Joined: Tue Jan 02, 2007 2:02 pm

Re: attitude, banking, roll

Post by beckdo »

yes
Queeny
Posts: 26
Joined: Tue Jun 03, 2008 10:06 am

Re: attitude, banking, roll

Post by Queeny »

thanks
Post Reply