Jump to content

jaxsin

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by jaxsin

  1. Thanks for the help. Just glad I got it worked out. Makes a little more sense to me now. Never easy for a novice.
  2. the error it doesn't say much. you can see it here http://imgur.com/FgPhB6M I am pretty sure I have tracked down the error to the until {} block of code at line 102. I just don't understand enough about kOS to figure out why it is happening. UPDATE: I figured it out, the error was being thrown by line 43. I wasn't getting the ship to steer correctly so when I started to debug the steering issues, I noticed the parameters where wrong. adjusting this fixes everything. A good nights sleep seemed to fix my problem.
  3. Ok, so after hours of looking at this code, I give up! I was trying to get the FAR-optimized code back in post #363??? in this thread up to date and sort of working. I figured I could try at least. The problem I am getting now is some sort of "cast from source to destination" error and Steve mentioned this was happening on the C# side. I can't find the problem, would appreciate if someone could look at this and see maybe what the problem is. Declare parameter ap,St,inc. // Apoapsis of orbit; stages of rocket; launch angle clearscreen. set Log to 2. // Line for mission log set Ic to 25. // Info-column (name; e.g "Inclination.:") set Ic2 to Ic+12. // Info-column (value; e.g "46°") set Il to 12. // 1. line of info-are set Mil to 2. // Line for mission-name set spl to 5. // Line for subprogram-name set stl to 8. // Line for subprogram-status print "Mission Log:" at (0,0). print "Mission:" at (26,0). print "Subprogram:" at (Ic-1,spl-1). print "Status:" at (Ic-1,stl-1). print "Info:" at (Ic-1,Il-2). print "Launcher" at (Ic,spl). print "Prelaunch" at (Ic,stl). print "Orbit alt.:" at (Ic,Il). print round(ap/1000,3) + " km" at (Ic2,Il). print "L. angle:" at (Ic,Il+2). print 90-inc + " deg" at (Ic2,Il+2). print "Stage:" at (Ic,Il+4). print St at (Ic2,Il+4). lock acc to maxthrust/mass. // acceleration of vehicle set v0 to 1800. // v0 & psi0 = at v0 your rocket will fly at angle psi0 set psi0 to 70. // ! measured from the vertical ! set twrmult to 1.5. // factor to cancel out increasing twr over time // 1 = twr stays constant, etc. set wtwr to 2.5. // limit on your twr set pitch to 90. set Inc to 90-Inc. lock steering to heading(pitch,inc,360-inc). lock surfspeed to velocity:surface:mag. lock twr to (body:radius^2*acc)/(body:mu). // twr of craft Sas off. print "Prelaunch" at (Ic,stl). print "Use SAS to launch ! " at (Ic,Il+10). wait until SAS. // use the SAS to launch print " " at (Ic,Il+10). sas off. if maxthrust = 0 {stage.} wait 1. set twr2 to twr. If twr > wtwr{set twr2 to wtwr.} set t to twr2/twr. lock throttle to t. print "Gravity Turn " at (Ic,stl). print round(Missiontime) + "s Takeoff" at (1,Log). set Log to Log+1. set twr2 to twr2*twrmult. // added multiplier to cancel out rising twr // Big script for gravity turn trajectory // (assumes no atmospheric drag and constant TWR) // formulas are from here: // https://globaljournals.org/GJSFR_Volume12/6-Computational-Algorithm-for-Gravity.pdf set z0 to tan(0.5*psi0). set c to v0/(z0^(twr2-1)+z0^(twr2+1)). set gt to list(). set n to 0. set n2 to 1. set nmax to sqrt(0.2*v0+28.25)-5.5. lock v to 5*n^2+55*n+10. lock v2 to 5*n2^2+55*n2+10. lock vm to c*zm^(twr2-1)*(1+zm^2). lock gt1 to gt#n. lock gt2 to gt#n2. set zmin to 0. set zm to 0.5. set zmax to 1. until round(vm,0) = v{ // algorythm to find the solution if vm>v {set zmax to zm.} if vm<v {set zmin to zm.} set zm to (zmin+zmax)/2. wait 0.001. } set gt:add to 90-2*arctan(zm). print "Iteration:" at (Ic,Il+6). until n = floor(nmax) or ap-apoapsis < ap/10{ set zmin to 0. set zm to 0.5. set zmax to 1. until round(vm,0) = v2{ // same algorythm if vm>v2 {set zmax to zm.} if vm<v2 {set zmin to zm.} set zm to (zmin+zmax)/2. wait 0.001. } set gt:add to 90-2*arctan(zm). until surfspeed > v or ap-apoapsis < ap/10 {wait 0.001.} // autostaging - uncomment(testing script failures) print n at (Ic2,Il+6). set m to (gt2 - gt1)/(v2-v). set o to gt1 - m * v. lock pitch to m * surfspeed + o. set n to n+1. set n2 to n2+1. } lock steering to prograde + r(0,0,(-1)*inc). lock throttle to 0.05/twr+(ap-apoapsis)/(1000*twr). // throttles down as you get closer to your wanted Ap // Still needs some polish //until apoapsis > (ap){ // run stage(1). // wait 0.001. //} lock throttle to (ap-apoapsis)/(500*twr). // also could get improved print " " at (Ic,Il+10). print "Coasting to Ap" at (Ic,stl). print round(Missiontime) + "s Coast start" at (1,Log). set Log to Log+1. set warp to 1. set atmh to body:atm:height. Until 0{ // until atmh < altitude somehow doesn't work //run stage(1). if altitude > atmh{break.} wait 0.001. } set warp to 0. //run clearinfo.
×
×
  • Create New...