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.

#define INIT_X ((real_T) mxGetPr(X_POS_PARAM)[0])#define INIT_Y ((real_T) mxGetPr(Y_POS_PARAM)[0])#define INIT_Z ((real_T) mxGetPr(Z_POS_PARAM)[0])#define INIT_PSI ((real_T) mxGetPr(PSI_ANGLE_PARAM)[0])#define INIT_THETA ((real_T) mxGetPr(THETA_ANGLE_PARAM)[0])#define INIT_PHI ((real_T) mxGetPr(PHI_ANGLE_PARAM)[0])/* States - not using the simstruct to save the states*/float X; /* Previous locations to update*/float YY;float Z;/* altitude */float Psi; /* euler yaw angle - RAD*/float Theta; /* euler angle */float Phi;/* euler angle */float OldThetaDot;float OldPhiDot;float OldPsiDot;float OldxDot;float OldyDot;float OldzDot;const float TwicePi = 3.1415927*2.0;const float Deg2Rad = 0.01745329;const float Rad2Deg = 57.2957795;/* Function: mdlInitializeSizes ===============================================* Abstract:* Setup sizes of the various vectors.*/static void mdlInitializeSizes(SimStruct *S){ssSetNumSFcnParams(S, NUM_PARAMS);if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {return; /* Parameter mismatch will be reported by Simulink */}ssSetNumContStates(S, 0);ssSetNumDiscStates(S, 0);if (!ssSetNumInputPorts(S, 1)) return;ssSetInputPortWidth(S, 0, 8);ssSetInputPortDirectFeedThrough(S, 0, 1);if (!ssSetNumOutputPorts(S,1)) return;ssSetOutputPortWidth(S, 0, 6);ssSetNumSampleTimes(S, 1);}/* Take care when specifying exception free code - see sfuntmpl.doc */ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);/* Function: mdlInitializeSampleTimes =========================================161

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

Saved successfully!

Ooh no, something went wrong!