0 Members and 1 Guest are viewing this topic.
Data.dAltitude =GetAltitude(); Data.dAOA =GetAOA(); if (iAOAautoON>0) { if (Data.dAltitude<150000) { if (Data.dAOA { SetThrusterGroupLevel(THGROUP_ATT_UP, 1); SetThrusterGroupLevel(THGROUP_ATT_DOWN, 0); } if (Data.dAOA>PI) { SetThrusterGroupLevel(THGROUP_ATT_DOWN, 1); SetThrusterGroupLevel(THGROUP_ATT_UP, 0); } if (Data.dAOA=PI) { SetThrusterGroupLevel(THGROUP_ATT_DOWN, 0); SetThrusterGroupLevel(THGROUP_ATT_UP, 0); } } }
if(key==OAPI_KEY_G){ iAOAautoON=1;}
function setpitch (v,p0,tmax,tol,pitch_func) if pitch_func == nil then pitch_func=v.get_pitch end local t0 = oapi.get_simtime() if tmax == nil then tmax=t0+100 else tmax=t0+tmax end if tol == nil then tol = 1e-3 end if verbose ~= nil then term.out(' setpitch initiated ('..p0*DEG..'deg, tmax='..tmax-t0..', tol='..tol..')') end repeat av = v:get_angvel() -- angular velocity p = pitch_func(v) -- current pitch value vp = av.x -- pitch velocity (damping term) dp = p0-p -- angle difference if dp > PI then dp = dp - 2*PI elseif dp < -PI then dp = dp + 2*PI end if math.abs(v:get_bank()) > PI05 then dp=-dp end // reverse direction if banked more than 90 deg rcs = dp*pitch_a - vp*pitch_b res_dp = math.abs(dp) -- angle residual res_vp = math.abs(vp) -- velocity residual res = math.max(res_dp,res_vp) if rcs > 1 then rcs = 1 elseif rcs < -1 then rcs = -1 end if res < 1e-3 then rcs = rcs*0.1 end if res < 1e-4 then rcs = rcs*0.1 end // close to minimum, slow down for higher accuracy SetRCS(v, RCSMODE.PITCH, rcs) if (res_dp > tol or res_vp > tol) and oapi.get_simtime() < tmax then proc.skip() end until res_dp < tol and res_vp < tol or oapi.get_simtime() > tmax SetRCS(v, RCSMODE.PITCH, 0) if verbose ~= nil then dt = oapi.get_simtime()-t0 if dt > tmax-t0 then term.out(' setpitch timed out (t='..string.format('%0.2f',dt)..')') else term.out(' setpitch converged (t='..string.format('%0.2f',dt)..')') end term.out(' residuals: angle='..string.format('%0.6g',dp)..', vel='..string.format('%0.6g',vp)) endend
Data.dAltitude =GetAltitude(); if (iAOAautoON>0) { if (Data.dAltitude<45000) { if (Data.dAltitude>12000){ double dAOA = GetAOA(); double dReqAOA = PI; //AOA de 180° (nez de la capsule en arrière) VECTOR3 Angle={0}; GetAngularVel(Angle); Angle.x=min(0.02,max(-0.02,(dReqAOA-dAOA))); SetAngularVel(Angle); } if (Data.dAltitude<12000){ double dPitch = GetPitch(); double dReqPitch = 0.5*PI; //pitch de 90° (nez de la capsule en haut) VECTOR3 Angle1={0}; GetAngularVel(Angle1); Angle1.x=min(0.02,max(-0.02,(dReqPitch-dPitch))); SetAngularVel(Angle1); } } }
Angle.x=min(0.02,max(-0.02,(dReqAOA-dAOA)));
currentAOA = GetAOA(); currentAOAdeg = 180*currentAOA/PI; double dReqAOA=160; if (iAOAautoON>0) { if (Data.dAltitude>0) { if (Data.dAltitude<20000) { VECTOR3 Angle={0}; GetAngularVel(Angle); Angle.x=min(0.05,max(-0.05,(dReqAOA-currentAOAdeg))); SetAngularVel(Angle); } } }
Déjà il y a la facilité du fait que l'AoA passe d'un pitch de ~0° à 90°, à cause de l'aérodynamique de la capsule. Donc facilité sur ce point.
void CoeffFunc (double aoa, double M, double Re, double *cl, double *cm, double *cd){ const int nlift = 11; double factor,dfact,lfact,frac,drag,lift; static const double AOA[nlift] = {-180.*RAD,-150*RAD,-120*RAD,-110*RAD,-90*RAD,-70*RAD,-60*RAD,-30*RAD,0*RAD,90*RAD,180.*RAD}; static const double CL[nlift] = {0.0,0.0,0.0,0.9,1.1,0.5,0.0,-0.5,-1.1,-0.9,0.0}; static const double CM[nlift] = {-0.015,-0.012,-0.006,-0.004,0.0,0.004,0.006,0.012,0.015,0.,-0.015}; static const double CD[nlift] = {0.8,0.8,1.0,1.0,1.143,1.0,1.0,0.8,0.8,0.8,0.8}; static const double Mach[17] = {0.0,0.7,0.9,1.1,1.2,1.35,1.65,2.0,3.0,5.0,8.0,10.5,13.5,18.2,21.5,31.0,50.0}; static const double LFactor[17] = {0.3,0.392,0.466,0.607,0.641,0.488,0.446,0.435,0.416,0.415,0.405,0.400,0.385,0.385,0.375,0.35,0.33}; static const double DFactor[17] = {0.9,0.944,0.991,1.068,1.044,1.270,1.28,1.267,1.213,1.134,1.15,1.158,1.8,1.8,1.193,1.224,1.25}; int j; factor = 100; dfact = 0.9; lfact = 1.0; for(j = 0; (j < 16) && (Mach[j+1] < M); j++); frac = (M-Mach[j])/(Mach[j+1]-Mach[j]); drag = dfact*(frac*DFactor[j+1]+(1.0-frac)*DFactor[j]); lift = drag * lfact*(frac*LFactor[j+1]+(1.0-frac)*LFactor[j]); for(j = 0; (j < nlift-1) && (AOA[j+1] < aoa); j++); frac = (aoa-AOA[j])/(AOA[j+1]-AOA[j]); *cd = drag*(frac*CD[j+1]+(1.0-frac)*CD[j]); *cl = lift*(frac*CL[j+1]+(1.0-frac)*CL[j]); *cm = factor*(frac*CM[j+1]+(1.0-frac)*CM[j]);}