# How to create a realistic missile-vessel

#### Topper

Donator
Hi,

I am not an expert in aerodynamic.
i wan't to create a vessel for my missile add on witch can be fly stable with speeds near 1400 m/s near see level. At this time my vessel begin to shake around at speeds more than 1000m/s.
My question is what respect by using "CreateAirfoil3" and inside the "VLiftCoeff" / "HLiftCoeff" function to get a "near realistic flight model"?
reg.
Topper

My modified vessel code from the shuttlePB (i know i have cheated a bit...):

Code:
// ==============================================================
//                 ORBITER MODULE: ShuttlePB
//                  Part of the ORBITER SDK
//          Copyright (C) 2002-2004 Martin Schweiger
//
// ShuttlePB.cpp
// Control module for ShuttlePB vessel class
//
// Notes:
// This is an example for a "minimal" vessel implementation which
// only overloads the clbkSetClassCaps method to define vessel
// capabilities and otherwise uses the default VESSEL class
// behaviour.
// ==============================================================

//#define STRICT
#include "AAMissile.h"
#define ORBITER_MODULE

// ==============================================================
// Some vessel parameters
// ==============================================================
const double PB_FUELMASS = 125.0;
const double PB_ISP = 980;
const double PB_MAXMAINTH = 2.0e4;
//const double PB_MAXHOVERTH = 1.5e4;
const double PB_MAXRCSTH = 50;

// Calculate lift coefficient [Cl] as a function of aoa (angle of attack) over -Pi ... Pi
// Implemented here as a piecewise linear function

void VLiftCoeff (VESSEL *v, double aoa, double M, double Re, void *context, double *cl, double *cm, double *cd)
{
int i;
const int nabsc = 9;
static const double CL[nabsc]  = {       0,      0,   -0.4,      0,    0.04,     1,   0.8,     0,      0};
static const double CM[nabsc]  = {       0,      0,  0.014, 0.0039, -0.006,-0.008,-0.010,     0,      0};
for (i = 0; i < nabsc-1 && AOA[i+1] < aoa; i++);
double f = (aoa-AOA[i]) / (AOA[i+1]-AOA[i]);
*cl = CL[i] + (CL[i+1]-CL[i]) * f;  // aoa-dependent lift coefficient
*cm = CM[i] + (CM[i+1]-CM[i]) * f;  // aoa-dependent moment coefficient
double saoa = sin(aoa);
double pd = 0.001 + 0.01*saoa*saoa;  // profile drag
*cd = pd + (oapiGetInducedDrag (*cl, 1.1, 0.9) + oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04))/30;
// profile drag + (lift-)induced drag + transonic/supersonic wave (compressibility) drag
}
// 2. horizontal lift component (vertical stabilisers and body)

void HLiftCoeff (VESSEL *v, double beta, double M, double Re, void *context, double *cl, double *cm, double *cd)
{
int i;
const int nabsc = 8;
static const double CL[nabsc]   = {       0,    +0.3,      0,   -0.3,  +0.3,     0,   -0.3,      0};
for (i = 0; i < nabsc-1 && BETA[i+1] < beta; i++);
*cl = CL[i] + (CL[i+1]-CL[i]) * (beta-BETA[i]) / (BETA[i+1]-BETA[i]);
*cm = 0.0;
*cd =  0.001 + (oapiGetInducedDrag (*cl, 1.1, 0.9) + oapiGetWaveDrag (M, 0.75, 1.0, 1.1, 0.04))/30;
}

// ==============================================================
// Shuttle-PB class interface
// ==============================================================

// ==============================================================
// ==============================================================

// --------------------------------------------------------------
// Set the capabilities of the vessel class
// --------------------------------------------------------------

void AIM120::clbkSetClassCaps (FILEHANDLE cfg)
{

anim_x = CreateAnimation (0);

THRUSTER_HANDLE th_main;
SetSize (10);
SetEmptyMass (35.0);
//make wings
CreateAirfoil3 (LIFT_VERTICAL, _V(0,0,-2.8), VLiftCoeff, 0, 1, 2.6, 1.2);
//CreateAirfoil3 (LIFT_VERTICAL, _V(0,0, 4), VLiftCoeff, 0, 1, 0.5, 1.6);
// wing and body lift+drag components

CreateAirfoil3 (LIFT_HORIZONTAL, _V(0,0,-2.8), HLiftCoeff, 0, 1, 2.6, 1.2);
//CreateAirfoil3 (LIFT_HORIZONTAL, _V(0,0, 4), HLiftCoeff, 0, 1, 0.5, 1.6);
// vertical stabiliser and body lift and drag components

CreateControlSurface (AIRCTRL_ELEVATOR,     0.4, 2.5, _V(   0,0,-7.2), AIRCTRL_AXIS_XPOS, anim_x);
CreateControlSurface (AIRCTRL_RUDDER,       0.4, 2.5, _V(   0,0,-7.2), AIRCTRL_AXIS_YPOS, anim_x);
CreateControlSurface2 (AIRCTRL_AILERON,        0.4, 2.5, _V( 7.5,0,-7.2), AIRCTRL_AXIS_XPOS, anim_x);
CreateControlSurface2 (AIRCTRL_AILERON,        0.4, 2.5, _V(-7.5,0,-7.2), AIRCTRL_AXIS_XNEG, anim_x);
CreateControlSurface (AIRCTRL_ELEVATORTRIM, 0.4, 2.5, _V(   0,0,-7.2), AIRCTRL_AXIS_XPOS, anim_x);

PROPELLANT_HANDLE hpr = CreatePropellantResource (PB_FUELMASS);

th_main = CreateThruster (_V(0,0,-4.35), _V(0,0,1), PB_MAXMAINTH, hpr, PB_ISP);
CreateThrusterGroup (&th_main, 1, THGROUP_MAIN);

// visual specs
/*
PARTICLESTREAMSPEC contrail_main = {
0, 5.0, 16, 200, 0.15, 1.0, 5, 3.0, PARTICLESTREAMSPEC::DIFFUSE,
PARTICLESTREAMSPEC::LVL_PSQRT, 0, 2,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-4, 1
};

PARTICLESTREAMSPEC exhaust_main = {
0, 2.0, 20, 200, 0.05, 0.1, 8, 1.0, PARTICLESTREAMSPEC::EMISSIVE,
PARTICLESTREAMSPEC::LVL_SQRT, 0, 1,
PARTICLESTREAMSPEC::ATM_PLOG, 1e-5, 0.1
};
*/
AddExhaust (th_main, 5, 0.25, _V(0,0,-1.82), _V(0,0,-1));

//SetTouchdownPoints (_V(0,-1.5,-2.6), _V(-0.2,1.5,-2.6), _V(0.2,0,-1.6));
//AG : SetTouchdownPoints (_V(0,-3.5,2), _V(-1,-1.0,-1.5), _V(1,-1.0,-1.5));
SetTouchdownPoints (_V(0,-1,2), _V(-1,-1.0,-1.5), _V(1,-1.0,-1.5));

SetReentryTexture(NULL);
}

// ==============================================================
// API callback interface
// ==============================================================

// --------------------------------------------------------------
// Vessel initialisation
// --------------------------------------------------------------

DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
return new AIM120 (hvessel, flightmodel);
}

// --------------------------------------------------------------
// Vessel cleanup
// --------------------------------------------------------------
DLLCLBK void ovcExit (VESSEL *vessel)
{
if (vessel) delete (AIM120*)vessel;
}

void AIM120::clbkDrawHUD (int mode, const HUDPAINTSPEC *hps, HDC hDC)
{
// draw the default HUD
VESSEL2::clbkDrawHUD (mode, hps, hDC);

int cx = hps->CX;
int cy = hps->CY;
int CenterX = cx;
int CenterY = cy;
Ellipse (hDC,
}

double AIM120::GetVesselDistance2(OBJHANDLE hVesselFrom, VESSEL* VesselTo)
{
VECTOR3 v3;
VesselTo->GetRelativePos(hVesselFrom,v3);
double TotalDistance = sqrt((v3.x * v3.x) + (v3.y * v3.y) + (v3.z * v3.z));
}

void AIM120::clbkPostStep (double simt, double simdt, double mjd)
{
//walpha.wMain();
}

#### Urwumpe

##### Not funny anymore
Donator
The instability comes when you have very strong gradients in the lift function. Make the lift function a bit less extreme and demand higher AOAs for maximum L/D.

#### mikey451

And the moment function...

#### sts-107

##### Donator
Donator
Hi Topper,

I hope those pages will assist you http://www.megaupload.com/?d=RN5L847V
As well any plans in future to implement TVC steering methods (for high altitudes)?

Best regards,
Alex.

SDK Question moveing cockpit camera
Replies
3
Views
482
Replies
1
Views
449
Replies
1
Views
602
Replies
5
Views
804
Replies
1
Views
697