13.07.2015 Views

An Integrated, Modular Simulation System for Education ... - Cal Poly

An Integrated, Modular Simulation System for Education ... - Cal Poly

An Integrated, Modular Simulation System for Education ... - Cal Poly

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

xDot=u*CTheta*CPsi+v*(SPhi*STheta*CPsi-CPhi*SPsi)+w*(CPhi*STheta*CPsi+SPhi*SPsi);yDot=u*CTheta*SPsi+v*(SPhi*STheta*SPsi+CPhi*CPsi)+w*(CPhi*STheta*SPsi-SPhi*CPsi);zDot= -u*STheta+v*SPhi*CTheta+w*CPhi*CTheta;Theta+=(3.0*ThetaDot-OldThetaDot)/2.0*dt; /***** Euler angle integration *****/Phi+=(3.0*PhiDot-OldPhiDot)/2.0*dt;Psi+=(3.0*PsiDot-OldPsiDot)/2.0*dt;xx+=(3.0*xDot-OldxDot)/2.0*dt; /***** position integration *****/yy+=(3.0*yDot-OldyDot)/2.0*dt;zz+=(3.0*zDot-OldzDot)/2.0*dt;OlduDot=uDot; /***** Update the derivatives <strong>for</strong> the integrations *****/OldvDot=vDot;OldwDot=wDot;OldpDot=pDot;OldqDot=qDot;OldrDot=rDot;OldThetaDot=ThetaDot;OldPhiDot=PhiDot;OldPsiDot=PsiDot;OldxDot=xDot;OldyDot=yDot;OldzDot=zDot;/* handle bounds checking on roll and yaw at 180 or -180 */if (Phi > pi)Phi = -pi + (Phi - pi);else if (Phi < -pi)Phi = pi + (Phi - -pi);if (Psi > pi)Psi = -pi + (Psi - pi);else if (Psi < -pi)Psi = pi + (Psi - -pi);}/* handle special case when aircraft pitch passes the vertical */if ((Theta > HalfPi) || (Theta < -HalfPi)){if (Phi >= 0)Phi -= pi;else if (Phi < 0)Phi += pi;if (Psi >= 0)Psi -= pi;else if (Psi < 0)Psi += pi;if (Theta > 0)Theta = (pi - Theta);else if (Theta < 0)Theta = (-pi - Theta);}void Wind2Body(float FxWind, float FyWind, float FzWind, double AirSpeed){float vSquared, AlphaSpeed, combo;150

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!