├── old ├── spec_char.ksm ├── example_lib_number_dialog.ks ├── example_lib_menu.ks ├── example_spec_char.ks ├── lib_realchute.ks ├── example_lib_list_dialog.ks ├── example_lib_num_to_str.ks ├── twr.ks ├── example_testsasmode.ks ├── example_lib_raw_user_input.ks ├── example_lib_navball.ks ├── example_lib_exec.ks ├── SC1.ks ├── lib_navball.ks ├── utilities.ks ├── lib_num_to_str.ks ├── lib_raw_user_input.ks ├── circularize.ks ├── lib_number_dialog.ks ├── launch_east.ks ├── lib_list_dialog.ks ├── lib_menu.ks ├── lib_term.ks ├── lib_circle_nav.ks ├── tune.ks ├── example_lib_lazcalc.ks ├── spacecomputer.ks ├── example_lib_pid.ks ├── lib_exec.ks ├── plane_tools.ks ├── master_hard.ks ├── spiral_out.ks ├── example_lib_term_clock.ks ├── lib_pid.ks ├── ltoa.ks ├── lib_lazcalc.ks ├── ascent.ks ├── throttle_log_0_0001.ks ├── throttle_log_1_0.ks ├── launchcurve.ks ├── throttle_log_0_1.ks ├── a1.ks ├── throttle_log_0_001.ks └── throttle_log_0_01.ks ├── patch.kOS Dev MK2.ks ├── upload.patch.kOS Dev MKI-A 1.ks ├── keostationary.ks ├── intercept.ks ├── .gitattributes ├── boot.keostationary.ks ├── boot.utilities.ks ├── boot.toorbit.ks ├── patch.kOS Dev MKI-A.toorbit.ks ├── patch.KSS Starlight Crew Rotator 1.ks ├── boot.patch.ks ├── .gitignore ├── upload.patch.Eve Science Probe 1.ks ├── patch.Eve Science Probe 1.ks ├── circularize.ks ├── fileutility.ks ├── utility.ks ├── upload.patch.kOS Dev MKI-A.ks ├── patch.Eve Base 1.ks ├── orbit.ks ├── upload.patch.Minmus Jet 1.ks ├── orbitutility.ks ├── hohmann.ks ├── maneuver.ks └── ascent.ks /old/spec_char.ksm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hamaluik/kOS/master/old/spec_char.ksm -------------------------------------------------------------------------------- /patch.kOS Dev MK2.ks: -------------------------------------------------------------------------------- 1 | run fileutility. 2 | Download("orbit.ks"). 3 | run orbit(150, 90, 1). -------------------------------------------------------------------------------- /old/example_lib_number_dialog.ks: -------------------------------------------------------------------------------- 1 | run lib_number_dialog. 2 | 3 | set number to open_number_dialog("Apoapsis:",100000). 4 | print "New apoapsis is: "+number. 5 | -------------------------------------------------------------------------------- /old/example_lib_menu.ks: -------------------------------------------------------------------------------- 1 | run lib_menu. 2 | 3 | set choice to open_menu("What is your choice?",list("This","is","an","example")). 4 | 5 | print "You have chosen "+choice. 6 | -------------------------------------------------------------------------------- /old/example_spec_char.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | 3 | run spec_char. 4 | print "this line contains quote: " + quote. 5 | print "two" + endl + "lines". 6 | -------------------------------------------------------------------------------- /upload.patch.kOS Dev MKI-A 1.ks: -------------------------------------------------------------------------------- 1 | //set dockingPortList to ship:modulesnamed("ModuleDockingNode"). 2 | //for dockingPort in dockingPortList { 3 | // print "Found a docking port: " + dockingPort:part:name. 4 | // print "It is facing: " + dockingPort:part:facing:vector. 5 | //} 6 | 7 | run utility. 8 | print MeanMotion(ship). -------------------------------------------------------------------------------- /old/lib_realchute.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | 3 | // adds support for RealChute 4 | @LAZYGLOBAL OFF. 5 | declare function R_chutes { 6 | parameter event. 7 | for RealChute in ship:modulesNamed("RealChuteModule") { 8 | RealChute:doevent(event). 9 | }. 10 | }. 11 | -------------------------------------------------------------------------------- /keostationary.ks: -------------------------------------------------------------------------------- 1 | parameter desiredLongitudeOffset. 2 | 3 | set targetAltitude to 2868741.33. 4 | set KSCLaunchPad to latlng(-0.0972092543643722, -74.557706433623). 5 | set desiredLongitude to KSCLaunchPad:lng + desiredLongitudeOffset. 6 | 7 | print "Executing Hohmann transfer...". 8 | run hohmann(desiredLongitude, targetAltitude). 9 | run maneuver(100). -------------------------------------------------------------------------------- /intercept.ks: -------------------------------------------------------------------------------- 1 | // transfer DVs 2 | // courtesy of https://en.wikipedia.org/wiki/Hohmann_transfer_orbit 3 | set r1 to ship:body:radius + ship:altitude. 4 | set r2 to target:body:radius + targetAltitude. 5 | set dv1 to sqrt(ship:body:mu / r1) * (sqrt((2 * r2) / (r1 + r2)) - 1). 6 | set dv2 to sqrt(ship:body:mu / r2) * (1 - sqrt((2 * r1) / (r1 + r2))). 7 | set transitTime to constant():PI * sqrt((r1 + r2)^3 / (8 * ship:body:mu)). -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /boot.keostationary.ks: -------------------------------------------------------------------------------- 1 | // chill out while we look for something to run 2 | set ship:control:pilotmainthrottle to 0. 3 | 4 | // utilities 5 | copy "fileutility.ks" from 0. 6 | run fileutility. 7 | 8 | Download("utility.ks"). 9 | Download("orbit.ks"). 10 | Download("ascent.ks"). 11 | Download("circularize.ks"). 12 | Download("maneuver.ks"). 13 | Download("hohmann.ks"). 14 | Download("keostationary.ks"). 15 | 16 | run orbit(100, 90, 0). 17 | run circularize("apoapsis"). 18 | run maneuver(0). -------------------------------------------------------------------------------- /boot.utilities.ks: -------------------------------------------------------------------------------- 1 | // general boot script 2 | // by Kenton Hamaluik 3 | // 2015-07-27 4 | // portions borrowed from https://github.com/gisikw/ksprogramming 5 | 6 | // chill out while we look for something to run 7 | set ship:control:pilotmainthrottle to 0. 8 | 9 | // utilities 10 | copy "fileutility.ks" from 0. 11 | run fileutility. 12 | 13 | Download("utility.ks"). 14 | Download("orbit.ks"). 15 | Download("ascent.ks"). 16 | Download("circularize.ks"). 17 | Download("maneuver.ks"). 18 | 19 | print "Utilities downloaded!". -------------------------------------------------------------------------------- /old/example_lib_list_dialog.ks: -------------------------------------------------------------------------------- 1 | run lib_list_dialog. 2 | set numbers to list("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"). 3 | set options to list(). 4 | for i in numbers { 5 | for j in numbers { 6 | options:add(i + j). 7 | } 8 | } 9 | print "your first choice is: " + options[open_list_dialog("choose an option:", options)]. 10 | wait 2. 11 | set choice to open_cancelable_list_dialog("choose an option:", options). 12 | if choice = -1 { 13 | print "you canceled the dialog". 14 | } else { 15 | print "your second choice is: " + options[choice]. 16 | } 17 | -------------------------------------------------------------------------------- /boot.toorbit.ks: -------------------------------------------------------------------------------- 1 | // chill out while we look for something to run 2 | set ship:control:pilotmainthrottle to 0. 3 | 4 | // utilities 5 | copy "fileutility.ks" from 0. 6 | run fileutility. 7 | 8 | Download("utility.ks"). 9 | Download("orbit.ks"). 10 | Download("ascent.ks"). 11 | Download("circularize.ks"). 12 | Download("maneuver.ks"). 13 | 14 | print "Utilities downloaded!". 15 | 16 | if(ship:status = "PRELAUNCH") { 17 | print "Prelaunch detected!". 18 | 19 | print "Launcing to orbit!". 20 | run orbit(100, 90, 0, 1.4). 21 | 22 | hudtext(ship:name + " is 5x5!", 1, 2, 50, green, true). 23 | } -------------------------------------------------------------------------------- /old/example_lib_num_to_str.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | 3 | run lib_num_to_str. 4 | local num is 0. 5 | clearscreen. 6 | 7 | Print " ". 8 | Print "+-----------------------+". 9 | print "| Compass = -180.00 deg |". 10 | print "+-----------------------+". 11 | print " ". 12 | print "Range is -180 to 180 to show the '-' indicator". 13 | print " ". 14 | Print "ag1 to exit.". 15 | 16 | set ag1 to false. 17 | 18 | until ag1 { 19 | set num to mod(-ship:bearing+180,360)-180. 20 | print num_to_str(num,3,2) at (12,2). 21 | }. 22 | 23 | set ag1 to false. 24 | -------------------------------------------------------------------------------- /patch.kOS Dev MKI-A.toorbit.ks: -------------------------------------------------------------------------------- 1 | set ship:control:pilotmainthrottle to 0. 2 | 3 | // utilities 4 | copy "fileutility.ks" from 0. 5 | run fileutility. 6 | 7 | Download("utility.ks"). 8 | Download("orbit.ks"). 9 | Download("ascent.ks"). 10 | Download("circularize.ks"). 11 | Download("maneuver.ks"). 12 | 13 | print "Utilities downloaded!". 14 | 15 | if(ship:status = "PRELAUNCH") { 16 | print "Prelaunch detected!". 17 | 18 | when ship:altitude > 70000 then { 19 | panels on. 20 | } 21 | 22 | print "Launching to orbit!". 23 | run orbit(100, 90, 0, 2). 24 | 25 | hudtext(ship:name + " is 5x5!", 1, 2, 50, green, true). 26 | hudtext("Ready for transfer burn!", 1, 2, 50, green, true). 27 | } -------------------------------------------------------------------------------- /old/twr.ks: -------------------------------------------------------------------------------- 1 | clearscreen. 2 | function calculateTWR { 3 | set i to 0. 4 | set totalThrust to v(0,0,0). 5 | 6 | list engines in engs. 7 | until i = engs:length { 8 | if engs[i]:ignition { 9 | set thrust to engs[i]:facing:vector:normalized * engs[i]:thrust. 10 | set totalThrust to totalThrust + thrust. 11 | }. 12 | set i to i + 1. 13 | } 14 | 15 | set gravity to -up:vector:normalized * (body:mu / body:position:mag^2). 16 | //set v_acc to vdot(up:vector, totalThrust)/mass - gravity:mag. 17 | set twr to (totalThrust:mag / mass) / gravity:mag. 18 | } 19 | 20 | until ship:altitude > 30000 { 21 | calculateTWR(). 22 | print "TWR: " + round(twr, 2) + " " at (0, 0). 23 | wait 0.001. 24 | } -------------------------------------------------------------------------------- /patch.KSS Starlight Crew Rotator 1.ks: -------------------------------------------------------------------------------- 1 | // general boot script 2 | // by Kenton Hamaluik 3 | // 2015-07-27 4 | // portions borrowed from https://github.com/gisikw/ksprogramming 5 | 6 | // chill out while we look for something to run 7 | set ship:control:pilotmainthrottle to 0. 8 | 9 | // utilities 10 | copy "fileutility.ks" from 0. 11 | run fileutility. 12 | 13 | Download("utility.ks"). 14 | Download("orbit.ks"). 15 | Download("ascent.ks"). 16 | Download("circularize.ks"). 17 | Download("maneuver.ks"). 18 | 19 | print "Utilities downloaded!". 20 | 21 | if(ship:status = "PRELAUNCH") { 22 | print "Prelaunch detected!". 23 | 24 | print "Launcing to orbit!". 25 | run orbit(80, 90, 1, 1.4). 26 | 27 | hudtext("Vessel Is 5x5!", 1, 2, 50, green, true). 28 | } -------------------------------------------------------------------------------- /boot.patch.ks: -------------------------------------------------------------------------------- 1 | // general boot script 2 | // by Kenton Hamaluik 3 | // 2015-07-27 4 | // portions borrowed from https://github.com/gisikw/ksprogramming 5 | 6 | // chill out while we look for something to run 7 | set ship:control:pilotmainthrottle to 0. 8 | 9 | // utilities 10 | copy "fileutility.ks" from 0. 11 | run fileutility. 12 | 13 | // download any new patches 14 | set patchScript TO "upload.patch." + ship:name + ".ks". 15 | 16 | if FileExists(patchScript, 0) { 17 | Download(patchScript). 18 | switch to 0. 19 | delete patchScript. 20 | switch to 1. 21 | if(FileExists("patch.ks", 1)) { 22 | delete "patch.ks". 23 | } 24 | rename patchScript to "patch.ks". 25 | print "Patch script found! Executing!". 26 | run patch. 27 | delete patch. 28 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /upload.patch.Eve Science Probe 1.ks: -------------------------------------------------------------------------------- 1 | // general boot script 2 | // by Kenton Hamaluik 3 | // 2015-07-27 4 | // portions borrowed from https://github.com/gisikw/ksprogramming 5 | 6 | // chill out while we look for something to run 7 | set ship:control:pilotmainthrottle to 0. 8 | 9 | // utilities 10 | copy "fileutility.ks" from 0. 11 | run fileutility. 12 | 13 | Download("utility.ks"). 14 | Download("orbit.ks"). 15 | Download("ascent.ks"). 16 | Download("circularize.ks"). 17 | Download("maneuver.ks"). 18 | 19 | print "Utilities downloaded!". 20 | copy patch.ks to 0. 21 | switch to 0. 22 | rename "patch.ks" to "upload.patch.Eve Science Probe 1.ks". 23 | switch to 1. 24 | 25 | sas off. 26 | lock steering to sun:position. 27 | print "Awaiting EVE SOI!". 28 | wait until ship:body = eve. 29 | print "Arrived in EVE SOI!". 30 | -------------------------------------------------------------------------------- /patch.Eve Science Probe 1.ks: -------------------------------------------------------------------------------- 1 | // general boot script 2 | // by Kenton Hamaluik 3 | // 2015-07-27 4 | // portions borrowed from https://github.com/gisikw/ksprogramming 5 | 6 | // chill out while we look for something to run 7 | set ship:control:pilotmainthrottle to 0. 8 | 9 | // utilities 10 | copy "fileutility.ks" from 0. 11 | run fileutility. 12 | 13 | Download("utility.ks"). 14 | Download("orbit.ks"). 15 | Download("ascent.ks"). 16 | Download("circularize.ks"). 17 | Download("maneuver.ks"). 18 | 19 | print "Utilities downloaded!". 20 | 21 | if(ship:status = "PRELAUNCH") { 22 | print "Prelaunch detected!". 23 | 24 | print "Launcing to orbit!". 25 | run orbit(250, 90, 4, 1.4). 26 | 27 | hudtext("Eve Science Probe 1 Is 5x5!", 1, 2, 50, green, true). 28 | hudtext("Ready for transfer burn!", 1, 2, 50, green, true). 29 | } -------------------------------------------------------------------------------- /old/example_testsasmode.ks: -------------------------------------------------------------------------------- 1 | clearscreen. 2 | set oldsas to sas. 3 | sas on. 4 | set delay to 4. 5 | print("testing sasmode"). 6 | wait delay. 7 | set sasmode to "prograde". 8 | print "prograde check!". 9 | wait delay. 10 | selectautopilotmode("retrograde"). 11 | print "retrograde check!". 12 | wait delay. 13 | set sasmode to "normal". 14 | print "normal check!". 15 | wait delay. 16 | set sasmode to "antinormal". 17 | print "antinormal check!". 18 | wait delay. 19 | set sasmode to "radialin". 20 | print "radialin check!". 21 | wait delay. 22 | set sasmode to "RadialOut". 23 | print "RadialOut check!". 24 | wait delay. 25 | add node(time:seconds + 60, 0, 0, 1000). 26 | set sasmode to "maneuver". 27 | print "maneuver check!". 28 | wait delay. 29 | set sasmode to "target". 30 | print "target check!". 31 | wait delay. 32 | set sasmode to "antitarget". 33 | print "antitarget check!". 34 | wait delay. -------------------------------------------------------------------------------- /old/example_lib_raw_user_input.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | run lib_raw_user_input. 3 | local quit is false. 4 | until quit 5 | { 6 | clearscreen. 7 | print "main menu". 8 | print "3. submenu". 9 | print "4. quit". 10 | local menu_option is wait_for_action_groups(list("ag3", "ag4")). 11 | if menu_option = 1 12 | { 13 | set quit to true. 14 | } 15 | else if menu_option = 0 16 | { 17 | local sub_quit is false. 18 | until sub_quit 19 | { 20 | clearscreen. 21 | print "submenu". 22 | print "7. say hello". 23 | print "8. main menu". 24 | local menu_option is wait_for_action_groups(list("ag7", "ag8")). 25 | if menu_option = 0 26 | { 27 | print "hello". 28 | wait 1. 29 | } 30 | else if menu_option = 1 31 | { 32 | set sub_quit to true. 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /old/example_lib_navball.ks: -------------------------------------------------------------------------------- 1 | // Testing the lib_navball functions. 2 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 3 | 4 | run lib_navball. 5 | 6 | clearscreen. 7 | 8 | print "Testing lib_navball.". 9 | print " ". 10 | print " +--------------------+". 11 | print " | Compass = |". 12 | print " +--------------------+". 13 | print " ". 14 | print " +--------------------+". 15 | print " | Pitch = |". 16 | print " +--------------------+". 17 | print " ". 18 | print " +--------------------+". 19 | print " | Roll = |". 20 | print " +--------------------+". 21 | print " ". 22 | print "Looping forever. Use Action group 1 to break.". 23 | 24 | set done to false. 25 | on AG1 set done to true. 26 | 27 | until done { 28 | print round(compass_for(ship), 1) + " " at (13,3). 29 | print round(pitch_for(ship), 1) + " " at (13,7). 30 | print round(roll_for(ship), 1) + " " at (13,11). 31 | wait 0. 32 | }. 33 | -------------------------------------------------------------------------------- /circularize.ks: -------------------------------------------------------------------------------- 1 | parameter location. 2 | 3 | print ("c0."). 4 | set r_a to ship:apoapsis + ship:body:radius. 5 | set r_p to ship:periapsis + ship:body:radius. 6 | 7 | set ecc to 1 - (2 / ((r_a / r_p) + 1)). 8 | set sma to (r_p + r_a) / 2. 9 | 10 | set v_a to sqrt(((1 - ecc) * body:mu) / ((1 + ecc) * sma)). 11 | set v_p to sqrt(((1 + ecc) * body:mu) / ((1 - ecc) * sma)). 12 | 13 | print "c1.". 14 | if(location = "apoapsis") { 15 | print "c2.". 16 | set circDV to sqrt(body:mu / r_a) - v_a. 17 | print "c3.". 18 | add node(time:seconds + eta:apoapsis, 0, 0, circDV). 19 | print "c4.". 20 | } 21 | else if(location = "periapsis") { 22 | print "c5.". 23 | set circDV to sqrt(body:mu / r_p) - v_p. 24 | print "c6.". 25 | add node(time:seconds + eta:periapsis, 0, 0, circDV). 26 | print "c7.". 27 | } 28 | else { 29 | print "c8.". 30 | print "Invalid argument!". 31 | print "c9.". 32 | print "Use 'apoapsis' or 'periapsis'!". 33 | print "c10.". 34 | } 35 | print "c11.". 36 | 37 | -------------------------------------------------------------------------------- /old/example_lib_exec.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | 3 | run lib_exec. 4 | 5 | execute("set " + "x" + " to " + "42" + "." + "print x."). // set x to 42. print x. 6 | 7 | print evaluate("2 * 2 = 5"). // false 8 | print evaluate("2 * 2 = 4"). // true 9 | 10 | lock expr to 0. // othervise compiler won't rialize that expr is lock 11 | 12 | set str_expr to "x * x + 2 * x - 10". 13 | 14 | execute("lock expr to " + str_expr + "."). 15 | 16 | print "f(x) = " + str_expr. 17 | 18 | set x to -5. 19 | set step to 1. 20 | 21 | until x > 5 22 | { 23 | print "f(" + x + ") = " + expr. 24 | set x to x + step. 25 | } 26 | 27 | 28 | set str_expr to "1 / x". 29 | 30 | execute("lock expr to " + str_expr + "."). 31 | 32 | print "g(x) = " + str_expr. 33 | 34 | set x to 1. 35 | set step to 2. 36 | 37 | until x > 8 38 | { 39 | print "g(" + x + ") = " + expr. 40 | set x to x + step. 41 | } 42 | 43 | function foo 44 | { 45 | parameter x. 46 | return x ^ 2. 47 | } 48 | 49 | print evaluate_function("foo", list(10)). 50 | -------------------------------------------------------------------------------- /fileutility.ks: -------------------------------------------------------------------------------- 1 | function FileExists { 2 | parameter name. 3 | parameter vol. 4 | 5 | switch to vol. 6 | list files in allFiles. 7 | for file in allFiles { 8 | if file:name = name { 9 | switch to 1. 10 | return true. 11 | } 12 | } 13 | switch to 1. 14 | return false. 15 | } 16 | 17 | // download files from the archive 18 | function Download { 19 | parameter name. 20 | 21 | //set downloadTime to addons:rt:delay(ship) * 3. 22 | //set timer to 0. 23 | 24 | //print "Downloading '" + name + "', will take " + round(downloadTime, 1) + "s.". 25 | 26 | //until timer >= downloadTime { 27 | // set start to time:seconds. 28 | // // if we lose connection, the download will be paused 29 | // wait until (time:seconds - start) > (downloadTime - timer) or not addons:rt:hasconnection(ship). 30 | // set timer to timer + time:seconds - start. 31 | //} 32 | 33 | // delete any local copies 34 | if FileExists(name, 1) { 35 | delete name. 36 | } 37 | 38 | // download from the archive 39 | if FileExists(name, 0) { 40 | copy name from 0. 41 | } 42 | } -------------------------------------------------------------------------------- /old/SC1.ks: -------------------------------------------------------------------------------- 1 | clearscreen. 2 | print "". 3 | print "". 4 | print "". 5 | print "". 6 | print "". 7 | print "". 8 | print " /\ ". 9 | print " |==| ". 10 | print " | | ". 11 | print " | | ". 12 | print " | | ". 13 | print " /____\ +-+-+-+-+-+ ". 14 | print " | | |S|p|a|c|e| ". 15 | print " | | +-+-+-+-+-+-+-+-+ ". 16 | print " | SC | |C|o|m|p|u|t|e|r| ". 17 | print " |v1.0| +-+-+-+-+-+-+-+-+ ". 18 | print " | | |v|1|.|0| ". 19 | print " /| | |\ +-+-+-+-+ ". 20 | print " / | | | \ ". 21 | print " /__|_|__|__\ ". 22 | print " /_\/_\ ". 23 | print " ###### ". 24 | print " ######## ". 25 | print " ###### ". 26 | print " #### ". 27 | print " #### ". 28 | print " ## ". 29 | print " ## ". 30 | print " ## ". 31 | print " ## ". 32 | 33 | set count to 0. 34 | wait 2. 35 | until count = 46 36 | { print "". set count to count + 1. }. -------------------------------------------------------------------------------- /utility.ks: -------------------------------------------------------------------------------- 1 | set lastThrust to -1. 2 | function AutoStage { 3 | parameter minStage. 4 | parameter delta. 5 | 6 | if(stage:number <= minStage) { 7 | set lastThrust to ship:maxthrust. 8 | return. 9 | } 10 | 11 | if(lastThrust < 0) { 12 | set lastThrust to ship:maxthrust. 13 | } 14 | 15 | if(ship:maxthrust < lastThrust - delta) { 16 | print "Thrust profile changed, staging!". 17 | set preThrottle to throttle. 18 | lock throttle to 0. 19 | wait 0.5. 20 | stage. 21 | wait 0.5. 22 | lock throttle to preThrottle. 23 | } 24 | set lastThrust to ship:maxthrust. 25 | } 26 | 27 | function EllipticalPitch { 28 | parameter alt. 29 | parameter flatAlt. 30 | 31 | if(alt < flatAlt) { 32 | set p to sqrt((90^2)*(1 - ((alt^2) / (flatAlt^2)))). 33 | } 34 | else { 35 | set p to 0. 36 | } 37 | 38 | return p. 39 | } 40 | 41 | function ShipTWR { 42 | set mth to ship:maxthrust. 43 | set r to ship:altitude + ship:body:radius. 44 | set w to ship:mass * ship:body:mu / r / r. 45 | return mth/w. 46 | } 47 | 48 | function LocalG { 49 | set r to ship:altitude + ship:body:radius. 50 | return ship:body:mu / r / r. 51 | } -------------------------------------------------------------------------------- /old/lib_navball.ks: -------------------------------------------------------------------------------- 1 | // A library of functions to calculate navball-based directions: 2 | 3 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 4 | 5 | @lazyglobal off. 6 | 7 | function east_for { 8 | parameter ves. 9 | 10 | return vcrs(ves:up:vector, ves:north:vector). 11 | } 12 | 13 | function compass_for { 14 | parameter ves. 15 | 16 | local pointing is ves:facing:forevector. 17 | local east is east_for(ves). 18 | 19 | local trig_x is vdot(ves:north:vector, pointing). 20 | local trig_y is vdot(east, pointing). 21 | 22 | local result is arctan2(trig_y, trig_x). 23 | 24 | if result < 0 { 25 | return 360 + result. 26 | } else { 27 | return result. 28 | } 29 | } 30 | 31 | function pitch_for { 32 | parameter ves. 33 | 34 | return 90 - vang(ves:up:vector, ves:facing:forevector). 35 | } 36 | 37 | function roll_for { 38 | parameter ves. 39 | 40 | local raw is vang(ves:up:vector, ves:facing:starvector). 41 | if vang(ves:up:vector, ves:facing:topvector) > 90 { 42 | if raw > 90 { 43 | return raw - 270. 44 | } else { 45 | return raw + 90. 46 | } 47 | } else { 48 | return 90 - raw. 49 | } 50 | }. 51 | -------------------------------------------------------------------------------- /old/utilities.ks: -------------------------------------------------------------------------------- 1 | @lazyglobal off. 2 | 3 | function mix { 4 | declare parameter left. 5 | declare parameter right. 6 | declare parameter weight. 7 | 8 | return left + (right - left) * weight. 9 | } 10 | 11 | function east_for { 12 | parameter ves. 13 | 14 | return vcrs(ves:up:vector, ves:north:vector). 15 | } 16 | 17 | function compass_for { 18 | parameter ves. 19 | 20 | local pointing is ves:facing:forevector. 21 | local east is east_for(ves). 22 | 23 | local trig_x is vdot(ves:north:vector, pointing). 24 | local trig_y is vdot(east, pointing). 25 | 26 | local result is arctan2(trig_y, trig_x). 27 | 28 | if result < 0 { 29 | return 360 + result. 30 | } else { 31 | return result. 32 | } 33 | } 34 | 35 | function flight_path_azimuth_for { 36 | parameter ves. 37 | 38 | local pointing is ves:velocity:orbit. 39 | local east is east_for(ves). 40 | 41 | local trig_x is vdot(ves:north:vector, pointing). 42 | local trig_y is vdot(east, pointing). 43 | 44 | local result is arctan2(trig_y, trig_x). 45 | 46 | if result < 0 { 47 | return 360 + result. 48 | } else { 49 | return result. 50 | } 51 | } 52 | 53 | function clamp_abs { 54 | parameter x. 55 | parameter limit. 56 | return min(max(x, -limit), limit). 57 | }. 58 | -------------------------------------------------------------------------------- /old/lib_num_to_str.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | 3 | @LAZYGLOBAL off. 4 | 5 | function num_to_str { 6 | parameter 7 | number, //input number 8 | ip, //number of digits before the decimal point. 9 | dp. //number of decimal places 10 | 11 | local string is "". 12 | local padder is "". 13 | local absNumber is abs(number). 14 | local index is ip-1. 15 | local firstNum is false. 16 | until firstNum or index = 0 { // stop adding spacers when the first number is found 17 | if mod(floor(absNumber/10^index),10) = 0 { 18 | set padder to padder +" ". 19 | } 20 | else { 21 | set firstNum to true. 22 | } 23 | set index to index-1. 24 | }. 25 | if dp = 0 { 26 | set string to string +round(absNumber). 27 | }. 28 | else { 29 | // set index to index-1. 30 | set string to string +floor(absNumber). 31 | set index to -1. 32 | set string to string +".". 33 | until index = -dp { 34 | set string to string +mod(floor(absNumber/10^index),10). 35 | set index to index-1. 36 | }. 37 | set string to string + mod(round(absNumber/10^index),10). 38 | }. 39 | if number < 0 { 40 | set string to padder +"-" +string. 41 | } 42 | else { 43 | set string to padder +" " +string. 44 | }. 45 | return string. 46 | }. 47 | -------------------------------------------------------------------------------- /upload.patch.kOS Dev MKI-A.ks: -------------------------------------------------------------------------------- 1 | run utility. 2 | 3 | // find our target 4 | set target to vessel("kOS Dev MKI-A 1"). 5 | 6 | set r1 to ship:body:radius + ship:altitude. 7 | set r2 to target:body:radius + target:altitude. 8 | set dv1 to sqrt(ship:body:mu / r1) * (sqrt((2 * r2) / (r1 + r2)) - 1). 9 | set dv2 to sqrt(ship:body:mu / r2) * (1 - sqrt((2 * r1) / (r1 + r2))). 10 | set transitTime to constant():PI * sqrt((r1 + r2)^3 / (8 * ship:body:mu)). 11 | 12 | set shipLong to ship:obt:trueanomaly + ship:obt:argumentOfPeriapsis + ship:obt:lan. 13 | set targetLong to target:obt:trueanomaly + target:obt:argumentOfPeriapsis + target:obt:lan. 14 | 15 | set phaseAngle to ClampAngle(targetLong - shipLong, 360). 16 | 17 | print "Ship long: " + shipLong. 18 | print "Target long: " + targetLong. 19 | print "Phase angle: " + phaseAngle. 20 | 21 | set relInc to RelativeInclination(ship, target). 22 | print "Relative inclination: " + relInc. 23 | 24 | set shipAngularVel to 360 / ship:obt:period. 25 | set targetAngularVel to 360 / ship:obt:period. 26 | set relativeAngularVel to abs(targetAngularVel - shipAngularVel). 27 | 28 | set desiredPhaseAngle to targetAngularVel * transitTime. 29 | 30 | print "Trans-orbital transit time is " + round(transitTime, 1) + " s.". 31 | print "Desired phase angle is therefore: " + desiredPhaseAngle. -------------------------------------------------------------------------------- /old/lib_raw_user_input.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | // Originally developed by abenkovskii 3 | @LAZYGLOBAL OFF. 4 | 5 | run lib_exec. 6 | 7 | function wait_for_action_groups 8 | { 9 | parameter ag_list. // list of strings 10 | 11 | function first_diff 12 | { 13 | parameter list_a. 14 | parameter list_b. 15 | 16 | local iter_a is list_a:iterator. 17 | local iter_b is list_b:iterator. 18 | 19 | until not (iter_a:next and iter_b:next) 20 | { 21 | if iter_a:value <> iter_b:value 22 | { 23 | break. 24 | } 25 | } 26 | local result is iter_a:index. 27 | if iter_a:atend and iter_b:atend 28 | { 29 | set result to -1. 30 | } 31 | return result. 32 | } 33 | 34 | local arg_string is "". 35 | local separator is "". 36 | 37 | for ag_name in ag_list 38 | { 39 | set arg_string to arg_string + separator + ag_name. 40 | set separator to ", ". 41 | } 42 | 43 | lock _raw_input_ag_list to -1. 44 | execute("lock _raw_input_ag_list to list(" + arg_string + ")."). 45 | local old_values is _raw_input_ag_list. 46 | 47 | local result is -1. 48 | until result <> -1 49 | { 50 | set result to first_diff(old_values, _raw_input_ag_list). 51 | } 52 | 53 | return result. 54 | } 55 | -------------------------------------------------------------------------------- /patch.Eve Base 1.ks: -------------------------------------------------------------------------------- 1 | // general boot script 2 | // by Kenton Hamaluik 3 | // 2015-07-27 4 | // portions borrowed from https://github.com/gisikw/ksprogramming 5 | 6 | // chill out while we look for something to run 7 | set ship:control:pilotmainthrottle to 0. 8 | 9 | // utilities 10 | copy "fileutility.ks" from 0. 11 | run fileutility. 12 | 13 | Download("utility.ks"). 14 | Download("orbit.ks"). 15 | Download("ascent.ks"). 16 | Download("circularize.ks"). 17 | Download("maneuver.ks"). 18 | 19 | print "Utilities downloaded!". 20 | 21 | if(ship:status = "PRELAUNCH") { 22 | print "Prelaunch detected!". 23 | 24 | set longRangeComms to ship:partsdubbed("LongRangeComms")[0]. 25 | set shortRangeComms to ship:partsdubbed("ShortRangeComms"). 26 | 27 | when altitude > 70000 then { 28 | print "Deploying sails.". 29 | ag1. 30 | 31 | print "Deploying comms". 32 | for antenna in shortRangeComms { 33 | set m to antenna:getmodule("ModuleRTAntenna"). 34 | m:doevent("activate"). 35 | } 36 | set m to longRangeComms:("ModuleRTAntenna"). 37 | m:doevent("activate"). 38 | m:setfield("target", "mission-control"). 39 | 40 | when altitude < 70000 then { 41 | print "Retracting sails.". 42 | ag2. 43 | } 44 | } 45 | 46 | print "Launcing to orbit!". 47 | run orbit(250, 90, 2). 48 | 49 | hudtext("Eve Base 1 Is 5x5!", 1, 2, 50, green, true). 50 | hudtext("Ready for transfer burn!", 1, 2, 50, green, true). 51 | } -------------------------------------------------------------------------------- /old/circularize.ks: -------------------------------------------------------------------------------- 1 | // circularize.ks 2 | // Circularize near apoapsis, attempting to set inclination to 3 | // parameter `target_inclination`. 4 | 5 | parameter target_inclination. 6 | 7 | print "Waiting for apoapsis.". 8 | wait 1. 9 | if eta:apoapsis > 600 { 10 | set warp to 4. 11 | wait until eta:apoapsis < 600. 12 | }. 13 | if eta:apoapsis > 150 { 14 | set warp to 3. 15 | wait until eta:apoapsis < 150. 16 | }. 17 | if eta:apoapsis > 60 { 18 | set warp to 1. 19 | wait until eta:apoapsis < 60. 20 | }. 21 | set warp to 0. 22 | 23 | lock circ_spd to sqrt( body:mu / ( ship:altitude + body:radius)). 24 | print "Target orbital speed is " + circ_spd. 25 | 26 | lock circ_azimuth_north to arcsin(cos(target_inclination)/cos(ship:latitude)). 27 | lock circ_azimuth_south to 180 - circ_azimuth_north. 28 | 29 | set circ_azimuth to 0. 30 | if ship:velocity:orbit:y > 0 { 31 | lock circ_azimuth to circ_azimuth_north. 32 | } else { 33 | lock circ_azimuth to circ_azimuth_south. 34 | }. 35 | 36 | lock circ_obt_vec to 37 | heading(circ_azimuth,0):forevector * circ_spd. 38 | 39 | print "Target azimuth is " + circ_azimuth. 40 | 41 | lock burn_vec to circ_obt_vec - ship:velocity:orbit. 42 | 43 | print "Attitude control engaged.". 44 | lock steering to burn_vec. 45 | wait until vang(ship:facing:forevector, burn_vec) < 1 and eta:apoapsis < 10. 46 | 47 | print "Circularizing.". 48 | lock throttle to min(1, burn_vec:mag / 50). 49 | 50 | wait until burn_vec:mag < 0.1. 51 | 52 | lock throttle to 0. 53 | -------------------------------------------------------------------------------- /orbit.ks: -------------------------------------------------------------------------------- 1 | declare parameter desiredAltitude. 2 | declare parameter desiredHeading. 3 | declare parameter stageLimit. 4 | declare parameter targetTWR. 5 | 6 | print "Downloading libraries.". 7 | 8 | run fileutility. 9 | Download("utility.ks"). 10 | run utility. 11 | Download("ascent.ks"). 12 | Download("circularize.ks"). 13 | Download("maneuver.ks"). 14 | 15 | // make sure we can launch 16 | if(ship:status = "PRELAUNCH" or ship:status = "LANDED") { 17 | // run the ascent program 18 | print "Executing ascent program.". 19 | run ascent(desiredAltitude * 1000, desiredHeading, stageLimit, targetTWR). 20 | lock throttle to 0. 21 | } 22 | 23 | // plan for circularization 24 | print "Planning circularization burn.". 25 | run circularize("apoapsis"). 26 | 27 | // execute the next maneuver node 28 | print "Executing maneuver node program.". 29 | run maneuver(stageLimit). 30 | 31 | function eccentricity { 32 | local r_a to ship:apoapsis + ship:body:radius. 33 | local r_p to ship:periapsis + ship:body:radius. 34 | return (r_a - r_p) / (r_a + r_p). 35 | } 36 | 37 | // make sure we're in a circular orbit 38 | until(eccentricity() < 0.001) { 39 | print "Eccentricity (" + eccentricity() + ") is not acceptable, adjusting...". 40 | print "Calculating circularization burn...". 41 | run circularize("apoapsis"). 42 | print "Complete!". 43 | print "Executing maneuver...". 44 | run maneuver(stageLimit). 45 | print "Complete!". 46 | 47 | } 48 | print "Eccentricity (" + eccentricity() + ") is at acceptable levels!". 49 | 50 | print "Circularization complete.". 51 | print "Engaging manual control.". 52 | set ship:control:pilotmainthrottle to 0. -------------------------------------------------------------------------------- /old/lib_number_dialog.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | 3 | function open_number_dialog 4 | { 5 | parameter title. 6 | parameter number. 7 | 8 | local increment is 1. 9 | 10 | clearscreen. 11 | 12 | local eq_string is "+". 13 | local space_string is "|". 14 | local i is 0. 15 | until i+2=terminal:width{ 16 | set eq_string to eq_string+"=". 17 | set space_string to space_string+" ". 18 | set i to i+1. 19 | } 20 | set space_string to space_string+"|". 21 | set eq_string to eq_string+"+". 22 | print eq_string at(0,0). 23 | set i to 0. 24 | until i=8{ 25 | print space_string at(0,1+i). 26 | set i to i+1. 27 | } 28 | print eq_string at(0,9). 29 | 30 | print "6/7 - number -/+" at (2, 5). 31 | print "8/9 - increment -/+" at (2, 6). 32 | print "0 - enter" at (2, 7). 33 | 34 | local old_decrease is ag6. 35 | local old_increase is ag7. 36 | local old_div10 is ag8. 37 | local old_mul10 is ag9. 38 | local old_enter is ag10. 39 | local spaces is " ". 40 | 41 | until old_enter <> ag10{ 42 | print title + " "+number+spaces at (2, 2). 43 | print "Increment: " + increment+spaces at (2, 3). 44 | 45 | if old_increase <> ag7{ 46 | set old_increase to ag7. 47 | set number to number + increment. 48 | } 49 | if old_decrease <> ag6{ 50 | set old_decrease to ag6. 51 | set number to number - increment. 52 | } 53 | if old_div10 <> ag8{ 54 | set old_div10 to ag8. 55 | set increment to increment / 10. 56 | } 57 | if old_mul10 <> ag9{ 58 | set old_mul10 to ag9. 59 | set increment to increment * 10. 60 | } 61 | } 62 | 63 | clearscreen. 64 | 65 | return number. 66 | } 67 | -------------------------------------------------------------------------------- /upload.patch.Minmus Jet 1.ks: -------------------------------------------------------------------------------- 1 | // transfer DVs 2 | // courtesy of https://en.wikipedia.org/wiki/Hohmann_transfer_orbit 3 | set r1 to ship:body:radius + ship:altitude. 4 | set r2 to minmus:apoapsis. 5 | set dv1 to sqrt(ship:body:mu / r1) * (sqrt((2 * r2) / (r1 + r2)) - 1). 6 | set dv2 to sqrt(ship:body:mu / r2) * (1 - sqrt((2 * r1) / (r1 + r2))). 7 | 8 | print "DV1 = " + dv1. 9 | print "DV2 = " + dv2. 10 | print "Total = " + (dv1 + dv2). 11 | 12 | set transitTime to constant():PI * sqrt((r1 + r2)^3 / (8 * ship:body:mu)). 13 | 14 | print "minmus transit time = " + round(transitTime, 1) + "s!". 15 | 16 | set minmusPeriod to minmus:obt:period. 17 | set minmusAngleSpeed to 360 / minmusPeriod. 18 | set degChangeDuringTransit to minmusAngleSpeed * transitTime. 19 | print "Will go " + round(degChangeDuringTransit, 1) + " deg around Kerbin during the transfer.". 20 | 21 | set departurePhaseAngle to (minmus:obt:trueanomaly - ship:obt:trueanomaly) - degChangeDuringTransit. 22 | print "Transit phase angle = " + round(departurePhaseAngle, 1). 23 | set currentPhaseAngle to (360 - minmus:obt:trueanomaly) - ship:obt:trueanomaly. 24 | print "Current phase angle = " + round(currentPhaseAngle, 1). 25 | 26 | set shipAngleSpeed to 360 / ship:obt:period. 27 | set transferRelativeAngleSpeed to shipAngleSpeed - minmusAngleSpeed. 28 | print "Speed of phase angle = " + round(transferRelativeAngleSpeed, 1). 29 | 30 | set deltaPhaseAngle to departurePhaseAngle - currentPhaseAngle. 31 | set timeTillPhaseAngle to abs(deltaPhaseAngle / transferRelativeAngleSpeed). 32 | print round(timeTillPhaseAngle, 1) + " s until phase angle is aligned!". 33 | 34 | //set targetNode to node(time:seconds + timeTillPhaseAngle, 0, 0, dv1). 35 | //add targetNode. -------------------------------------------------------------------------------- /orbitutility.ks: -------------------------------------------------------------------------------- 1 | set DegToRad to constant():PI / 180. 2 | set RadToDeg to 180 / constant():PI. 3 | 4 | function cosr { 5 | parameter x. 6 | return cos(RadToDeg * x). 7 | } 8 | 9 | function sinr { 10 | parameter x. 11 | return sin(RadToDeg * x). 12 | } 13 | 14 | function acosr { 15 | parameter x. 16 | return DegToRad * arccos(x). 17 | } 18 | 19 | function GetOrbitNormal { 20 | parameter orbitable. 21 | return vcrs(orbitable:up:forevector, orbitable:prograde:forevector):normalized. 22 | } 23 | 24 | function EccAnomR { 25 | parameter ecc, trueAnom. 26 | return acosr((ecc + cosr(trueAnom)) / (1 + ecc * cosr(trueAnom))). 27 | } 28 | 29 | function MeanAnomR { 30 | parameter ecc, eccAnom. 31 | return eccAnom - ecc * sinr(eccAnom). 32 | } 33 | 34 | function MeanMotionR { 35 | parameter orbit. 36 | return sqrt(orbit:body:mu / (orbit:semimajoraxis * orbit:semimajoraxis * orbit:semimajoraxis)) 37 | } 38 | 39 | function TimeOfTrueAnomaly { 40 | parameter orbit. 41 | parameter trueAnomaly. 42 | return (MeanAnomR(orbit:eccentricity, EccAnomR(orbit:eccentricity, DegToRad * trueAnomaly)) - (DegToRad * orbit:meananomalyatepoch)) / MeanMotionR(orbit). 43 | } 44 | 45 | function TimeToAscendingNode { 46 | parameter orbitable. 47 | set ttan to TimeOfTrueAnomaly(orbitable, 360 - orbitable:obt:argumentofperiapsis) - time:seconds. 48 | if ttan < 0 { 49 | set ttan to ttan + orbitable:obt:period. 50 | } 51 | return ttan. 52 | } 53 | 54 | function TimeToDescendingNode { 55 | parameter orbitable. 56 | set ttdn to TimeOfTrueAnomaly(orbitable, 180 - orbitable:obt:argumentofperiapsis) - time:seconds. 57 | if ttdn < 0 { 58 | set ttdn to ttdn + orbitable:obt:period. 59 | } 60 | return ttdn. 61 | } -------------------------------------------------------------------------------- /old/launch_east.ks: -------------------------------------------------------------------------------- 1 | declare parameter desiredApo. 2 | 3 | // prepare for lift-off 4 | clearscreen. 5 | print "Throttling up...". 6 | lock throttle to 1.0. 7 | lock steering to up. 8 | wait 1. 9 | 10 | print "Launching in:". 11 | print " 5". 12 | wait 1. 13 | print " 4". 14 | wait 1. 15 | print " 3". 16 | wait 1. 17 | print " 2". 18 | wait 1. 19 | print " 1". 20 | wait 1. 21 | print "Fire main engines!". 22 | 23 | when ship:altitude > 100 then { 24 | print "We have lift-off!". 25 | } 26 | 27 | // auto-stage 28 | when stage:liquidfuel < 0.1 then { 29 | //print "Staging!". 30 | stage. 31 | preserve. 32 | } 33 | 34 | // auto-solar panel 35 | when ship:altitude > 71000 then { 36 | AG1. 37 | when ship:altitude < 71000 then { 38 | AG2. 39 | } 40 | } 41 | 42 | // turn SAS on 43 | SAS on. 44 | // deal with the gears 45 | gear on. gear off. 46 | 47 | // wait till we've got off the ground to start controlling the throttle 48 | until ship:altitude > 1000 { wait 0.001. } 49 | 50 | print "Tempering throttle...". 51 | // aim for a TWR of about 2 52 | lock throttle to max(min((2 * (body:mu / body:position:mag^2) * mass / maxthrust), 0), 1). 53 | 54 | // wait until we hit our apoapsis 55 | until ship:apoapsis > desiredApo { 56 | wait 0.1. 57 | } 58 | lock throttle to 0. 59 | print "Drifting to apoapsis...". 60 | until ship:altitude > 70000 { wait 0.1. } 61 | 62 | // turn towards the horizon 63 | lock steering to heading(90, 0). 64 | 65 | // calculate some variables 66 | set Gk to 3.5316000*10^12. 67 | set Radius to 600000 + apoapsis. 68 | set sma to 600000 + ((periapsis+apoapsis)/2). 69 | set V1 to (Gk/Radius)^.5. 70 | set V2 to (Gk*((2/Radius)-(1/sma)))^.5. 71 | set dV to abs(V1-V2). 72 | set acceleration to (maxthrust/mass). 73 | set burnTime to (dV/acceleration). 74 | 75 | print "Burn time: " + burnTime. -------------------------------------------------------------------------------- /hohmann.ks: -------------------------------------------------------------------------------- 1 | parameter targetLongitude. 2 | parameter targetAltitude. 3 | 4 | // transfer DVs 5 | // courtesy of https://en.wikipedia.org/wiki/Hohmann_transfer_orbit 6 | set r1 to ship:body:radius + ship:altitude. 7 | set r2 to ship:body:radius + targetAltitude. 8 | set dv1 to sqrt(ship:body:mu / r1) * (sqrt((2 * r2) / (r1 + r2)) - 1). 9 | set dv2 to sqrt(ship:body:mu / r2) * (1 - sqrt((2 * r1) / (r1 + r2))). 10 | 11 | print "DV1 = " + dv1. 12 | print "DV2 = " + dv2. 13 | print "Total = " + (dv1 + dv2). 14 | 15 | set transitTime to constant():PI * sqrt((r1 + r2)^3 / (8 * ship:body:mu)). 16 | 17 | print "Transit time = " + transitTime. 18 | 19 | set bodyRotationSpeedInDegrees to 360 / ship:body:rotationPeriod. 20 | set bodySiderealVelocity to ship:body:radius * bodyRotationSpeedInDegrees * constant():PI / 180. 21 | 22 | print "Body rotation speed in degrees = " + bodyRotationSpeedInDegrees. 23 | print "Body sidereal velocity = " + bodySiderealVelocity. 24 | 25 | set bodyRotationInDegrees to bodyRotationSpeedInDegrees * transitTime. 26 | 27 | print "Body will rotate " + bodyRotationInDegrees + " deg during the transit!". 28 | 29 | set startBurnAngle to targetLongitude - bodyRotationInDegrees. 30 | until startBurnAngle >= 0 { 31 | set startBurnAngle to startBurnAngle + 360. 32 | } 33 | set startBurnAngle to mod(startBurnAngle, 360). 34 | 35 | print "Burn has to start at " + startBurnAngle + " deg!". 36 | 37 | set vo to ship:velocity:orbit:mag. 38 | set wo to (180 * vo) / (constant():PI * r1). 39 | set shipLong to ship:longitude. 40 | until shipLong < startBurnAngle { 41 | set shipLong to shipLong - 360. 42 | } 43 | set maneuverETA to (startBurnAngle - shipLong) / wo. 44 | 45 | print "Vo = " + vo. 46 | print "Wo = " + wo + " (deg)". 47 | print "Ship longitude = " + shipLong. 48 | print "ETA until maneuver = " + maneuverETA + " s". 49 | 50 | set geoNode to node(time:seconds + maneuverETA, 0, 0, dv1). 51 | add geoNode. -------------------------------------------------------------------------------- /old/lib_list_dialog.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | 3 | @LAZYGLOBAL OFF. 4 | 5 | run lib_menu. 6 | 7 | function open_list_dialog { 8 | parameter 9 | title, 10 | option_list. 11 | 12 | local action_list is list("Next page", "Previous page"). 13 | return _list_dialog(title, option_list, action_list, -1). 14 | } 15 | 16 | function open_cancelable_list_dialog { 17 | parameter 18 | title, 19 | option_list. 20 | 21 | local action_list is list("Next page", "Previous page", "Cancel"). 22 | return _list_dialog(title, option_list, action_list, -2). 23 | } 24 | 25 | 26 | // this function is internal and should not be used outside lib_list_dialog 27 | function _list_dialog { 28 | parameter 29 | title, 30 | option_list, 31 | action_list, 32 | internal_action_offset. 33 | 34 | local inaccessible_lines is 11. 35 | local page_start is 0. 36 | local result is internal_action_offset. 37 | until result > internal_action_offset { 38 | local page_height is terminal:height - inaccessible_lines - action_list:length. 39 | set page_start to page_start - mod(page_start, page_height). 40 | local menu_list is action_list:copy. 41 | for option in option_list:sublist(page_start, page_height) { 42 | menu_list:add(option). 43 | } 44 | local title is title + " [Page: " + (page_start / page_height + 1) + " / " + (ceiling(option_list:length/page_height)) + "]". 45 | set result to open_menu_indexed(title, menu_list) - action_list:length. 46 | if result = internal_action_offset - 1 { // next 47 | set page_start to min(page_start + page_height, option_list:length - 1). 48 | } else if result = internal_action_offset { // previous 49 | set page_start to max(0, page_start - page_height). 50 | } 51 | } 52 | if result >= 0 { 53 | set result to page_start + result. 54 | } 55 | return result. 56 | } 57 | -------------------------------------------------------------------------------- /old/lib_menu.ks: -------------------------------------------------------------------------------- 1 | // This script shows a menu on the terminal allowing user to 2 | // select one of the options and return it to calling script. 3 | 4 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 5 | 6 | @lazyglobal off. 7 | 8 | 9 | function open_menu_indexed{ 10 | parameter title. 11 | parameter list_of_names. 12 | 13 | if list_of_names:empty{ 14 | print "error: list_of_names should not be empty". print 1/0. 15 | } 16 | 17 | local current_option is 0. 18 | local len is list_of_names:length(). 19 | local eq_string is "+". 20 | local i is 0. 21 | until i+2=terminal:width{ 22 | set eq_string to eq_string+"=". 23 | set i to i+1. 24 | } 25 | set eq_string to eq_string+"+". 26 | 27 | clearscreen. 28 | print eq_string at(0,0). 29 | set i to 0. 30 | until i=len+8{ 31 | print "|" at(0,i+1). 32 | print "|" at(terminal:width-1,i+1). 33 | set i to i+1. 34 | } 35 | print title at(2,2). 36 | set i to 0. 37 | until i=len{ 38 | print "[ ] "+list_of_names[i] at(2,i+4). 39 | set i to i+1. 40 | } 41 | print eq_string at(0,len+5). 42 | print "AG7/8 - move up/down, AG9 - select" at(2,len+7). 43 | print eq_string at(0,len+9). 44 | print "*" at(3,4). 45 | 46 | until false{ 47 | local last_up is ag7. 48 | local last_down is ag8. 49 | local last_sel is ag9. 50 | wait until ag7<>last_up or ag8<>last_down or ag9<>last_sel. 51 | if ag7<>last_up{ 52 | print " " at(3,4+current_option). 53 | set current_option to mod(current_option-1+len,len). 54 | print "*" at(3,4+current_option). 55 | } 56 | else if ag8<>last_down{ 57 | print " " at(3,4+current_option). 58 | set current_option to mod(current_option+1,len). 59 | print "*" at(3,4+current_option). 60 | } 61 | else if ag9<>last_sel{ 62 | break. 63 | } 64 | } 65 | 66 | clearscreen. 67 | return current_option. 68 | } 69 | 70 | function open_menu{ 71 | parameter title. 72 | parameter list_of_names. 73 | 74 | return list_of_names[open_menu_indexed(title, list_of_names)]. 75 | } 76 | -------------------------------------------------------------------------------- /old/lib_term.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | // Original starting work by Github user: Dunbaratu 3 | 4 | // terminal manipulations 5 | // 6 | @lazyglobal off. 7 | 8 | // ----------- 9 | // char_line 10 | // ----------- 11 | // Perform a low level line drawing algorithm 12 | // with characters on the terminal. 13 | function char_line { 14 | parameter 15 | ch, // string (character) to draw with. 16 | x0, y0, x1, y1. // locations to draw from/to 17 | 18 | local dX is x1-x0. 19 | local dY is y1-y0. 20 | local len is sqrt(dX^2+dY^2). 21 | local incSize is 2. // make loop only execute once if it's just a point. 22 | if len > 0 { 23 | set incSize to 1/len. // or let it execute a number of times if it's not. 24 | } 25 | local d is 0. 26 | until d > 1 { 27 | print ch at (d*dX+x0, d*dY+y0). 28 | set d to d + incSize. 29 | }. 30 | } 31 | 32 | 33 | // Draw an arc of an ellipse, using characters. 34 | // Note that since the screen's Y axis goes bigger going 35 | // DOWN, the result may be inverted from what you'd imagine. 36 | function char_ellipse_arc { 37 | parameter 38 | ch, // string (character) to draw with. 39 | x0, y0, xRad, yRad, deg0, deg1. 40 | 41 | // swap if arc degrees are given backward: 42 | if deg0 > deg1 { 43 | local tmp is deg0. 44 | set deg0 to deg1. 45 | set deg1 to tmp. 46 | }. 47 | // incSize is the biggest number of degrees that is guaranteed 48 | // to be just barely small enough not to skip a character when drawing. 49 | local longRad is max(xRad,yRad). 50 | local incSize is arcsin(1/longRad). 51 | 52 | local d is deg0. 53 | until d > deg1 { 54 | print ch at (xRad*cos(d)+x0, yRad*sin(d)+y0). 55 | set d to d + incSize. 56 | }. 57 | }. 58 | 59 | // Draw a circle. This is a special case of char_ellipse_arc. 60 | function char_circle { 61 | parameter 62 | ch, 63 | x0, y0, r. 64 | char_ellipse_arc(ch, x0, y0, r, r, 0, 360). 65 | }. 66 | -------------------------------------------------------------------------------- /old/lib_circle_nav.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | 3 | 4 | @LAZYGLOBAL OFF. 5 | 6 | //use to find the initial bearing for the shortest path around a sphere from... 7 | function circle_bearing { 8 | parameter 9 | p1, //...this point... 10 | p2. //...to this point. 11 | 12 | return mod(360+arctan2(sin(p2:lng-p1:lng)*cos(p2:lat),cos(p1:lat)*sin(p2:lat)-sin(p1:lat)*cos(p2:lat)*cos(p2:lng-p1:lng)),360). 13 | }. 14 | 15 | //use to find where you will end up if you travel from... 16 | function circle_destination { 17 | parameter 18 | p1, //...this point... 19 | b, // ...with this as your intitial bearing... 20 | d, // ...for this distance... 21 | radius. // ...around a sphere of this radious. 22 | 23 | local lat is arcsin(sin(p1:lat)*cos((d*180)/(radius*constant():pi))+cos(p1:lat)*sin((d*180)/(radius*constant():pi))*cos(b)). 24 | local lng is 0. 25 | if abs(Lat) <> 90 { 26 | set lng to p1:lng+arctan2(sin(b)*sin((d*180)/(radius*constant():pi))*cos(p1:lat),cos((d*180)/(radius*constant():pi))-sin(p1:lat)*sin(lat)). 27 | }. 28 | 29 | return latlng(lat,lng). 30 | }. 31 | 32 | //use to find the distance from... 33 | function circle_distance { 34 | parameter 35 | p1, //...this point... 36 | p2, //...to this point... 37 | radius. //...around a body of this radius. (note: if you are flying you may want to use ship:body:radius + altitude). 38 | local A is sin((p1:lat-p2:lat)/2)^2 + cos(p1:lat)*cos(p2:lat)*sin((p1:lng-p2:lng)/2)^2. 39 | 40 | return radius*constant():PI*arctan2(sqrt(A),sqrt(1-A))/90. 41 | }. 42 | 43 | //use to find the mid point on the outside of a sphere between... 44 | function circle_midpoint { 45 | parameter 46 | p1, //...this point... 47 | p2. //...and this point. 48 | local A is cos(p2:lat)*cos(p2:lng-p1:lng). 49 | local B is cos(p2:lat)*sin(p2:lng-P1:lng). 50 | 51 | return latlng(arctan2(sin(p1:lat)+sin(p2:lat),sqrt((cos(p1:lat)+resultA)^2+resultB^2)),p1:lng+arctan2(resultB,cos(p1:lat)+resultA)). 52 | }. 53 | -------------------------------------------------------------------------------- /old/tune.ks: -------------------------------------------------------------------------------- 1 | declare parameter Kp. 2 | 3 | log "# Throttle PID Tuning" to throttle_log. 4 | log "# Kp: " + Kp to throttle_log. 5 | log "# t acc throt" to throttle_log. 6 | 7 | // load the PID library 8 | run lib_PID. 9 | 10 | // prepare for lift-off 11 | clearscreen. 12 | lock steering to up. 13 | 14 | // auto-stage 15 | when stage:liquidfuel < 0.1 then { 16 | //print "Staging!". 17 | stage. 18 | preserve. 19 | } 20 | 21 | // turn SAS on 22 | SAS on. 23 | 24 | // control the throttle 25 | set myThrottle to 1.0. 26 | lock throttle to myThrottle. 27 | 28 | // initialize the throttle PID 29 | set throttlePID to PID_init(Kp, 0, 0, 0, 1). 30 | 31 | set twr to 0. 32 | lock logline to (time:seconds - start_time) + " " + twr + " " + myThrottle. 33 | 34 | // calculate the TWR of the vehicle in its current state 35 | function calculateTWR { 36 | set i to 0. 37 | set totalThrust to v(0,0,0). 38 | 39 | list engines in engs. 40 | until i = engs:length { 41 | if engs[i]:ignition { 42 | set thrust to engs[i]:facing:vector:normalized * engs[i]:thrust. 43 | set totalThrust to totalThrust + thrust. 44 | }. 45 | set i to i + 1. 46 | } 47 | 48 | set gravity to -up:vector:normalized * (body:mu / body:position:mag^2). 49 | //set v_acc to vdot(up:vector, totalThrust)/mass - gravity:mag. 50 | set twr to (totalThrust:mag / mass) / gravity:mag. 51 | } 52 | 53 | // keep going until we hit the gear key to disable things 54 | gear on. gear off. 55 | // wait till we've got off the ground to start controlling the throttle 56 | until ship:altitude > 100 { wait 0.001. } 57 | print "Tempering throttle, gear to release.". 58 | clearscreen. 59 | set start_time to time:seconds. 60 | until gear { 61 | calculateTWR(). 62 | set myThrottle to PID_seek(throttlePID, 2, twr). 63 | 64 | print "T: " + (time:seconds - start_time) at (0, 0). 65 | print "TWR: " + (twr) + " " at (0, 1). 66 | print "Target TWR: " + 2 at (0, 2). 67 | print "Error: " + (abs(twr - 2) / 2) at (0, 3). 68 | 69 | log logline to throttle_log. 70 | wait 0.001. 71 | } 72 | //copy throttle_log to 0. -------------------------------------------------------------------------------- /old/example_lib_lazcalc.ks: -------------------------------------------------------------------------------- 1 | //LIB_LAZcalc.ks testing example 2 | //This file is distributed under the terms of the MIT license, (c) the KSLib team 3 | 4 | SWITCH TO 0. 5 | RUN lib_lazcalc.ks. 6 | CLEARSCREEN. 7 | SET TERMINAL:WIDTH TO 50. 8 | 9 | LOCAL launchAzimuth TO 0. 10 | 11 | PRINT "Target Alt | Target Inc | Node | Launch Azimuth". 12 | PRINT "--------------------------------------------------". 13 | SET launchAzimuth TO LAZcalc(130,0). 14 | PRINT " 130km | 0deg | Asc | " + ROUND(launchAzimuth,2) + "deg". 15 | PRINT "--------------------------------------------------". 16 | SET launchAzimuth TO LAZcalc(450,51.6). 17 | PRINT " 450km | 51.6deg | Asc | " + ROUND(launchAzimuth,2) + "deg". 18 | PRINT "--------------------------------------------------". 19 | SET launchAzimuth TO LAZcalc(120,40). 20 | PRINT " 120km | 40deg | Asc | " + ROUND(launchAzimuth,2) + "deg". 21 | PRINT "--------------------------------------------------". 22 | SET launchAzimuth TO LAZcalc(500,-60). 23 | PRINT " 500km | 60deg | Dec | " + ROUND(launchAzimuth,2) + "deg". 24 | PRINT "--------------------------------------------------". 25 | SET launchAzimuth TO LAZcalc(130,-180). 26 | PRINT " 130km | 180deg | Dec | " + ROUND(launchAzimuth,2) + "deg". 27 | PRINT "--------------------------------------------------". 28 | SET launchAzimuth TO LAZcalc(250,120). 29 | PRINT " 250km | 120deg | Asc | " + ROUND(launchAzimuth,2) + "deg". 30 | PRINT "--------------------------------------------------". 31 | SET launchAzimuth TO LAZcalc(150,-90). 32 | PRINT " 150km | 90deg | Dec | " + ROUND(launchAzimuth,2) + "deg". 33 | PRINT "--------------------------------------------------". 34 | SET launchAzimuth TO LAZcalc(250,90). 35 | PRINT " 250km | 90deg | Asc | " + ROUND(launchAzimuth,2) + "deg". 36 | PRINT "--------------------------------------------------". 37 | SET launchAzimuth TO LAZcalc(1000,-105). 38 | PRINT " 1000km | 105deg | Dec | " + ROUND(launchAzimuth,2) + "deg". 39 | PRINT "--------------------------------------------------". -------------------------------------------------------------------------------- /old/spacecomputer.ks: -------------------------------------------------------------------------------- 1 | clearscreen. 2 | set exit to 0. 3 | set index to 0. 4 | set selection to 0. 5 | set printflag to 1. 6 | if ag9 = "True" { toggle ag9. }. 7 | if ag8 = "True" { toggle ag8. }. 8 | if ag7 = "True" { toggle ag7. }. 9 | 10 | set splash to 1. 11 | if splash = 1 { run SC1. }. 12 | 13 | until exit = 1 14 | { 15 | if ag9 = "True" { set index to index - 1. set printflag to 1. toggle ag9. }. 16 | if ag8 = "True" { set index to index + 1. set printflag to 1. toggle ag8. }. 17 | if index < 0 { set index to 4. }. 18 | if index > 4 { set index to 0. }. 19 | if ag7 = "True" 20 | { 21 | toggle ag7. 22 | if index = 0 { if status = "PRELAUNCH" { run a1. }. set printflag to 1. }. 23 | if index = 1 { if status = "ORBITING" { run Transfer. }. set printflag to 1. }. 24 | if index = 2 { set printflag to 1. }. 25 | if index = 3 { if status = "ORBITING" OR status = "FLYING" { run lp. }. set printflag to 1. }. 26 | if index = 4 { set exit to 1. }. 27 | }. 28 | if printflag = 1 29 | { 30 | clearscreen. 31 | print "Welcome to Space Computer v1.0" at (10,0). 32 | print "--------------------------------------------------" at (0,1). 33 | print "Select a program from the list." at (10,2). 34 | print "Use action group 9 to select up." at (9,4). 35 | print "Use action group 8 to select down." at (8,6). 36 | print "Use action group 7 to confirm your selection." at (3,8). 37 | print "--------------------------------------------------" at (0,9). 38 | print "Launch to Orbit" at (18,12). 39 | print "Alter Orbit" at (20,14). 40 | print "Execute Node" at (19,16). 41 | print "Land From Orbit" at (18,18). 42 | print "EXIT" at (23,20). 43 | if index = 0 { print "======>" at (7,12). print "<======" at (36,12). }. 44 | if index = 1 { print "======>" at (7,14). print "<======" at (36,14). }. 45 | if index = 2 { print "======>" at (7,16). print "<======" at (36,16). }. 46 | if index = 3 { print "======>" at (7,18). print "<======" at (36,18). }. 47 | if index = 4 { print "======>" at (7,20). print "<======" at (36,20). }. 48 | set printflag to 0. 49 | }. 50 | }. 51 | clearscreen. 52 | print "Have A Nice Day!". -------------------------------------------------------------------------------- /old/example_lib_pid.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | clearscreen. 3 | SAS on. 4 | set seekAlt to 25. 5 | 6 | print "A simple test of libPID.". 7 | print "Does a hover script at " + seekAlt + "m AGL.". 8 | print " ". 9 | print " Try flying around with WASD while it hovers.". 10 | print " (steering is unlocked. under your control.". 11 | print " ". 12 | print " Keys:". 13 | print " Action Group 1 : -10 hover altitude". 14 | print " Action Group 2 : -1 hover altitude". 15 | print " Action Group 3 : +1 hover altitude". 16 | print " Action Group 4 : +10 hover altitude". 17 | print " LANDING LEGS : Deploy to exit script". 18 | print " ". 19 | print " Seek ALT:RADAR = ". 20 | print " Cur ALT:RADAR = ". 21 | print " ". 22 | print " Throttle = ". 23 | 24 | // load the functions I'm using: 25 | run lib_PID. 26 | 27 | on ag1 { set seekAlt to seekAlt -10. preserve. }. 28 | on ag2 { set seekAlt to seekAlt - 1. preserve. }. 29 | on ag3 { set seekAlt to seekAlt + 1. preserve. }. 30 | on ag4 { set seekAlt to seekAlt +10. preserve. }. 31 | 32 | set ship:control:pilotmainthrottle to 0. 33 | 34 | // hit "stage" until there's an active engine: 35 | until ship:availablethrust > 0 { 36 | wait 0.5. 37 | stage. 38 | }. 39 | 40 | // Call to update the display of numbers: 41 | function display_block { 42 | parameter startCol, startRow. // define where the block of text should be positioned 43 | 44 | print round(seekAlt,2) + "m " at (startCol,startRow). 45 | print round(alt:radar,2) + "m " at (startCol,startRow+1). 46 | print round(myth,3) + " " at (startCol,startRow+3). 47 | }. 48 | 49 | // thOffset is how far off from midThrottle to be. 50 | // It's the value I'll be letting the PID controller 51 | // adjust for me. 52 | set myTh to 0. 53 | 54 | lock throttle to myTh. 55 | 56 | set hoverPID to PID_init( 0.05, 0.01, 0.1, 0, 1 ). // Kp, Ki, Kd, min, max control range vals. 57 | 58 | gear on. gear off. // on then off because of the weird KSP 'have to hit g twice' bug. 59 | 60 | until gear { 61 | set myTh to PID_seek( hoverPID, seekAlt, alt:radar ). 62 | display_block(18,13). 63 | wait 0.001. 64 | }. 65 | 66 | set ship:control:pilotmainthrottle to throttle. 67 | print "------------------------------". 68 | print "Releasing control back to you.". 69 | print "------------------------------". 70 | 71 | -------------------------------------------------------------------------------- /old/lib_exec.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | // Originally developed by abenkovskii 3 | 4 | // The mess below declares a function execute that executes a command from it's string representation. 5 | // I'm 95% sure there is no easy way to achieve this behavior in the current version of kOS (0.17). 6 | // All easier solutions I know fail to work as expected in a range of special cases. 7 | // If you think you know an easy way to implement it there are unit tests 8 | // in KSLib/unit_tests/lib_exec to test your implementation. 9 | // See "run is weird" for more detailed information: [link is coming soon (tm)] 10 | 11 | @LAZYGLOBAL OFF. 12 | 13 | log "" to _execute.internal. 14 | delete _execute.internal. 15 | log "" to _execute.tmp. 16 | delete _execute.tmp. 17 | log "" to _execute.init. 18 | delete _execute.init. 19 | 20 | log "{}" to _execute.tmp. 21 | log "run _execute.tmp." to _execute.internal. 22 | 23 | global _execute__empty_string is "". 24 | 25 | log 26 | "run _execute.internal. " + 27 | "function execute" + 28 | "{" + 29 | "parameter command. " + 30 | "log _execute__empty_string to _execute.tmp. " + 31 | "delete _execute.tmp. " + 32 | "log command to _execute.tmp. " + 33 | "run _execute.internal. " + 34 | "log _execute__empty_string to _execute.tmp. " + 35 | "delete _execute.tmp. " + 36 | "}" 37 | to _execute.init. 38 | run _execute.init. 39 | 40 | delete _execute.init. 41 | delete _execute.internal. 42 | delete _execute.tmp. 43 | 44 | // evaluate an expression 45 | // Attention: evaluate() is implemented using execute(). 46 | // You'll have to copy the mess above or it won't work 47 | function evaluate 48 | { 49 | parameter expression. 50 | 51 | execute("global _evaluate_result is " + expression + "."). 52 | local result is _evaluate_result. 53 | unset _evaluate_result. 54 | return result. 55 | } 56 | 57 | function evaluate_function 58 | { 59 | parameter 60 | function_name, 61 | parameter_list. 62 | 63 | global _exec__param_list is parameter_list. 64 | local expression is "". 65 | local separator is "". 66 | local index is 0. 67 | until index = parameter_list:length 68 | { 69 | set expression to expression + separator + "_exec__param_list[" + index + "]". 70 | set separator to ", ". 71 | set index to index + 1. 72 | } 73 | set expression to function_name + "(" + expression + ")". 74 | return evaluate(expression). 75 | } 76 | -------------------------------------------------------------------------------- /old/plane_tools.ks: -------------------------------------------------------------------------------- 1 | @lazyglobal off. 2 | 3 | function get_normal_vector { 4 | declare parameter inc. 5 | declare parameter lan. 6 | 7 | local minmus_r to minmus:position - kerbin:position. 8 | local minmus_v to minmus:velocity:orbit. 9 | 10 | local minmus_normal to vcrs(minmus_r, minmus_v). 11 | 12 | local delta_lan to lan - minmus:obt:lan. 13 | 14 | local target_normal to angleaxis(delta_lan, v(0,-1,0)) * minmus_normal. 15 | local target_dn to vcrs(target_normal,v(0,1,0)). 16 | 17 | local delta_inc to inc - minmus:obt:inclination. 18 | 19 | set target_normal to angleaxis(delta_inc,target_dn) * target_normal. 20 | 21 | return target_normal. 22 | }. 23 | 24 | function vector_at_longitude { 25 | declare parameter lan. 26 | 27 | local minmus_r to minmus:position - kerbin:position. 28 | local minmus_v to minmus:velocity:orbit. 29 | 30 | local minmus_normal to vcrs(minmus_r, minmus_v). 31 | 32 | local delta_lan to lan - minmus:obt:lan. 33 | 34 | local target_normal to angleaxis(delta_lan, v(0,-1,0)) * minmus_normal. 35 | 36 | return vcrs(v(0,1,0),target_normal). 37 | }. 38 | 39 | function relative_ascending_node { 40 | declare parameter reference_normal. 41 | declare parameter my_normal. 42 | 43 | return vcrs(my_normal, reference_normal). 44 | }. 45 | 46 | function warp_to_window_for_lan { 47 | declare parameter target_lan. 48 | 49 | local ascending_node to v(0,0,0). 50 | lock ascending_node to vector_at_longitude(target_lan). 51 | local descending_node to v(0,0,0). 52 | lock descending_node to vector_at_longitude(target_lan + 180). 53 | 54 | local target_node to v(0,0,0). 55 | local next_node_is to "". 56 | 57 | if vdot(ascending_node, ship:velocity:orbit) > 0 { 58 | lock target_node to ascending_node. 59 | set next_node_is to "ascending". 60 | } else { 61 | lock target_node to descending_node. 62 | set next_node_is to "descending". 63 | }. 64 | 65 | lock angle_to_node to vang(ship:position-kerbin:position,target_node). 66 | 67 | print "Launch window in " + angle_to_node + " minutes.". 68 | 69 | if angle_to_node > 10 { 70 | set warp to 4. 71 | wait until angle_to_node < 10. 72 | }. 73 | if angle_to_node > 2.5 { 74 | set warp to 3. 75 | wait until angle_to_node < 2.5. 76 | }. 77 | if angle_to_node > 1 { 78 | set warp to 1. 79 | wait until angle_to_node < 1. 80 | }. 81 | set warp to 0. 82 | return next_node_is. 83 | } 84 | -------------------------------------------------------------------------------- /old/master_hard.ks: -------------------------------------------------------------------------------- 1 | // Master executable: Hard tier 2 | 3 | @lazyglobal off. 4 | 5 | local target_ecc to 0.51. 6 | local target_sma to 6540000. 7 | local target_inc to 124. 8 | local target_lan to 87. 9 | local target_agp to 14. 10 | 11 | print "Orbital navigation parameters:". 12 | print "SMA: " + target_sma. 13 | print "Ecc: " + target_ecc. 14 | print "Inc: " + target_inc. 15 | print "LAN: " + target_lan. 16 | print "AgP: " + target_agp. 17 | 18 | print "Loading libraries.". 19 | copy lib_lazcalc from 0. 20 | run lib_lazcalc. 21 | copy utilities from 0. 22 | run utilities. 23 | copy plane_tools from 0. 24 | run plane_tools. 25 | 26 | print "Loading sequences.". 27 | copy ascent from 0. 28 | copy circularize from 0. 29 | copy spiral_out from 0. 30 | 31 | local target_pe_alt to (1 - target_ecc) * target_sma 32 | - ship:body:radius. 33 | local target_ap_alt to (1 + target_ecc) * target_sma 34 | - ship:body:radius. 35 | 36 | local parking_alt to max(target_pe_alt * 0.75, 100000). 37 | 38 | print "Target orbit is " + (target_ap_alt / 1000) + " x " 39 | + (target_pe_alt / 1000) + ".". 40 | print "Parking orbit at " + (parking_alt / 1000). 41 | 42 | print "Ascent sequence.". 43 | run ascent(target_inc, target_lan, parking_alt, 30, 2, 0.35). 44 | 45 | print "Circularizing at apoapsis". 46 | run circularize(target_inc). 47 | 48 | stage. 49 | 50 | print "Raising orbit.". 51 | run spiral_out(target_ap_alt, target_pe_alt, target_agp). 52 | 53 | set warp to 1. 54 | 55 | print "Estimated score:". 56 | 57 | local est_score_ecc to abs(round(ship:obt:eccentricity, 3) - target_ecc) * 100. 58 | print "Ecc " + ship:obt:eccentricity + "/" + target_ecc 59 | + " : " + est_score_ecc. 60 | 61 | local est_score_sma to abs(round(ship:obt:semimajoraxis) - target_sma) * 0.1. 62 | print "SMA " + ship:obt:semimajoraxis + "/" + target_sma 63 | + " : " + est_score_sma. 64 | 65 | local est_score_inc to abs(round(ship:obt:inclination, 3) - target_inc) * 100. 66 | print "Inc " + ship:obt:inclination + "/" + target_inc 67 | + " : " + est_score_inc. 68 | 69 | local est_score_lan to abs(round(ship:obt:lan, 2) - target_lan) * 10. 70 | print "LAN " + ship:obt:lan + "/" + target_lan 71 | + " : " + est_score_lan. 72 | 73 | local est_score_agp to abs(round(ship:obt:argumentofperiapsis, 2) 74 | - target_agp) * 10. 75 | print "AgP " + ship:obt:argumentofperiapsis + "/" + target_agp 76 | + " : " + est_score_agp. 77 | 78 | print "Total score: " + (est_score_ecc + est_score_sma + est_score_inc + 79 | est_score_lan + est_score_agp). 80 | -------------------------------------------------------------------------------- /maneuver.ks: -------------------------------------------------------------------------------- 1 | declare parameter stageLimit. 2 | 3 | run utility. 4 | 5 | lock throttle to 0. 6 | sas off. 7 | 8 | // grab our next node 9 | local mNode to nextnode. 10 | 11 | // figure out some information about it 12 | set burnDV to mNode:deltav. 13 | set burnDVMag to mNode:deltav:mag. 14 | set burnAcceleration to ship:maxthrust / ship:mass. 15 | set burnTime to burnDVMag / burnAcceleration. 16 | 17 | print "Aligning with maneuver prograde.". 18 | //sas on. 19 | lock steering to mNode:deltav. 20 | wait until vang(ship:facing:forevector, mNode:deltav) < 1. 21 | print "Ship aligned.". 22 | 23 | // warp to 30s before the burn time 24 | print "Maneuver burn scheduled for " + round(mNode:eta - (burnTime / 2), 1) + " s from now.". 25 | if(mNode:eta > 10) { 26 | print "Warping to 10s before start of burn.". 27 | warpto(time:seconds + mNode:eta - (burnTime / 2) - 10). 28 | print "Warp complete.". 29 | } 30 | 31 | // wait for it... 32 | print "Waiting to begin burn...". 33 | wait until (vang(ship:facing:forevector, mNode:deltav) < 1) or (mNode:eta <= (burnTime / 2)). 34 | warpto(time:seconds + mNode:eta - (burnTime / 2)). 35 | until mNode:eta <= (burnTime / 2) { 36 | clearscreen. 37 | print round(mNode:eta - (burnTime / 2), 1) + " s until burn...". 38 | wait 0.1. 39 | } 40 | //wait until mNode:eta <= (burnTime / 2). 41 | 42 | print "Burn is go!". 43 | lock throttle to 1. 44 | 45 | // wait until we get to 2s left 46 | until burnTime <= 2 { 47 | // autostage if necessary 48 | AutoStage(stageLimit, 10). 49 | 50 | // constantly update the acceleration and time left 51 | set burnAcceleration to ship:maxthrust / ship:mass. 52 | if burnAcceleration > 0.001 { 53 | set burnTime to mNode:deltav:mag / burnAcceleration. 54 | } 55 | wait 0.1. 56 | } 57 | 58 | print "Burn almost complete, throttling back". 59 | until false { 60 | // autostage if necessary 61 | AutoStage(stageLimit, 10). 62 | 63 | // cut the throttle completely if the node prograde flips around and we've somehow passed it! 64 | if(vdot(burnDV, mNode:deltav) < 0) { 65 | lock throttle to 0. 66 | break. 67 | } 68 | 69 | // throttle back linearly 70 | set burnAcceleration to ship:maxthrust / ship:mass. 71 | if(burnAcceleration > 0.001) { 72 | lock throttle to min(mNode:deltav:mag / burnAcceleration, 1). 73 | } 74 | else { 75 | lock throttle to 1. 76 | } 77 | 78 | // if we're close, hold tight 79 | if(mNode:deltav:mag <= 0.1) { 80 | print "Finalizing burn.". 81 | wait until vdot(burnDV, mNode:deltav) < 0.5. 82 | break. 83 | } 84 | wait 0.01. 85 | } 86 | set ship:control:pilotmainthrottle to 0. 87 | lock throttle to 0. 88 | unlock steering. 89 | unlock throttle. 90 | 91 | print "Maneuver burn complete!". 92 | remove mNode. 93 | sas on. -------------------------------------------------------------------------------- /old/spiral_out.ks: -------------------------------------------------------------------------------- 1 | // In-plane raise from parking orbit to final orbit. 2 | 3 | @lazyglobal off. 4 | 5 | parameter target_ap_alt. 6 | parameter target_pe_alt. 7 | parameter target_agp. 8 | 9 | lock my_normal_vector to vcrs( 10 | ship:position - kerbin:position, 11 | ship:velocity:orbit). 12 | 13 | lock periapsis_dir to angleaxis(target_agp, my_normal_vector) * 14 | relative_ascending_node(v(0,-1,0),my_normal_vector). 15 | 16 | lock apoapsis_dir to periapsis_dir * -1. 17 | 18 | lock angle_to_periapsis to vang( 19 | ship:position - kerbin:position, periapsis_dir). 20 | 21 | lock angle_to_apoapsis to vang( 22 | ship:position - kerbin:position, apoapsis_dir). 23 | 24 | 25 | print "Waiting for target argument of periapsis.". 26 | 27 | lock steering to prograde. 28 | 29 | set warp to 4. 30 | wait until angle_to_periapsis < 5 and vdot(ship:velocity:orbit, periapsis_dir) > 0. 31 | set warp to 1. 32 | wait until angle_to_periapsis < 2. 33 | set warp to 0. 34 | wait until angle_to_periapsis < 1. 35 | 36 | print "Initial burn to establish periapsis.". 37 | 38 | lock throttle to 1. 39 | 40 | wait until ship:obt:apoapsis > target_ap_alt or 41 | (ship:obt:argumentofperiapsis > target_agp + 0.004 and 42 | ship:obt:argumentofperiapsis < target_agp + 0.005). 43 | 44 | lock throttle to 0. 45 | 46 | lock pe_alt_limit to min(target_pe_alt - 50, ship:obt:apoapsis * 0.95). 47 | 48 | print "Spiral out.". 49 | 50 | until ship:obt:apoapsis > target_ap_alt - 50 and 51 | ship:obt:periapsis > target_pe_alt - 50 { 52 | 53 | if ship:obt:periapsis < pe_alt_limit { 54 | set warp to 5. 55 | wait until eta:apoapsis < 300. 56 | set warp to 4. 57 | wait until eta:apoapsis < 90. 58 | set warp to 1. 59 | wait until eta:apoapsis < 40. 60 | set warp to 0. 61 | 62 | wait until eta:apoapsis < 20. 63 | lock throttle to min(1, (target_pe_alt - ship:obt:periapsis)/2000). 64 | 65 | wait until ship:obt:periapsis > pe_alt_limit or ( 66 | eta:apoapsis > 20 and abs(ship:obt:argumentofperiapsis 67 | - target_agp) < 0.005). 68 | lock throttle to 0. 69 | }. 70 | 71 | if ship:obt:apoapsis < target_ap_alt - 50 { 72 | set warp to 5. 73 | wait until eta:periapsis < 300. 74 | set warp to 4. 75 | wait until eta:periapsis < 90. 76 | set warp to 1. 77 | wait until eta:periapsis < 40. 78 | set warp to 0. 79 | 80 | wait until eta:periapsis < 20. 81 | lock throttle to min(1, (target_ap_alt - ship:obt:periapsis) / 2000). 82 | 83 | wait until ship:obt:apoapsis > target_ap_alt - 50 or ( 84 | eta:periapsis > 20 and 85 | ship:obt:argumentofperiapsis > target_agp + 0.004 and 86 | ship:obt:argumentofperiapsis < target_agp + 0.005). 87 | lock throttle to 0. 88 | }. 89 | }. 90 | -------------------------------------------------------------------------------- /old/example_lib_term_clock.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | // Original starting work by Github user: Dunbaratu 3 | 4 | // Example that uses some of the lib_term line drawing 5 | // routines to make a Kerbal clock showing the current 6 | // kerbin time. 7 | // 8 | // Designed to show off the circle and line drawing primities 9 | // of lib_term. 10 | 11 | run lib_term. 12 | clearscreen. 13 | 14 | 15 | // Change these to fiddle with 16 | // where it appears and how big it is: 17 | set centerX to 17. 18 | set centerY to 17. 19 | set clockRadius to 15. 20 | 21 | // Draw the clock face: 22 | // ------------------- 23 | char_circle(":", centerX, centerY, clockRadius). 24 | 25 | // Draw the 6 Hour markers: 26 | set h to 0. 27 | set rad to clockRadius. 28 | until h > 5 { 29 | print "*" at (centerX+rad*cos(60*h-90), centerY+rad*sin(60*h-90)). 30 | set h to h + 1. 31 | }. 32 | set h to 0. 33 | set rad to clockRadius+1. 34 | until h > 5 { 35 | print h at (centerX+rad*cos(60*h-90), centerY+rad*sin(60*h-90)). 36 | set h to h + 1. 37 | }. 38 | 39 | // Label the clock: 40 | print "Kerbin Clock" at (centerX+clockRadius+2, centerY-clockRadius). 41 | print "Watch the hands." at (centerX+clockRadius+2, 2+centerY-clockRadius). 42 | print "Use time warp " at (centerX+clockRadius+2, 4+centerY-clockRadius). 43 | print "to see it move " at (centerX+clockRadius+2, 5+centerY-clockRadius). 44 | print "faster." at (centerX+clockRadius+2, 6+centerY-clockRadius). 45 | print "Ctrl-C to quit." at (centerX+clockRadius+2, 8+centerY-clockRadius). 46 | 47 | // Loop forever, drawing the hands. 48 | until false { 49 | set h to time:hour + (time:minute/60). 50 | set m to time:minute. 51 | set s to time:second. 52 | 53 | // Draw hands in current position: 54 | drawHand( "H", centerX, centerY, 60*h, 2, clockRadius*2/3). 55 | drawHand( "M", centerX, centerY, 6*m, 1, clockRadius*7/8). 56 | drawHand( "s", centerX, centerY, 6*s, 0, clockRadius*7/8). 57 | 58 | // allow 1 second to pass: 59 | set ts to time:seconds. 60 | wait until time:seconds > ts+1. 61 | 62 | // Erase hands in current position: 63 | drawHand( " ", centerX, centerY, 60*h, 2, clockRadius*2/3). 64 | drawHand( " ", centerX, centerY, 6*m, 1, clockRadius*7/8). 65 | drawHand( " ", centerX, centerY, 6*s, 0, clockRadius*7/8). 66 | }. 67 | 68 | function drawHand { 69 | parameter 70 | ch, // char to draw with. 71 | x0, // center x coord. 72 | y0, // center y coord. 73 | deg, // degrees where it is now on the clock (0 = straight up) 74 | width, // width start the hand line. 75 | rMax. // max radius to stop the hand line. 76 | 77 | local px1 is rMax*(cos(deg-90))+x0. 78 | local py1 is rMax*(sin(deg-90))+y0. 79 | local px0 is width*(cos(deg-180))+x0. 80 | local py0 is width*(sin(deg-180))+y0. 81 | local px2 is width*(cos(deg))+x0. 82 | local py2 is width*(sin(deg))+y0. 83 | char_line( ch, px0, py0, px1, py1). 84 | char_line( ch, px1, py1, px2, py2). 85 | char_line( ch, px2, py2, px0, py0). 86 | }. 87 | -------------------------------------------------------------------------------- /old/lib_pid.ks: -------------------------------------------------------------------------------- 1 | // This file is distributed under the terms of the MIT license, (c) the KSLib team 2 | 3 | @LAZYGLOBAL off. 4 | 5 | function PID_init { 6 | parameter 7 | Kp, // gain of position 8 | Ki, // gain of integral 9 | Kd, // gain of derivative 10 | cMin, // the bottom limit of the control range (to protect against integral windup) 11 | cMax. // the the upper limit of the control range (to protect against integral windup) 12 | 13 | local SeekP is 0. // desired value for P (will get set later). 14 | local P is 0. // phenomenon P being affected. 15 | local I is 0. // crude approximation of Integral of P. 16 | local D is 0. // crude approximation of Derivative of P. 17 | local oldT is -1. // (old time) start value flags the fact that it hasn't been calculated 18 | local oldInput is 0. // previous return value of PID controller. 19 | 20 | // Because we don't have proper user structures in kOS (yet?) 21 | // I'll store the PID tracking values in a list like so: 22 | // 23 | local PID_array is list(Kp, Ki, Kd, cMin, cMax, SeekP, P, I, D, oldT, oldInput). 24 | 25 | return PID_array. 26 | }. 27 | 28 | function PID_seek { 29 | parameter 30 | PID_array, // array built with PID_init. 31 | seekVal, // value we want. 32 | curVal. // value we currently have. 33 | 34 | // Using LIST() as a poor-man's struct. 35 | 36 | local Kp is PID_array[0]. 37 | local Ki is PID_array[1]. 38 | local Kd is PID_array[2]. 39 | local cMin is PID_array[3]. 40 | local cMax is PID_array[4]. 41 | local oldS is PID_array[5]. 42 | local oldP is PID_array[6]. 43 | local oldI is PID_array[7]. 44 | local oldD is PID_array[8]. 45 | local oldT is PID_array[9]. // Old Time 46 | local oldInput is PID_array[10]. // prev return value, just in case we have to do nothing and return it again. 47 | 48 | local P is seekVal - curVal. 49 | local D is oldD. // default if we do no work this time. 50 | local I is oldI. // default if we do no work this time. 51 | local newInput is oldInput. // default if we do no work this time. 52 | 53 | local t is time:seconds. 54 | local dT is t - oldT. 55 | 56 | if oldT < 0 { 57 | // I have never been called yet - so don't trust any 58 | // of the settings yet. 59 | } else { 60 | if dT > 0 { // Do nothing if no physics tick has passed from prev call to now. 61 | set D to (P - oldP)/dT. // crude fake derivative of P 62 | local onlyPD is Kp*P + Kd*D. 63 | if (oldI > 0 or onlyPD > cMin) and (oldI < 0 or onlyPD < cMax) { // only do the I turm when within the control range 64 | set I to oldI + P*dT. // crude fake integral of P 65 | }. 66 | set newInput to onlyPD + Ki*I. 67 | }. 68 | }. 69 | 70 | set newInput to max(cMin,min(cMax,newInput)). 71 | 72 | // remember old values for next time. 73 | set PID_array[5] to seekVal. 74 | set PID_array[6] to P. 75 | set PID_array[7] to I. 76 | set PID_array[8] to D. 77 | set PID_array[9] to t. 78 | set PID_array[10] to newInput. 79 | 80 | return newInput. 81 | }. 82 | -------------------------------------------------------------------------------- /old/ltoa.ks: -------------------------------------------------------------------------------- 1 | // launch to orbit (w/ atmosphere) 2 | if body:name = "Kerbin" { 3 | // trajectory parameters 4 | set gt0 to 1000. 5 | set gt1 to 50000. 6 | set pitch0 to 0. 7 | set pitch1 to 90. 8 | // velocity parameters 9 | set maxq to 7000. 10 | set ha to 70000. 11 | } 12 | print "Launch to orbit: " + time:calendar + ", " + time:clock. 13 | set tset to 1. 14 | lock throttle to tset. 15 | lock steering to up + R(0, 0, -180). 16 | print "T-1 All systems GO. Ignition!". 17 | set arramp to alt:radar + 25. // ramp altitude 18 | when alt:radar > arramp then { 19 | print "T+" + round(missiontime) + " Liftoff.". 20 | } 21 | when alt:radar > gt0 then { 22 | print "T+" + round(missiontime) + " Beginning gravity turn.". 23 | } 24 | wait 1. 25 | print "T+" + round(missiontime) + " Ignition.". 26 | stage. 27 | // control speed and attitude 28 | set pitch to 0. 29 | until altitude > ha or apoapsis > lorb { 30 | set ar to alt:radar. 31 | // control attitude 32 | if ar > gt0 and ar < gt1 { 33 | set arr to (ar - gt0) / (gt1 - gt0). 34 | set pda to (cos(arr * 180) + 1) / 2. 35 | set pitch to pitch1 * ( pda - 1 ). 36 | lock steering to up + R(0, pitch, -180). 37 | print "pitch: " + round(90+pitch) + " " at (20,33). 38 | } 39 | if ar > gt1 { 40 | lock steering to up + R(0, pitch, -180). 41 | } 42 | // dynamic pressure q 43 | set vsm to velocity:surface:mag. 44 | set exp to -altitude/sh. 45 | set ad to ad0 * euler^exp. // atmospheric density 46 | set q to 0.5 * ad * vsm^2. 47 | print "q: " + round(q) + " " at (20,34). 48 | // calculate target velocity 49 | set vl to maxq*0.9. 50 | set vh to maxq*1.1. 51 | if q < vl { set tset to 1. } 52 | if q > vl and q < vh { set tset to (vh-q)/(vh-vl). } 53 | if q > vh { set tset to 0. } 54 | print "alt:radar: " + round(ar) + " " at (0,33). 55 | print "throttle: " + round(tset,2) + " " at (0,34). 56 | print "apoapis: " + round(apoapsis/1000) at (0,35). 57 | print "periapis: " + round(periapsis/1000) at (20,35). 58 | wait 0.1. 59 | } 60 | set tset to 0. 61 | print " " at (0,33). 62 | print " " at (20,33). 63 | print " " at (20,34). 64 | if altitude < ha { 65 | print "T+" + round(missiontime) + " Waiting to leave atmosphere". 66 | lock steering to up + R(0, pitch, 0). // roll for orbital orientation 67 | // thrust to compensate atmospheric drag losses 68 | until altitude > ha { 69 | // calculate target velocity 70 | if apoapsis >= lorb { set tset to 0. } 71 | if apoapsis < lorb { set tset to (lorb-apoapsis)/(lorb*0.01). } 72 | print "throttle: " + round(tset,2) + " " at (0,34). 73 | print "apoapis: " + round(apoapsis/1000,2) at (0,35). 74 | print "periapis: " + round(periapsis/1000,2) at (20,35). 75 | wait 0.1. 76 | } 77 | } 78 | print " " at (0,33). 79 | print " " at (0,34). 80 | print " " at (0,35). 81 | lock throttle to 0. 82 | // aponode works only in vacuum as it uses ship v to calc apoapsis velocity 83 | run aponode(lorb). 84 | run exenode. 85 | -------------------------------------------------------------------------------- /old/lib_lazcalc.ks: -------------------------------------------------------------------------------- 1 | //=====LAUNCH AZIMUTH CALCULATOR===== 2 | //~~LIB_LAZcalc.ks~~ 3 | //~~Version 1.0~~ 4 | 5 | //To use: RUN LAZcalc.ks. SET myLaunchAzimuth TO LAZcalc([desired circular orbit altitude in kilometers],[desired orbital inclination; negative if launching from descending node, positive otherwise]) 6 | 7 | @LAZYGLOBAL OFF. 8 | 9 | FUNCTION LAZcalc { 10 | 11 | //#open Variable Declaration 12 | 13 | DECLARE PARAMETER desiredAlt. //Altitude of desired target orbit (circular) 14 | DECLARE PARAMETER desiredInc. //Inclination of desired target orbit 15 | 16 | LOCAL launchNode TO "A". //Whether the launch should be at the ascending or descending node. Defaults to ascending. 17 | LOCAL currentLatitude TO SHIP:LATITUDE. //Pulls the current latitude to avoid having a slightly different latitude used for different parts of the calculation due to them occuring in different physics ticks 18 | LOCAL inertialAzimuth TO -1. //Launch azimuth before taking into account the rotation of the planet 19 | LOCAL launchAzimuth TO -1. //Launch azimuth after taking into account the rotation of the planet 20 | LOCAL targetOrbVel TO -1. //Orbital velocity of the desired target orbit 21 | LOCAL targetOrbSMA TO -1. //Semi-major axis of the desired target orbit 22 | LOCAL equatorialVel TO -1. //Velocity of the planet's equator 23 | LOCAL VXRot TO -1. 24 | LOCAL VYRot TO -1. 25 | 26 | //#close Variable Declaration 27 | 28 | //#open Input Sterilization 29 | 30 | //Orbital altitude can't be less than sea level 31 | IF desiredAlt <= 0 { 32 | PRINT "Target altitude cannot be below sea level". 33 | SET launchAzimuth TO 1/0. //Throws error 34 | }. 35 | 36 | //Orbital inclination can't be less than launch latitude or greater than 180 - launch latitude 37 | IF ABS(desiredInc) < ABS(currentLatitude) { 38 | SET desiredInc TO ABS(currentLatitude). 39 | HUDTEXT("Inclination impossible from current latitude, setting inclination to latitude, eastward launch", 10, 2, 30, RED, FALSE). 40 | 41 | } ELSE IF ABS(desiredInc) > (180 - ABS(currentLatitude)) { 42 | SET desiredInc TO (180 - ABS(currentLatitude)). 43 | HUDTEXT("Inclination impossible from current latitude, setting inclination to latitude, westward launch", 10, 2, 30, RED, FALSE). 44 | }. 45 | 46 | IF desiredInc < 0 { 47 | SET launchNode TO "D". 48 | SET desiredInc TO ABS(desiredInc). 49 | }. 50 | 51 | //#close Input Sterilization 52 | 53 | //#open Calculations 54 | 55 | SET desiredAlt TO desiredAlt * 1000. //Converts to kilometers 56 | SET targetOrbSMA TO desiredAlt + BODY:RADIUS. 57 | SET targetOrbVel TO SQRT(BODY:MU / (targetOrbSMA)). 58 | SET equatorialVel TO (2 * CONSTANT():PI * BODY:RADIUS) / BODY:ROTATIONPERIOD. 59 | SET inertialAzimuth TO ARCSIN(COS(desiredInc) / COS(currentLatitude)). 60 | SET VXRot TO (targetOrbVel * SIN(inertialAzimuth)) - (equatorialVel * COS(currentLatitude)). 61 | SET VYRot TO (targetOrbVel * COS(inertialAzimuth)). 62 | SET launchAzimuth TO ARCTAN(VXRot / VYRot). 63 | 64 | //#close Calculations 65 | 66 | //#open Output 67 | 68 | IF launchNode = "D" { 69 | SET launchAzimuth TO 180 - launchAzimuth. 70 | }. 71 | 72 | IF launchAzimuth < 0 { 73 | SET launchAzimuth TO 360 + launchAzimuth. //Converts negative degrees from north into heading 74 | }. 75 | 76 | RETURN launchAzimuth. 77 | 78 | //#close Output 79 | 80 | }. //FUNCTION LAZcalc -------------------------------------------------------------------------------- /ascent.ks: -------------------------------------------------------------------------------- 1 | declare parameter desiredAltitude. 2 | declare parameter desiredHeading. 3 | declare parameter stageLimit. 4 | declare parameter targetTWR. 5 | 6 | run utility. 7 | 8 | print "Prepare for launch.". 9 | 10 | lock throttle to 1. 11 | print "Throttle up.". wait 0.1. 12 | set startRoll to ship:facing:roll. 13 | lock steering to up + r(0, 0, startRoll). 14 | print "Controls locked skyward.". 15 | 16 | // countdown 17 | print "Launch preparations complete.". 18 | //print "Launching in:". 19 | set countdown to 5. 20 | until countdown < 1 { 21 | //print " " + countdown. 22 | hudtext("Launching in " + countdown + "...", 1, 2, 50, white, true). 23 | set countdown to countdown - 1. 24 | wait 1. 25 | } 26 | 27 | print "Firing main engines!". 28 | stage. 29 | 30 | // wait for confirmed lifoff 31 | wait until altitude > 100. 32 | print "We have liftoff!". 33 | 34 | lock pitch to -5 * (ship:verticalspeed / 100). 35 | lock steering to up + r(0, pitch, 180). 36 | 37 | // don't do anything until we get high enough 38 | wait until ship:verticalspeed > 100. 39 | print "Pitchover maneuver complete!". 40 | 41 | //// wait until pitch over maneuver 42 | //wait until altitude > 500. 43 | //print "Beginning pitch over maneuver". 44 | //set pitchOverPitch to 85. 45 | //lock steering to heading(desiredHeading, pitchOverPitch). 46 | // 47 | //// when the pitch-over is complete, lock our steering to prograde 48 | //when ship:facing:pitch <= (pitchOverPitch + 0.1) then { 49 | // when vang(ship:facing:forevector, ship:srfprograde:forevector) < 0.5 then { 50 | // //lock steering to heading(desiredHeading, ship:srfprograde:pitch). 51 | // lock steering to prograde. 52 | // print "Pitch over maneuver complete.". 53 | // } 54 | //} 55 | 56 | //set targetSpeed to sqrt(ship:body:mu / (desiredAltitude + ship:body:radius)). 57 | 58 | // limit the throttle 59 | print "Ascending to " + round(desiredAltitude / 1000, 1) + " km.". 60 | until ship:apoapsis >= desiredAltitude { 61 | clearscreen. 62 | 63 | // autostage if necessary 64 | AutoStage(stageLimit, 10). 65 | 66 | // control the steering 67 | //set p to EllipticalPitch(ship:apoapsis, desiredAltitude). 68 | //set p to EllipticalPitch(ship:velocity:orbit:mag, targetSpeed). 69 | //lock steering to heading(desiredHeading, p). 70 | if(ship:altitude < 35000) { 71 | //lock steering to ship:srfprograde. 72 | lock pitch to -1 * (vang(ship:up:vector, ship:srfprograde:forevector)). 73 | if(pitch < -45) { 74 | lock pitch to -45. 75 | } 76 | } 77 | else { 78 | //lock steering to ship:prograde. 79 | lock pitch to -1 * (vang(ship:up:vector, ship:prograde:forevector)). 80 | if(pitch < -80) { 81 | lock pitch to -80. 82 | } 83 | } 84 | print "Pitch: " + pitch. 85 | print "AoA: " + vang(ship:srfprograde:forevector, ship:facing:forevector). 86 | //lock steering to up + r(0, 90 - EllipticalPitch(ship:apoapsis, desiredAltitude), startRoll). 87 | 88 | // control the throttle 89 | print "Max thrust: " + ship:maxthrust. 90 | if(ship:maxthrust > 0.1 and ship:altitude <= 35000) { 91 | set rAlt to ship:altitude + ship:body:radius. 92 | print "Orbital radius: " + rAlt. 93 | set gAlt to ship:body:mu / rAlt / rAlt. 94 | print "Local gravity: " + gAlt. 95 | if(ship:maxthrust < 0.1) { 96 | set t to 1. 97 | } 98 | else { 99 | set t to (targetTWR * gAlt * ship:mass / ship:maxthrust). 100 | } 101 | print "Throttle: " + t. 102 | lock throttle to min(max(t, 0), 1). 103 | } 104 | else { 105 | lock throttle to 1. 106 | } 107 | 108 | wait 0.1. 109 | } 110 | unlock throttle. 111 | lock throttle to 0. 112 | set ship:control:pilotmainthrottle to 0. 113 | print "Ascent complete.". -------------------------------------------------------------------------------- /old/ascent.ks: -------------------------------------------------------------------------------- 1 | // ascent.ks: launch to designated orbital plane 2 | 3 | @lazyglobal off. 4 | 5 | declare parameter target_inc. 6 | declare parameter target_lan. 7 | declare parameter target_alt. 8 | 9 | declare parameter turn_start_speed. 10 | declare parameter turn_angle. 11 | 12 | declare parameter initial_throttle. 13 | 14 | local pitch_ramp_begin_alt to 20000. 15 | local pitch_ramp_end_alt to 40000. 16 | 17 | // Sometimes I forget whether I'm passing a throttle as a float or a percent. 18 | if initial_throttle > 1 { 19 | set initial_throttle to initial_throttle / 100. 20 | }. 21 | 22 | 23 | print "Waiting for launch window.". 24 | local next_node_is to warp_to_window_for_lan(target_lan). 25 | 26 | local launch_azimuth to 0. 27 | if next_node_is = "ascending" { 28 | set launch_azimuth to lazcalc(target_alt/1000, target_inc). 29 | } else { 30 | set launch_azimuth to lazcalc(target_alt/1000, -target_inc). 31 | } 32 | 33 | print "Launch azimuth: " + launch_azimuth. 34 | 35 | if launch_azimuth < 180 { 36 | lock great_circle_heading to arccos(cos(launch_azimuth) 37 | * cos(ship:latitude)). 38 | } else { 39 | lock great_circle_heading to 360 - arccos(cos(launch_azimuth) 40 | * cos(ship:latitude)). 41 | }. 42 | 43 | lock flight_path_angle_sfc to 90 - vang(ship:obt:velocity:surface, up:vector). 44 | lock flight_path_angle_obt to 90 - vang(ship:obt:velocity:orbit, up:vector). 45 | lock flight_path_azimuth to flight_path_azimuth_for(ship). 46 | 47 | lock target_orbit_normal to get_normal_vector(target_inc, target_lan). 48 | lock my_orbit_normal to vcrs( 49 | ship:position - kerbin:position, ship:velocity:orbit). 50 | lock rel_an to relative_ascending_node(target_orbit_normal, my_orbit_normal). 51 | lock rel_dn to relative_ascending_node(my_orbit_normal, target_orbit_normal). 52 | 53 | local srb to ship:partstagged("srb")[0]. 54 | local core_engine to ship:partstagged("core_engine")[0]. 55 | 56 | when srb:flameout then { 57 | // Jettison solids 58 | set srb to 0. 59 | lock throttle to 1. 60 | stage. 61 | 62 | when ship:altitude > 24000 then { 63 | // Jettison fairings 64 | stage. 65 | 66 | when core_engine:flameout then { 67 | // Stage core. 68 | set core_engine to 0. 69 | stage. 70 | }. 71 | }. 72 | }. 73 | 74 | lock throttle to initial_throttle. 75 | stage. 76 | print "Ignition.". 77 | wait 1. 78 | stage. 79 | print "Liftoff.". 80 | 81 | lock target_heading to great_circle_heading. 82 | lock target_pitch to 90. 83 | lock steering to heading(target_heading, target_pitch). 84 | 85 | wait until ship:airspeed > turn_start_speed. 86 | print "Initiating pitch maneuver.". 87 | lock target_pitch to 90 - turn_angle. 88 | 89 | wait until flight_path_angle_sfc < 90 - turn_angle. 90 | lock target_pitch to flight_path_angle_sfc. 91 | print "Pitch maneuver complete.". 92 | 93 | when ship:altitude > pitch_ramp_begin_alt then { 94 | lock pitch_ramp_mult to (ship:altitude - pitch_ramp_begin_alt) 95 | / (pitch_ramp_end_alt - pitch_ramp_begin_alt). 96 | lock target_pitch to mix(flight_path_angle_sfc, flight_path_angle_obt, 97 | pitch_ramp_mult). 98 | 99 | when ship:altitude > pitch_ramp_end_alt then { 100 | lock target_pitch to flight_path_angle_obt. 101 | }. 102 | }. 103 | 104 | wait until ship:altitude > 27000. 105 | print "Yaw uncage.". 106 | 107 | lock my_position to ship:position - kerbin:position. 108 | 109 | local target_node_is to 0. 110 | local target_node_loc to v(0,0,0). 111 | 112 | if vdot(my_position, target_orbit_normal) > 0 { 113 | set target_node_is to "ascending". 114 | lock target_node_loc to rel_an. 115 | } else { 116 | set target_node_is to "descending". 117 | lock target_node_loc to rel_dn. 118 | }. 119 | 120 | lock angle_to_target_node to vang(my_position, target_node_loc). 121 | 122 | lock pos_at_apoapsis to positionat( 123 | ship, time + eta:apoapsis) - kerbin:position. 124 | 125 | lock angle_to_apoapsis to vang(my_position, pos_at_apoapsis). 126 | 127 | lock angle_error to angle_to_target_node - angle_to_apoapsis. 128 | 129 | if target_node_is = "ascending" { 130 | lock yaw_offset to clamp_abs(-angle_error, 5). 131 | } else { 132 | lock yaw_offset to clamp_abs(angle_error, 5). 133 | }. 134 | 135 | lock target_heading to flight_path_azimuth + yaw_offset. 136 | 137 | wait until ship:apoapsis > target_alt. 138 | 139 | lock throttle to 0. 140 | set ship:control:pilotmainthrottle to 0. 141 | unlock throttle. 142 | 143 | lock steering to ship:srfprograde. 144 | wait until ship:altitude > 70000. 145 | 146 | toggle ag1. 147 | -------------------------------------------------------------------------------- /old/throttle_log_0_0001.ks: -------------------------------------------------------------------------------- 1 | # Throttle PID Tuning 2 | # Kp: 1 3 | # t acc throt 4 | 0.0399999991059303 0.976883498174648 0 5 | 0.159999996423721 0 1 6 | 0.219999995082617 0 1 7 | 0.299999993294477 4.44866888125973 0 8 | 0.359999991953373 4.45234564469265 0 9 | 0.439999990165234 0 1 10 | 0.499999988824129 0 1 11 | 0.57999998703599 4.45810566489829 0 12 | 0.639999985694885 4.46179899925771 0 13 | 0.719999983906746 0 1 14 | 0.779999982565641 0 1 15 | 0.839999981224537 4.46635227761304 0 16 | 0.919999979436398 0 1 17 | 0.979999978095293 0 1 18 | 1.05999997630715 4.47550454723887 0 19 | 1.11999997496605 4.47922804663321 0 20 | 1.17999997362494 0 1 21 | 1.23999997228384 0 1 22 | 1.3199999704957 4.48494706993433 0 23 | 1.39999996870756 0 1 24 | 1.45999996736646 0 1 25 | 1.51999996602535 4.49293463182764 0 26 | 1.57999996468425 4.49668871124207 0 27 | 1.63999996334314 0 1 28 | 1.69999996200204 0 1 29 | 1.75999996066093 4.50120698463898 0 30 | 1.8399999588728 0 1 31 | 1.89999995753169 0 1 32 | 1.95999995619059 4.50925886907124 0 33 | 2.01999995484948 4.51304105836512 0 34 | 2.07999995350838 0 1 35 | 2.13999995216727 0 1 36 | 2.19999995082617 4.51759912651448 0 37 | 2.25999994948506 4.52139604015931 0 38 | 2.31999994814396 0 1 39 | 2.37999994680285 0 1 40 | 2.43999994546175 4.52597479024773 0 41 | 2.51999994367361 0 1 42 | 2.57999994233251 0 1 43 | 2.6399999409914 4.5341239685499 0 44 | 2.71999993920326 0 1 45 | 2.77999993786216 0 1 46 | 2.85999993607402 4.54358691209993 0 47 | 2.91999993473291 4.54742895465505 0 48 | 2.97999993339181 0 1 49 | 3.03999993205071 0 1 50 | 3.0999999307096 4.55207352220058 0 51 | 3.1599999293685 4.55593117250504 0 52 | 3.21999992802739 0 1 53 | 3.27999992668629 0 1 54 | 3.33999992534518 4.56059637256447 0 55 | 3.41999992355704 0 1 56 | 3.47999992221594 0 1 57 | 3.53999992087483 4.56888438552622 0 58 | 3.59999991953373 4.57277165358137 0 59 | 3.65999991819263 0 1 60 | 3.73999991640449 4.57488188762194 0 61 | 3.79999991506338 4.57877812845219 0 62 | 3.85999991372228 0 1 63 | 3.93999991193414 4.58089456574361 0 64 | 4.019999910146 0 1 65 | 4.07999990880489 0 1 66 | 4.13999990746379 4.58926138845386 0 67 | 4.19999990612268 4.59318343392798 0 68 | 4.27999990433455 0 1 69 | 4.33999990299344 0 1 70 | 4.4199999012053 4.59938677559529 0 71 | 4.4799998998642 4.60332554988323 0 72 | 4.53999989852309 0 1 73 | 4.59999989718199 0 1 74 | 4.65999989584088 4.60810539799581 0 75 | 4.73999989405274 0 1 76 | 4.8199998922646 4.61393932437126 0 77 | 4.8799998909235 4.61790289146128 0 78 | 4.9399998895824 0 1 79 | 4.99999988824129 0 1 80 | 5.05999988690019 4.62271801903516 0 81 | 5.11999988555908 4.62669787258856 0 82 | 5.17999988421798 0 1 83 | 5.25999988242984 4.62887556358347 0 84 | 5.31999988108873 4.63286504974925 0 85 | 5.37999987974763 0 1 86 | 5.43999987840652 0 1 87 | 5.49999987706542 4.63771512308775 0 88 | 5.55999987572432 4.64172017286015 0 89 | 5.63999987393618 0 1 90 | 5.69999987259507 0 1 91 | 5.77999987080693 4.64807497092302 0 92 | 5.83999986946583 4.6520967291972 0 93 | 5.91999986767769 0 1 94 | 5.97999986633658 0 1 95 | 6.03999986499548 4.65713872432483 0 96 | 6.09999986365438 4.66117750666968 0 97 | 6.15999986231327 0 1 98 | 6.23999986052513 4.66339791907305 0 99 | 6.29999985918403 4.66744698842143 0 100 | 6.35999985784292 0 1 101 | 6.43999985605478 4.66967456450248 0 102 | 6.49999985471368 4.67373331527269 0 103 | 6.55999985337257 0 1 104 | 6.63999985158443 4.6759685145753 0 105 | 6.69999985024333 4.68003763464745 0 106 | 6.77999984845519 0 1 107 | 6.83999984711409 0 1 108 | 6.91999984532595 4.68650680863877 0 109 | 6.97999984398484 4.6905954778693 0 110 | 7.03999984264374 0 1 111 | 7.09999984130263 0 1 112 | 7.15999983996153 4.69558240421194 0 113 | 7.21999983862042 4.6996863375308 0 114 | 7.27999983727932 0 1 115 | 7.33999983593822 0 1 116 | 7.39999983459711 4.70469553668556 0 117 | 7.47999983280897 0 1 118 | 7.53999983146787 0 1 119 | 7.59999983012676 4.71354740316866 0 120 | 7.65999982878566 4.71768365281758 0 121 | 7.71999982744455 0 1 122 | 7.77999982610345 0 1 123 | 7.85999982431531 4.72412191049864 0 124 | 7.91999982297421 4.72827745561446 0 125 | 7.9799998216331 0 1 126 | 8.039999820292 0 1 127 | 8.11999981850386 4.73474919812752 0 128 | 8.19999981671572 0 1 129 | 8.25999981537461 0 1 130 | 8.33999981358647 4.74512092772343 0 131 | 8.39999981224537 4.74931446916212 0 132 | 8.45999981090426 0 1 133 | 8.51999980956316 0 1 134 | 8.57999980822206 4.75445159446186 0 135 | 8.65999980643392 0 1 136 | 8.71999980509281 0 1 137 | 8.77999980375171 4.76350882942998 0 138 | 8.8399998024106 4.76773583426388 0 139 | 8.8999998010695 0 1 140 | 8.97999979928136 4.77009643132449 0 141 | 9.03999979794025 4.77433411289118 0 142 | 9.09999979659915 0 1 143 | 9.15999979525805 0 1 144 | 9.21999979391694 4.77953408124599 0 145 | 9.27999979257584 4.78378933675355 0 146 | 9.33999979123473 0 1 147 | 9.39999978989363 0 1 148 | 9.47999978810549 4.79043544641336 0 149 | 9.53999978676438 4.79470974209685 0 150 | 9.61999978497624 0 1 151 | 9.67999978363514 0 1 152 | 9.73999978229404 4.80012304929076 0 153 | 9.8199997805059 0 1 154 | 9.87999977916479 0 1 155 | 9.95999977737665 4.81080011086576 0 156 | 10.0199997760355 4.81511178245366 0 157 | 10.0799997746944 0 1 158 | -------------------------------------------------------------------------------- /old/throttle_log_1_0.ks: -------------------------------------------------------------------------------- 1 | # Throttle PID Tuning 2 | # Kp: 1 3 | # t acc throt 4 | 0.0399999991059303 1.01715919959563 0 5 | 0.139999996870756 0 1 6 | 0.199999995529652 0 1 7 | 0.259999994188547 5.66124144352611 0 8 | 0.319999992847443 5.66675550671791 0 9 | 0.399999991059303 0 1 10 | 0.479999989271164 5.66987865993727 0 11 | 0.539999987930059 5.67540843495283 0 12 | 0.61999998614192 0 1 13 | 0.679999984800816 0 1 14 | 0.759999983012676 5.68408973518473 0 15 | 0.819999981671572 5.68964819026854 0 16 | 0.899999979883432 0 1 17 | 0.959999978542328 0 1 18 | 1.03999997675419 5.69837931968849 0 19 | 1.09999997541308 5.70396681545693 0 20 | 1.15999997407198 0 1 21 | 1.21999997273088 0 1 22 | 1.27999997138977 5.71069244217042 0 23 | 1.35999996960163 0 1 24 | 1.41999996826053 0 1 25 | 1.47999996691942 5.7226853755171 0 26 | 1.55999996513128 0 1 27 | 1.63999996334314 5.73096757540621 0 28 | 1.69999996200204 5.73662044916751 0 29 | 1.7799999602139 0 1 30 | 1.8399999588728 0 1 31 | 1.91999995708466 5.74552268035975 0 32 | 1.97999995574355 5.75120473504164 0 33 | 2.03999995440245 0 1 34 | 2.11999995261431 5.75426648222419 0 35 | 2.1799999512732 5.75996495247037 0 36 | 2.2399999499321 0 1 37 | 2.29999994859099 0 1 38 | 2.35999994724989 5.7668484743124 0 39 | 2.43999994546175 0 1 40 | 2.49999994412065 0 1 41 | 2.55999994277954 5.77909620569697 0 42 | 2.6399999409914 0 1 43 | 2.71999993920326 5.78756028807906 0 44 | 2.77999993786216 5.79332692152282 0 45 | 2.85999993607402 0 1 46 | 2.91999993473291 0 1 47 | 2.97999993339181 5.80050390536857 0 48 | 3.05999993160367 0 1 49 | 3.13999992981553 5.80903573061516 0 50 | 3.19999992847443 5.81484533032444 0 51 | 3.25999992713332 0 1 52 | 3.31999992579222 0 1 53 | 3.37999992445111 5.82188251777271 0 54 | 3.43999992311001 5.82771810638099 0 55 | 3.51999992132187 0 1 56 | 3.59999991953373 5.83109504591542 0 57 | 3.65999991819263 5.83694813149342 0 58 | 3.73999991640449 0 1 59 | 3.79999991506338 0 1 60 | 3.85999991372228 5.84425054457247 0 61 | 3.93999991193414 0 1 62 | 3.99999991059303 0 1 63 | 4.07999990880489 5.85881701767548 0 64 | 4.13999990746379 5.86472714544656 0 65 | 4.19999990612268 0 1 66 | 4.25999990478158 0 1 67 | 4.31999990344048 5.87190564684964 0 68 | 4.39999990165234 0 1 69 | 4.45999990031123 0 1 70 | 4.51999989897013 5.88463555343125 0 71 | 4.59999989718199 0 1 72 | 4.65999989584088 0 1 73 | 4.71999989449978 5.89742644799578 0 74 | 4.79999989271164 0 1 75 | 4.85999989137053 0 1 76 | 4.9399998895824 5.91228360587619 0 77 | 4.99999988824129 5.91830553057766 0 78 | 5.07999988645315 0 1 79 | 5.13999988511205 0 1 80 | 5.21999988332391 5.9278736576091 0 81 | 5.2799998819828 5.93392708722884 0 82 | 5.3399998806417 0 1 83 | 5.39999987930059 0 1 84 | 5.45999987795949 5.94130811043532 0 85 | 5.51999987661839 5.94738905808849 0 86 | 5.59999987483025 0 1 87 | 5.65999987348914 0 1 88 | 5.71999987214804 5.955029165863 0 89 | 5.7999998703599 0 1 90 | 5.85999986901879 0 1 91 | 5.91999986767769 5.96815106037577 0 92 | 5.97999986633658 5.97428756162418 0 93 | 6.05999986454844 0 1 94 | 6.11999986320734 0 1 95 | 6.1999998614192 5.9840635610363 0 96 | 6.2599998600781 5.99023323041468 0 97 | 6.31999985873699 0 1 98 | 6.37999985739589 0 1 99 | 6.43999985605478 5.99777615930449 0 100 | 6.49999985471368 6.00397467544726 0 101 | 6.55999985337257 0 1 102 | 6.61999985203147 0 1 103 | 6.69999985024333 6.01363104608254 0 104 | 6.75999984890223 6.01986217778441 0 105 | 6.83999984711409 0 1 106 | 6.89999984577298 0 1 107 | 6.97999984398484 6.02980752010692 0 108 | 7.03999984264374 6.03607168711037 0 109 | 7.1199998408556 0 1 110 | 7.17999983951449 0 1 111 | 7.25999983772635 6.04607709095943 0 112 | 7.31999983638525 6.05237495936536 0 113 | 7.37999983504415 0 1 114 | 7.43999983370304 0 1 115 | 7.49999983236194 6.06009908050053 0 116 | 7.5799998305738 0 1 117 | 7.65999982878566 6.06948671384348 0 118 | 7.73999982699752 0 1 119 | 7.79999982565641 0 1 120 | 7.85999982431531 6.08314824796556 0 121 | 7.91999982297421 6.089524003705 0 122 | 7.99999982118607 0 1 123 | 8.05999981984496 0 1 124 | 8.11999981850386 6.09759742258956 0 125 | 8.17999981716275 6.10400330212971 0 126 | 8.23999981582165 0 1 127 | 8.29999981448054 0 1 128 | 8.3799998126924 6.11402198605095 0 129 | 8.45999981090426 0 1 130 | 8.51999980956316 0 1 131 | 8.57999980822206 6.12789639255029 0 132 | 8.63999980688095 6.13436646372425 0 133 | 8.69999980553985 0 1 134 | 8.75999980419874 0 1 135 | 8.81999980285764 6.14233283790116 0 136 | 8.87999980151653 6.14883314111162 0 137 | 8.93999980017543 0 1 138 | 8.99999979883432 0 1 139 | 9.05999979749322 6.15684121849014 0 140 | 9.11999979615211 6.16337196582329 0 141 | 9.17999979481101 0 1 142 | 9.25999979302287 6.16705702788265 0 143 | 9.31999979168177 6.17360831398225 0 144 | 9.37999979034066 0 1 145 | 9.43999978899956 0 1 146 | 9.51999978721142 6.18387946079344 0 147 | 9.57999978587031 6.19046657673929 0 148 | 9.63999978452921 0 1 149 | 9.6999997831881 0 1 150 | 9.759999781847 6.19859567307408 0 151 | 9.8199997805059 6.20521436626124 0 152 | 9.87999977916479 0 1 153 | 9.93999977782369 0 1 154 | 10.0199997760355 6.21560167982841 0 155 | 10.0799997746944 6.2222561269546 0 156 | 10.1399997733533 0 1 157 | 10.2199997715652 6.22603078528597 0 158 | 10.2799997702241 6.23270634090931 0 159 | 10.339999768883 0 1 160 | 10.4199997670949 6.23649625790368 0 161 | 10.4799997657537 6.24319346936019 0 162 | 10.5599997639656 0 1 163 | 10.6199997626245 0 1 164 | 10.6799997612834 6.25173559253202 0 165 | 10.7399997599423 6.25846460963807 0 166 | 10.7999997586012 0 1 167 | 10.8599997572601 0 1 168 | -------------------------------------------------------------------------------- /old/launchcurve.ks: -------------------------------------------------------------------------------- 1 | // Reddit /r/kOS Accurate Orbit Competition 2 | // EASY TIER ENTRY 3 | 4 | // Reddit: /u/ScootyPuff-Sr 5 | // KSPForum: Justy 6 | // Written June 27 - July 4, 2015 7 | 8 | // Ideas liberally looted from: 9 | // * The tutorial page. 10 | // * /u/Ezekiel24r's gravity turn. 11 | 12 | // Variables 13 | SET countdown TO 5. 14 | SET aptarget TO 100000. 15 | SET att TO 90. 16 | SET padavoid TO 85. 17 | SET gravityturn TO FALSE. 18 | 19 | // Countdown sequence. 20 | PRINT "Counting down.". 21 | UNTIL countdown = 0 { 22 | IF countdown = 3 { 23 | LOCK THROTTLE TO 0.1. 24 | STAGE. 25 | PRINT "Main engine start.". 26 | } 27 | ELSE IF countdown = 2 { 28 | LOCK THROTTLE TO 1.0. 29 | SAS ON. 30 | PRINT "Throttle up. Internal guidance.". 31 | } 32 | ELSE { 33 | PRINT "..." + countdown. 34 | } 35 | SET countdown TO countdown - 1. 36 | WAIT 1. 37 | } 38 | 39 | // Launch! 40 | STAGE. 41 | PRINT "Liftoff!". 42 | 43 | // Autostaging. 44 | WHEN MAXTHRUST < 0.1 AND STAGE:READY THEN { 45 | PRINT "Stage separation.". 46 | STAGE. 47 | PRESERVE. 48 | } 49 | 50 | // Aluminum shower prevention maneuver. 51 | WAIT UNTIL ALT:RADAR > 100. 52 | LOCK STEERING TO HEADING(90,padavoid). 53 | PRINT "Begin pitch program.". 54 | SET gravityturn TO TRUE. 55 | 56 | // Fairing jettison trigger. 57 | WHEN SHIP:ALTITUDE >= 45000 THEN { 58 | FOR fairing IN SHIP:PARTSTAGGED("PayloadFairing") { 59 | fairing:GETMODULE("ModuleProceduralFairing"):DOACTION("deploy",TRUE). 60 | } 61 | PRINT "Altitude " + SHIP:ALTITUDE + ", payload fairing separation.". 62 | } 63 | 64 | // Engine cutoff. 65 | WHEN SHIP:APOAPSIS >= (aptarget - 6000) THEN { 66 | LOCK THROTTLE TO 0.05. 67 | PRINT "Approaching engine cutoff.". 68 | } 69 | WHEN SHIP:APOAPSIS >= (aptarget - 5000) THEN { 70 | LOCK THROTTLE TO 0.0. 71 | SET gravityturn to FALSE. 72 | PRINT "Engine cutoff. Coast to apokee.". 73 | IF SHIP:ALTITUDE < 70000 { 74 | LOCK STEERING TO SRFPROGRADE. 75 | PRINT "Coast drag reduction maneuver.". 76 | } 77 | } 78 | 79 | // 'Gravity' turn. 80 | UNTIL gravityturn = FALSE { 81 | SET att TO 90 - (SQRT(0.16*SHIP:ALTITUDE)). 82 | IF (att < padavoid) AND (att >= 0) { 83 | LOCK STEERING TO HEADING(90, att). 84 | } 85 | WHEN att < 0 THEN { 86 | LOCK STEERING TO HEADING(90,0). 87 | SET gravityturn TO FALSE. 88 | } 89 | WAIT 0.2. 90 | } 91 | 92 | // Atmospheric exit. 93 | WAIT UNTIL SHIP:ALTITUDE >= 70000. 94 | LOCK STEERING TO HEADING(90,0). 95 | PRINT "Aiming horizontal.". 96 | 97 | // Establish low orbit. 98 | // Velocity for a 100km circular orbit is 2245.8 m/s. 99 | // 100 | 101 | WAIT 2. 102 | SET WARP TO 2. 103 | WAIT UNTIL ETA:APOAPSIS <= 30. 104 | SET WARP TO 0. 105 | 106 | WAIT UNTIL ETA:APOAPSIS <= 10. 107 | LOCK THROTTLE TO 1.0. 108 | PRINT "Beginning circularization burn.". 109 | WAIT UNTIL SHIP:APOAPSIS >= aptarget - 3000. 110 | LOCK THROTTLE TO 0.0. 111 | PRINT "Orbit established.". 112 | 113 | // Flatten inclination. 114 | IF SHIP:GEOPOSITION:LAT > 0 { 115 | PRINT "Ship is over the northern hemisphere.". 116 | SET incburn TO HEADING(0,0). 117 | } ELSE { 118 | PRINT "Ship is over the southern hemisphere.". 119 | SET incburn TO HEADING(180,0). 120 | } 121 | LOCK STEERING TO incburn. 122 | PRINT "Waiting for equatorial crossing.". 123 | SET WARPMODE TO "PHYSICS". 124 | SET WARP TO 3. 125 | WAIT UNTIL ABS(SHIP:GEOPOSITION:LAT) < 0.0005. 126 | SET WARP TO 0. 127 | SET dvtgt TO (2 * (SHIP:SURFACESPEED+202) * SIN(SHIP:OBT:INCLINATION/2)). 128 | SET burnlen TO dvtgt / ((ship:maxthrust/10) / ship:mass). 129 | PRINT "Starting inclination burn, " + burnlen + " seconds.". 130 | LOCK THROTTLE TO 0.1. 131 | WAIT burnlen. 132 | LOCK THROTTLE TO 0.0. 133 | PRINT "Inclination adjustment complete. Rounding orbit.". 134 | WAIT 1. 135 | 136 | SET WARPMODE TO "RAILS". 137 | SET WARP TO 3. 138 | WAIT UNTIL ETA:APOAPSIS <= 60. 139 | SET WARP TO 0. 140 | LOCK STEERING TO HEADING(90,0). 141 | WAIT UNTIL ETA:APOAPSIS <= 5. 142 | LOCK THROTTLE TO 0.05. 143 | WAIT UNTIL SHIP:APOAPSIS >= aptarget. 144 | LOCK THROTTLE TO 0.0. 145 | LOCK STEERING TO NORTH. 146 | WAIT 5. 147 | 148 | SET WARP TO 3. 149 | WAIT UNTIL ETA:APOAPSIS <= 60. 150 | SET WARP TO 0. 151 | LOCK STEERING TO HEADING(90,0). 152 | 153 | WAIT UNTIL ETA:APOAPSIS <= 20. 154 | SET dvtgt TO 2245.8 - (SHIP:SURFACESPEED+202). 155 | SET burnlen TO dvtgt / ((ship:maxthrust/20) / ship:mass). 156 | WAIT UNTIL ETA:APOAPSIS <= burnlen/2. 157 | LOCK THROTTLE TO 0.05. 158 | WAIT UNTIL SHIP:PERIAPSIS >= APTARGET - 30. 159 | LOCK THROTTLE TO 0.0. 160 | 161 | PRINT "Orbit circularized!.". 162 | PRINT "Deploying antennae.". 163 | FOR antenna IN SHIP:PARTSDUBBED("longAntenna") { 164 | antenna:GETMODULE("ModuleAnimateGeneric"):DOACTION("toggle antenna", true). 165 | } 166 | 167 | LOCK STEERING TO NORTH. 168 | WAIT 5. 169 | PRINT "Guidance terminated.". 170 | UNLOCK STEERING. 171 | SAS OFF. 172 | 173 | SET targetECC TO 0. 174 | SET targetSMA TO 700000. 175 | SET targetInc TO 0. 176 | SET actualECC TO SHIP:OBT:ECCENTRICITY. 177 | SET actualSMA TO SHIP:OBT:SEMIMAJORAXIS. 178 | SET actualINC TO SHIP:OBT:INCLINATION. 179 | SET scoreECC TO ABS( ROUND(actualEcc, 3) - targetEcc) * 100. 180 | SET scoreSMA TO ABS( ROUND(actualSMA) - targetSMA) * 0.1. 181 | SET scoreInc TO ABS( ROUND(actualInc, 3) - targetInc) * 100. 182 | SET totalscore TO (scoreECC + scoreSMA + scoreInc). 183 | PRINT "Scorecard:". 184 | PRINT "Eccentricity " + scoreECC + " points, " + actualECC. 185 | PRINT "SMA " + scoreSMA + " points, " + actualSMA. 186 | PRINT "Inclination " + scoreInc + " points, " + actualInc. 187 | PRINT "--------------------------------------------------". 188 | PRINT "TOTAL " + totalscore. -------------------------------------------------------------------------------- /old/throttle_log_0_1.ks: -------------------------------------------------------------------------------- 1 | # Throttle PID Tuning 2 | # Kp: 1 3 | # t acc throt 4 | 0.0399999991059303 1.12593754311671 0 5 | 0.139999996870756 0 1 6 | 0.219999995082617 2.96541812795106 0 7 | 0.279999993741512 2.96726578737167 0 8 | 0.339999992400408 0 1 9 | 0.399999991059303 0 1 10 | 0.459999989718199 2.96956491909524 0 11 | 0.519999988377094 2.97141746569732 0 12 | 0.57999998703599 0 1 13 | 0.639999985694885 0 1 14 | 0.699999984353781 2.97372212576947 0 15 | 0.779999982565641 0 1 16 | 0.859999980777502 2.97649997182203 0 17 | 0.919999979436398 2.97836018661576 0 18 | 0.979999978095293 0 1 19 | 1.03999997675419 0 1 20 | 1.09999997541308 2.9806743291392 0 21 | 1.17999997362494 0 1 22 | 1.23999997228384 0 1 23 | 1.3199999704957 2.98533138853612 0 24 | 1.3799999691546 2.98720203499491 0 25 | 1.45999996736646 0 1 26 | 1.51999996602535 0 1 27 | 1.57999996468425 2.98960695776666 0 28 | 1.63999996334314 2.99148201617835 0 29 | 1.69999996200204 0 1 30 | 1.7799999602139 2.99256482314625 0 31 | 1.8399999588728 2.99444220339076 0 32 | 1.91999995708466 0 1 33 | 1.97999995574355 0 1 34 | 2.03999995440245 2.99685398236761 0 35 | 2.11999995261431 0 1 36 | 2.1799999512732 0 1 37 | 2.2399999499321 3.00092512683605 0 38 | 2.29999994859099 3.00281239205814 0 39 | 2.35999994724989 0 1 40 | 2.43999994546175 3.00390137321177 0 41 | 2.49999994412065 3.00579102380225 0 42 | 2.55999994277954 0 1 43 | 2.61999994143844 0 1 44 | 2.67999994009733 3.00814121026633 0 45 | 2.73999993875623 3.01003594780009 0 46 | 2.81999993696809 0 1 47 | 2.87999993562698 0 1 48 | 2.95999993383884 3.01310067309899 0 49 | 3.01999993249774 3.01500081311254 0 50 | 3.0999999307096 0 1 51 | 3.1599999293685 0 1 52 | 3.21999992802739 3.01743935471552 0 53 | 3.29999992623925 0 1 54 | 3.35999992489815 0 1 55 | 3.43999992311001 3.02219521853358 0 56 | 3.4999999217689 3.02410610325655 0 57 | 3.5599999204278 0 1 58 | 3.61999991908669 0 1 59 | 3.67999991774559 3.02648302632863 0 60 | 3.73999991640449 3.02839877296317 0 61 | 3.79999991506338 0 1 62 | 3.87999991327524 3.02950274097851 0 63 | 3.93999991193414 3.03142150360397 0 64 | 3.99999991059303 0 1 65 | 4.07999990880489 3.032525909237 0 66 | 4.13999990746379 3.03444659944095 0 67 | 4.19999990612268 0 1 68 | 4.27999990433455 3.03555145367708 0 69 | 4.33999990299344 3.03747516052036 0 70 | 4.4199999012053 0 1 71 | 4.4799998998642 0 1 72 | 4.53999989852309 3.0399410674747 0 73 | 4.59999989718199 3.04186882079307 0 74 | 4.65999989584088 0 1 75 | 4.71999989449978 0 1 76 | 4.77999989315867 3.04426303563149 0 77 | 4.83999989181757 3.04619600680742 0 78 | 4.91999989002943 0 1 79 | 4.97999988868833 0 1 80 | 5.03999988734722 3.04867272737622 0 81 | 5.11999988555908 0 1 82 | 5.17999988421798 0 1 83 | 5.25999988242984 3.05350824567554 0 84 | 5.31999988108873 3.05545223073287 0 85 | 5.39999987930059 0 1 86 | 5.45999987795949 0 1 87 | 5.51999987661839 3.05794418321632 0 88 | 5.57999987527728 3.05989285540973 0 89 | 5.63999987393618 0 1 90 | 5.69999987259507 0 1 91 | 5.75999987125397 3.06231245421129 0 92 | 5.81999986991286 3.06426558383964 0 93 | 5.89999986812472 0 1 94 | 5.95999986678362 0 1 95 | 6.01999986544251 3.06676830585967 0 96 | 6.09999986365438 0 1 97 | 6.15999986231327 0 1 98 | 6.21999986097217 3.07100130118115 0 99 | 6.29999985918403 0 1 100 | 6.35999985784292 0 1 101 | 6.41999985650182 3.07524638719683 0 102 | 6.49999985471368 0 1 103 | 6.55999985337257 0 1 104 | 6.61999985203147 3.07950389146042 0 105 | 6.67999985069036 3.08147863344212 0 106 | 6.73999984934926 0 1 107 | 6.79999984800816 0 1 108 | 6.87999984622002 3.08459185120061 0 109 | 6.93999984487891 3.08657215896961 0 110 | 6.99999984353781 0 1 111 | 7.0599998421967 0 1 112 | 7.1199998408556 3.08903401440326 0 113 | 7.19999983906746 0 1 114 | 7.25999983772635 0 1 115 | 7.33999983593822 3.09399111077712 0 116 | 7.39999983459711 3.09598351480212 0 117 | 7.45999983325601 0 1 118 | 7.5199998319149 0 1 119 | 7.59999983012676 3.09912610495412 0 120 | 7.65999982878566 3.1011241650128 0 121 | 7.73999982699752 0 1 122 | 7.81999982520938 3.10235578262407 0 123 | 7.89999982342124 0 1 124 | 7.95999982208014 0 1 125 | 8.039999820292 3.10735144817667 0 126 | 8.09999981895089 3.10935910222421 0 127 | 8.15999981760979 0 1 128 | 8.21999981626868 0 1 129 | 8.27999981492758 3.1118549524 0 130 | 8.33999981358647 3.11386757653224 0 131 | 8.39999981224537 0 1 132 | 8.45999981090426 0 1 133 | 8.51999980956316 3.11636958856369 0 134 | 8.57999980822206 3.11838725318421 0 135 | 8.65999980643392 0 1 136 | 8.71999980509281 0 1 137 | 8.77999980375171 3.12097603205156 0 138 | 8.85999980196357 0 1 139 | 8.91999980062246 0 1 140 | 8.97999979928136 3.12535028543099 0 141 | 9.03999979794025 3.12737841124418 0 142 | 9.09999979659915 0 1 143 | 9.15999979525805 0 1 144 | 9.21999979391694 3.12989968703176 0 145 | 9.27999979257584 3.13193286870009 0 146 | 9.33999979123473 0 1 147 | 9.41999978944659 3.1331030741063 0 148 | 9.47999978810549 3.13513933829207 0 149 | 9.53999978676438 0 1 150 | 9.61999978497624 3.13630990209123 0 151 | 9.67999978363514 3.13834891192539 0 152 | 9.759999781847 0 1 153 | 9.8199997805059 0 1 154 | 9.87999977916479 3.14096254772653 0 155 | 9.93999977782369 3.1430063145655 0 156 | 9.99999977648258 0 1 157 | 10.0599997751415 0 1 158 | 10.1199997738004 3.14554345793289 0 159 | 10.1999997720122 0 1 160 | 10.2599997706711 0 1 161 | 10.31999976933 3.1499731892031 0 162 | 10.3799997679889 3.15202830947661 0 163 | 10.4599997662008 0 1 164 | 10.5199997648597 0 1 165 | 10.5999997630715 3.15534750423247 0 166 | 10.6599997617304 3.15740908277062 0 167 | 10.7199997603893 0 1 168 | 10.7799997590482 0 1 169 | 10.8399997577071 3.15996766166549 0 170 | 10.899999756366 3.16203357864102 0 171 | 10.9599997550249 0 1 172 | 11.0199997536838 0 1 173 | 11.0999997518957 3.16528906408932 0 174 | 11.1599997505546 3.16736154513738 0 175 | 11.2199997492135 0 1 176 | 11.2999997474253 3.16855123573872 0 177 | 11.3599997460842 3.17062718577214 0 178 | 11.4399997442961 0 1 179 | 11.499999742955 0 1 180 | 11.5599997416139 3.17328540199328 0 181 | 11.6399997398257 0 1 182 | 11.6999997384846 0 1 183 | 11.7599997371435 3.17778198186641 0 184 | 11.8199997358024 3.17986830005192 0 185 | 11.8999997340143 0 1 186 | 11.9599997326732 0 1 187 | 12.0199997313321 3.1825404227552 0 188 | 12.079999729991 3.18463227243826 0 189 | 12.1399997286499 0 1 190 | 12.1999997273088 0 1 191 | 12.2599997259676 3.18722699376754 0 192 | 12.3199997246265 3.18932360501733 0 193 | 12.3999997228384 0 1 194 | 12.4599997214973 0 1 195 | 12.5199997201562 3.19200788567487 0 196 | 12.5999997183681 0 1 197 | 12.6599997170269 0 1 198 | 12.7199997156858 3.19655063635932 0 199 | 12.7799997143447 3.19865837024142 0 200 | 12.8599997125566 0 1 201 | 12.9199997112155 0 1 202 | 12.9799997098744 3.20135654015502 0 203 | 13.0399997085333 3.20347020928904 0 204 | 13.0999997071922 0 1 205 | 13.1599997058511 0 1 206 | 13.2399997040629 3.20679633945103 0 207 | 13.2999997027218 3.20891654495332 0 208 | 13.3599997013807 0 1 209 | 13.4399996995926 3.21013066672707 0 210 | 13.4999996982515 3.21225354233226 0 211 | 13.5599996969104 0 1 212 | 13.6399996951222 3.21346816817788 0 213 | 13.6999996937811 3.21559465337959 0 214 | 13.75999969244 0 1 215 | 13.8399996906519 3.21680978649669 0 216 | 13.8999996893108 3.21893929701506 0 217 | 13.9599996879697 0 1 218 | 14.0199996866286 0 1 219 | 14.0799996852875 3.22157656262322 0 220 | 14.1399996839464 3.2237115618226 0 221 | 14.1999996826053 0 1 222 | 14.2599996812642 0 1 223 | 14.339999679476 3.22706866714488 0 224 | 14.3999996781349 3.22921059807441 0 225 | 14.4599996767938 0 1 226 | 14.5399996750057 3.23043346680616 0 227 | 14.5999996736646 3.23257844600986 0 228 | 14.6599996723235 0 1 229 | 14.7199996709824 0 1 230 | 14.7799996696413 3.23523382578375 0 231 | 14.8599996678531 0 1 232 | 14.919999666512 0 1 233 | 14.9999996647239 3.2405959166175 0 234 | 15.0799996629357 0 1 235 | 15.1399996615946 0 1 236 | 15.1999996602535 3.24525612300812 0 237 | 15.2799996584654 0 1 238 | 15.3399996571243 0 1 239 | 15.3999996557832 3.24993004780381 0 240 | 15.4599996544421 3.2521002362365 0 241 | -------------------------------------------------------------------------------- /old/a1.ks: -------------------------------------------------------------------------------- 1 | clearscreen. 2 | sas off. // Ensures SAS is OFF. 3 | 4 | //**User Set variables. 5 | 6 | set tOrbit to 100000. // Sets Default Target Orbit. 7 | set tHeading to 90. // Sets your launch heading. Usage:0-360. 0=North. 8 | set rpAlt to 1000. // Sets the altitude at which to preform an initial roll. 9 | set rProgram to -90. // Sets the roll target. Engages at rpAlt. Usage:0-360. 180=VAB default. 10 | 11 | set throttleLimit to 1. // Engages throttle limits below turn1. 12 | set tTWR to 2. // Sets the max TWR while throttle limited. 13 | 14 | set Count to 0. // Sets the number of asparagus stages. 15 | set aspFuel to 0. // Sets the amount of fuel in one aparagus stage. 16 | 17 | 18 | //**Internal variables. 19 | 20 | set yaw to 90 + tHeading. // Internal var to match heading to NavBall 21 | set pitch to 90. // Sets your inital pitch via heading. Usage:0-360 90=Up. 22 | set roll to 180. // Sets your inital roll. Usage:0-360. 180=VAB Default. 23 | set x to 0. // Internal var for angle calculation. 24 | set y to 0. // Internal var for angle calculation. 25 | set z to 0. // Internal var for angle calculation. 26 | set tThr to 1. // Sets throttle at lift off. 27 | lock steering to up + R(0,0,roll) + V(x,y,z). // Locks steering to calculated vector plus roll. 28 | lock throttle to tThr. // Locks throttle to var tThr. 29 | set orbit to 0. // Sets the main loop close condition. 30 | set hAtmo to 69500. // Sets the altitude of atmosohere of Kerbin. Unit:Meters. 31 | set turn1 to 9999. // Sets the altitude of the first down range turn. Unit:Meters 32 | set turn2 to 14999. // " " Unit:Meters 33 | set turn3 to 19999. // " " Unit:Meters 34 | set turn4 to 24999. // " " Unit:Meters 35 | set turn5 to 49999. // " " Unit:Meters 36 | set end to 0. // Internal var for UI. 37 | set bitMask to " ". // Internal var for UI. 38 | set printflag to 1. // Internal var for UI. 39 | if ag9 = "True" { toggle ag9. }. // Internal var for UI. 40 | if ag8 = "True" { toggle ag8. }. // Internal var for UI. 41 | if ag7 = "True" { toggle ag7. }. // Internal var for UI. 42 | set TWR to (maxthrust/(mass*9.81)). // Preliminary TWR set. 43 | 44 | //**Abort Procedure. 45 | // Usage: AG2 decople/fire escape motors. AG3 decouple tower/trigger parachute. 46 | on abort { toggle ag2. wait until verticalspeed < 0. toggle ag3. }. 47 | 48 | 49 | //**UI Section. 50 | 51 | until end = 1 52 | { 53 | if ag9 = "True" { set tOrbit to tOrbit + 10000. set printflag to 1. toggle ag9. }. 54 | if ag8 = "True" { set tOrbit to tOrbit - 10000. set printflag to 1. toggle ag8. }. 55 | if tOrbit < 80000 { set tOrbit to 80000. }. 56 | if tOrbit > 650000 { set tOrbit to 650000. }. 57 | if ag7 = "True" 58 | { 59 | clearscreen. 60 | print "You have confirmed " + tOrbit + "m" at (0,1). 61 | print "Lift Off in 5s." at (0,3). 62 | toggle ag7. 63 | wait 2. 64 | set end to 1. 65 | }. 66 | 67 | if printflag = 1 68 | { 69 | clearscreen. 70 | print "Select your orbit altitude." at (0,0). 71 | print "--------------------------------" at (0,1). 72 | print "Use action group 9 to add 10Km to orbit alt." at (0,3). 73 | print "Use action group 8 to remove 10Km from orbit alt." at (0,5). 74 | print "Use action group 7 to confirm orbit alt." at (0,7). 75 | print "You have selected " + tOrbit + "m" at (0,9). 76 | set printflag to 0. 77 | }. 78 | }. 79 | 80 | 81 | //**Throttle limit section. 82 | //**Learned a new way to lock TWR that is faster and doesn't need to be in the loop. 83 | //**Thanks to KSP forum member Check for this better method. 84 | 85 | if throttleLimit = 1 86 | { 87 | lock throttle to (tTWR * 9.81 * mass / maxthrust). 88 | when altitude > turn1 then 89 | { set throttleLimit to 0. lock throttle to tThr. }. 90 | }. 91 | 92 | 93 | //**Values based on UI. 94 | 95 | set xAlt to tOrbit - 100. // Primary M.E.C.O. Condition. Usage:xAlt=tOrbit-Meters. 96 | set xOrbit to tOrbit + 5000. // Secondary M.E.C.O. Condition. Usage:xOrbit=tOrbit+Meters. 97 | set cAlt to (tOrbit - (tOrbit*.01)). // Internal var for near MECO throttle limit. Usage:cAlt=tOrbit-5%. 98 | set hAlt to tOrbit - 5. // Internal var for apoaps hold. Usage:hAlt=tOrbit-Meters. 99 | 100 | 101 | //**Begin Countdown. 102 | 103 | clearscreen. 104 | print "Orbit altitude set to " + tOrbit + "m". 105 | print "3". wait 1. 106 | print "2". wait 1. 107 | print "1". wait 1. 108 | clearscreen. 109 | print "Lift Off! Target Heading set to " + tHeading + "Deg". stage. 110 | 111 | set StartFuel to . // Internal var for initial Total Liquid Fuel. 112 | 113 | 114 | //**G-turn Section. 115 | 116 | when altitude > rpAlt then set roll to rProgram. 117 | when altitude > turn1 then set pitch to 60. 118 | when altitude > turn2 then set pitch to 50. 119 | when altitude > turn3 then set pitch to 30. 120 | when altitude > turn4 then set pitch to 15. 121 | when apoapsis > turn5 then set pitch to 0. 122 | 123 | 124 | //**Orbit Injection control. Alter at your own risk. 125 | 126 | when apoapsis > tOrbit then 127 | { 128 | set tThr to 0. 129 | toggle ag5. 130 | until altitude > hAtmo 131 | { 132 | if apoapsis < hAlt { set tThr to .1. }. 133 | if apoapsis > tOrbit { set tThr to 0. }. 134 | }. 135 | }. 136 | when altitude > 70200 then 137 | { 138 | set Gk to 3.5316000*10^12. 139 | set Radius to 600000 + apoapsis. 140 | set sma to 600000 + ((periapsis+apoapsis)/2). 141 | set V1 to (Gk/Radius)^.5. 142 | set V2 to (Gk*((2/Radius)-(1/sma)))^.5. 143 | set dV to abs(V1-V2). 144 | set acceleration to (maxthrust/mass). 145 | set burnTime to (dV/acceleration). 146 | set tTime to (burnTime/2). 147 | set warp to 3. 148 | when eta:apoapsis < (120 + tTime) then set warp to 2. 149 | when eta:apoapsis < (60 + tTime) then 150 | { set warp to 0. wait 1. lock steering to prograde. }. 151 | when eta:apoapsis < tTime then set tThr to 1. 152 | when periapsis > cAlt then set tThr to .1. 153 | when periapsis > xAlt OR apoapsis > xOrbit then 154 | { 155 | set tThr to 0. 156 | sas on. 157 | clearscreen. 158 | print "You Are Now In Orbit". 159 | set orbit to 1. 160 | }. 161 | }. 162 | 163 | 164 | //**Main Control loop. Alter at your own risk. 165 | 166 | until orbit = 1 167 | { 168 | set x to cos(yaw) * cos(pitch). 169 | set y to sin(yaw) * cos(pitch). 170 | set z to sin(pitch). 171 | set StageSolid to stage:solidfuel. 172 | set StageLiquid to stage:liquidfuel. 173 | set Lfuel to . 174 | set TWR to maxthrust / (mass*9.81). 175 | if throttle < 1 { set cTWR to (TWR*throttle). }. 176 | if throttle > 1 OR throttle = 1 { set cTWR to TWR. }. 177 | print "Heading " + heading + bitMask at (0,3). 178 | print "Max Surface TWR " + TWR + bitMask at (0,5). 179 | print "Current TWR " + cTWR + bitMask at (0,7). 180 | print "ETA:Apoapsis " + eta:apoapsis + bitMask at (0,9). 181 | print "MaxThrust " + maxthrust + "kN" + bitMask at (0,11). 182 | 183 | if Lfuel < (StartFuel - aspFuel) AND Count > 0 184 | { stage. set StartFuel to (StartFuel-aspFuel). set Count to Count - 1. }. 185 | 186 | if StageSolid < 1 AND StageSolid > 0 187 | { stage. }. 188 | 189 | if StageLiquid = 0 AND StageSolid = 0 190 | { if Lfuel > 0 { stage. wait 1. }. }. 191 | }. 192 | 193 | //**End program orbital condition print out. Extend solar pannels on AG1. 194 | 195 | lock throttle to 0. 196 | wait 1. 197 | toggle ag1. 198 | print " ". 199 | print "Apoapsis is " + apoapsis + "m". 200 | print " ". 201 | print "Periapsis is " + periapsis + "m". 202 | print " ". 203 | print "Orbital Eccentricity is " + 204 | (((apoapsis + 600000)-(periapsis + 600000))/((apoapsis + 600000)+(periapsis + 600000))). 205 | print " ". 206 | wait 2. -------------------------------------------------------------------------------- /old/throttle_log_0_001.ks: -------------------------------------------------------------------------------- 1 | # Throttle PID Tuning 2 | # Kp: 1 3 | # t acc throt 4 | 0.0399999991059303 1.10075850344076 0 5 | 0.139999996870756 0 1 6 | 0.219999995082617 3.55388045091884 0 7 | 0.279999993741512 3.55633429346544 0 8 | 0.339999992400408 0 1 9 | 0.399999991059303 0 1 10 | 0.459999989718199 3.55923424422297 0 11 | 0.519999988377094 3.56169573012694 0 12 | 0.599999986588955 0 1 13 | 0.65999998524785 0 1 14 | 0.739999983459711 3.56550209860937 0 15 | 0.799999982118607 3.5679718692191 0 16 | 0.879999980330467 0 1 17 | 0.939999978989363 0 1 18 | 0.999999977648258 3.57096822265251 0 19 | 1.07999997586012 0 1 20 | 1.13999997451901 0 1 21 | 1.21999997273088 3.57705486025584 0 22 | 1.27999997138977 3.5795412216629 0 23 | 1.33999997004867 0 1 24 | 1.39999996870756 0 1 25 | 1.45999996736646 3.58248578227402 0 26 | 1.51999996602535 3.58497994067518 0 27 | 1.57999996468425 0 1 28 | 1.63999996334314 0 1 29 | 1.719999961555 3.58876761454644 0 30 | 1.7799999602139 3.59127030101152 0 31 | 1.85999995842576 0 1 32 | 1.91999995708466 0 1 33 | 1.99999995529652 3.59514968504509 0 34 | 2.07999995350838 0 1 35 | 2.13999995216727 0 1 36 | 2.19999995082617 3.60048602817458 0 37 | 2.25999994948506 3.60300631630048 0 38 | 2.31999994814396 0 1 39 | 2.37999994680285 0 1 40 | 2.43999994546175 3.60599537633712 0 41 | 2.49999994412065 3.60852326758702 0 42 | 2.55999994277954 0 1 43 | 2.61999994143844 0 1 44 | 2.67999994009733 3.61152266198696 0 45 | 2.73999993875623 3.61405785332008 0 46 | 2.81999993696809 0 1 47 | 2.87999993562698 0 1 48 | 2.93999993428588 3.61714652299228 0 49 | 3.01999993249774 0 1 50 | 3.07999993115664 0 1 51 | 3.13999992981553 3.62255175569921 0 52 | 3.21999992802739 0 1 53 | 3.27999992668629 0 1 54 | 3.33999992534518 3.62797516328988 0 55 | 3.39999992400408 3.63053473624876 0 56 | 3.45999992266297 0 1 57 | 3.53999992087483 3.63186853955838 0 58 | 3.59999991953373 3.63443233020578 0 59 | 3.65999991819263 0 1 60 | 3.73999991640449 3.63576910937767 0 61 | 3.81999991461635 0 1 62 | 3.87999991327524 0 1 63 | 3.93999991193414 3.64123154183619 0 64 | 4.019999910146 0 1 65 | 4.07999990880489 0 1 66 | 4.13999990746379 3.6467141282646 0 67 | 4.19999990612268 3.64929955305129 0 68 | 4.27999990433455 0 1 69 | 4.33999990299344 0 1 70 | 4.39999990165234 3.65245854962887 0 71 | 4.45999990031123 3.65505178662671 0 72 | 4.51999989897013 0 1 73 | 4.57999989762902 0 1 74 | 4.63999989628792 3.65813958417162 0 75 | 4.69999989494681 3.66074076976532 0 76 | 4.75999989360571 0 1 77 | 4.8199998922646 0 1 78 | 4.8799998909235 3.66383903423967 0 79 | 4.95999988913536 0 1 80 | 5.01999988779426 0 1 81 | 5.07999988645315 3.66939289599747 0 82 | 5.13999988511205 3.67201056043978 0 83 | 5.19999988377094 0 1 84 | 5.25999988242984 0 1 85 | 5.31999988108873 3.6751320093411 0 86 | 5.37999987974763 3.67775770934819 0 87 | 5.43999987840652 0 1 88 | 5.49999987706542 0 1 89 | 5.55999987572432 3.68088980125543 0 90 | 5.61999987438321 3.6835239563409 0 91 | 5.67999987304211 0 1 92 | 5.739999871701 0 1 93 | 5.7999998703599 3.68666707730718 0 94 | 5.85999986901879 3.68930901271897 0 95 | 5.91999986767769 0 1 96 | 5.97999986633658 0 1 97 | 6.03999986499548 3.69246359064514 0 98 | 6.09999986365438 3.69511404716146 0 99 | 6.15999986231327 0 1 100 | 6.21999986097217 0 1 101 | 6.27999985963106 3.69827944101232 0 102 | 6.33999985828996 3.7009377351518 0 103 | 6.39999985694885 0 1 104 | 6.45999985560775 0 1 105 | 6.51999985426664 3.70411434684789 0 106 | 6.57999985292554 3.70678123390454 0 107 | 6.63999985158443 0 1 108 | 6.69999985024333 0 1 109 | 6.75999984890223 3.70996912546503 0 110 | 6.81999984756112 3.71264465908799 0 111 | 6.93999984487891 0 1 112 | 7.01999984309077 3.71431612987015 0 113 | 7.09999984130263 0 1 114 | 7.15999983996153 0 1 115 | 7.23999983817339 3.72092382639664 0 116 | 7.29999983683228 3.72361373639852 0 117 | 7.37999983504415 0 1 118 | 7.43999983370304 0 1 119 | 7.49999983236194 3.72692038025993 0 120 | 7.55999983102083 3.72961933428388 0 121 | 7.61999982967973 0 1 122 | 7.67999982833862 0 1 123 | 7.73999982699752 3.73284842944955 0 124 | 7.79999982565641 3.73555582129127 0 125 | 7.85999982431531 0 1 126 | 7.91999982297421 0 1 127 | 7.9799998216331 3.73879754805847 0 128 | 8.039999820292 3.74151341516727 0 129 | 8.09999981895089 0 1 130 | 8.15999981760979 0 1 131 | 8.21999981626868 3.74476567370571 0 132 | 8.27999981492758 3.7474904064969 0 133 | 8.33999981358647 0 1 134 | 8.39999981224537 0 1 135 | 8.45999981090426 3.75075469658026 0 136 | 8.51999980956316 3.75348796296054 0 137 | 8.57999980822206 0 1 138 | 8.63999980688095 0 1 139 | 8.69999980553985 3.75676327539927 0 140 | 8.75999980419874 3.75950551617237 0 141 | 8.81999980285764 0 1 142 | 8.8999998010695 3.76096167318251 0 143 | 8.95999979972839 3.76370942289749 0 144 | 9.01999979838729 0 1 145 | 9.07999979704618 0 1 146 | 9.13999979570508 3.76700387133105 0 147 | 9.19999979436398 3.76975989237191 0 148 | 9.25999979302287 0 1 149 | 9.31999979168177 0 1 150 | 9.37999979034066 3.77306587516964 0 151 | 9.43999978899956 3.77583099835301 0 152 | 9.49999978765845 0 1 153 | 9.55999978631735 0 1 154 | 9.61999978497624 3.77914816632722 0 155 | 9.6999997831881 0 1 156 | 9.759999781847 0 1 157 | 9.8199997805059 3.78506837307617 0 158 | 9.87999977916479 3.78785152955842 0 159 | 9.95999977737665 0 1 160 | 10.0199997760355 0 1 161 | 10.0799997746944 3.79128624267282 0 162 | 10.1399997733533 3.7940777774451 0 163 | 10.1999997720122 0 1 164 | 10.2599997706711 0 1 165 | 10.31999976933 3.79743188476352 0 166 | 10.3799997679889 3.80023192620111 0 167 | 10.4399997666478 0 1 168 | 10.4999997653067 0 1 169 | 10.5599997639656 3.80359821116025 0 170 | 10.6199997626245 3.8064075703331 0 171 | 10.6799997612834 0 1 172 | 10.7399997599423 0 1 173 | 10.7999997586012 3.80978578499679 0 174 | 10.8599997572601 3.81260448502431 0 175 | 10.919999755919 0 1 176 | 10.9799997545779 0 1 177 | 11.0399997532368 3.81599461590556 0 178 | 11.0999997518957 3.81882234356446 0 179 | 11.1599997505546 0 1 180 | 11.2199997492135 0 1 181 | 11.2799997478724 3.82222452812096 0 182 | 11.3399997465312 3.8250612488007 0 183 | 11.3999997451901 0 1 184 | 11.459999743849 0 1 185 | 11.5199997425079 3.8284758930148 0 186 | 11.5799997411668 3.83132212500774 0 187 | 11.6399997398257 0 1 188 | 11.6999997384846 0 1 189 | 11.7799997366965 3.83569991446049 0 190 | 11.8399997353554 3.83855691894734 0 191 | 11.8999997340143 0 1 192 | 11.9599997326732 0 1 193 | 12.0199997313321 3.84199845126318 0 194 | 12.079999729991 3.84486466846331 0 195 | 12.1399997286499 0 1 196 | 12.1999997273088 0 1 197 | 12.2599997259676 3.84831887470278 0 198 | 12.3199997246265 3.85119392749448 0 199 | 12.3799997232854 0 1 200 | 12.4399997219443 0 1 201 | 12.4999997206032 3.85466124748364 0 202 | 12.5599997192621 3.85754562755265 0 203 | 12.619999717921 0 1 204 | 12.6999997161329 3.85909866915113 0 205 | 12.7599997147918 3.86198937716502 0 206 | 12.8199997134507 0 1 207 | 12.8799997121096 0 1 208 | 12.9399997107685 3.86547597747324 0 209 | 12.9999997094274 3.86837602899461 0 210 | 13.0599997080863 0 1 211 | 13.1199997067451 0 1 212 | 13.179999705404 3.87187557325686 0 213 | 13.2399997040629 3.87478501393463 0 214 | 13.2999997027218 0 1 215 | 13.3599997013807 0 1 216 | 13.4199997000396 3.87829713458227 0 217 | 13.4999996982515 0 1 218 | 13.5599996969104 0 1 219 | 13.6199996955693 3.88454102711224 0 220 | 13.6799996942282 3.88747029350789 0 221 | 13.7399996928871 0 1 222 | 13.799999691546 0 1 223 | 13.8599996902049 3.8910084466699 0 224 | 13.9199996888638 3.8939472648509 0 225 | 13.9799996875227 0 1 226 | 14.0399996861815 0 1 227 | 14.0999996848404 3.89749899581904 0 228 | 14.1599996834993 3.90044663246752 0 229 | 14.2199996821582 0 1 230 | 14.2799996808171 0 1 231 | 14.339999679476 3.90401155518135 0 232 | 14.3999996781349 3.90696923383676 0 233 | 14.4599996767938 0 1 234 | 14.5199996754527 0 1 235 | 14.5799996741116 3.91054709406311 0 236 | 14.6599996723235 0 1 237 | 14.7199996709824 0 1 238 | 14.7799996696413 3.91689971386162 0 239 | 14.8599996678531 0 1 240 | 14.919999666512 0 1 241 | 14.9799996651709 3.92327475337442 0 242 | 15.0599996633828 0 1 243 | 15.1199996620417 0 1 244 | 15.1799996607006 3.92967312698801 0 245 | 15.2399996593595 3.93267095138403 0 246 | 15.2999996580184 0 1 247 | 15.3599996566772 0 1 248 | 15.4199996553361 3.93630466294976 0 249 | 15.479999653995 3.9393123259719 0 250 | 15.5399996526539 0 1 251 | 15.5999996513128 0 1 252 | 15.6599996499717 3.94295894523015 0 253 | 15.7199996486306 3.94597658061924 0 254 | 15.7799996472895 0 1 255 | 15.8599996455014 3.94762161194064 0 256 | 15.9199996441603 3.95064523130708 0 257 | 15.9799996428192 0 1 258 | 16.0399996414781 0 1 259 | 16.099999640137 3.95431420688546 0 260 | 16.1599996387959 3.95734825313181 0 261 | 16.2199996374547 0 1 262 | 16.2799996361136 0 1 263 | 16.3399996347725 3.96103069271693 0 264 | 16.3999996334314 3.9640748012177 0 265 | 16.4799996316433 0 1 266 | 16.5399996303022 0 1 267 | 16.5999996289611 3.96787794091605 0 268 | 16.65999962762 3.97093247143277 0 269 | 16.7199996262789 0 1 270 | 16.7799996249378 0 1 271 | 16.8399996235967 3.97464171479225 0 272 | 16.8999996222556 3.97770561335037 0 273 | 16.9599996209145 0 1 274 | 17.0199996195734 0 1 275 | 17.0799996182323 3.98142891179065 0 276 | 17.1399996168911 3.98450381553701 0 277 | 17.19999961555 0 1 278 | 17.2599996142089 0 1 279 | 17.3199996128678 3.98824124499273 0 280 | 17.3799996115267 3.99132598794142 0 281 | 17.4399996101856 0 1 282 | 17.4999996088445 0 1 283 | 17.5599996075034 3.99507724055906 0 284 | 17.6199996061623 3.99817234904401 0 285 | 17.6799996048212 0 1 286 | 17.7599996030331 3.9998702628242 0 287 | 17.819999601692 4.00297198143416 0 288 | 17.8799996003509 0 1 289 | 17.9399995990098 0 1 290 | 17.9999995976686 4.0067457669904 0 291 | 18.0599995963275 4.00985830984724 0 292 | 18.1199995949864 0 1 293 | 18.1799995936453 0 1 294 | 18.2399995923042 4.01364687016781 0 295 | 18.2999995909631 4.01676986157494 0 296 | 18.359999589622 0 1 297 | 18.4199995882809 0 1 298 | 18.4799995869398 4.02057169970437 0 299 | 18.5399995855987 4.02370594941122 0 300 | 18.5999995842576 0 1 301 | 18.6599995829165 0 1 302 | 18.7199995815754 4.02752238789878 0 303 | 18.7999995797873 0 1 304 | 18.8599995784462 0 1 305 | 18.919999577105 4.0342711475151 0 306 | 18.9799995757639 4.03742668668305 0 307 | 19.0399995744228 0 1 308 | 19.0999995730817 0 1 309 | 19.1599995717406 4.04127349951613 0 310 | 19.2399995699525 0 1 311 | 19.2999995686114 0 1 312 | 19.3599995672703 4.04807141153093 0 313 | 19.4199995659292 4.05124844770141 0 314 | 19.499999564141 0 1 315 | 19.5599995627999 0 1 316 | 19.6199995614588 4.05524125704782 0 317 | 19.6799995601177 4.05842896555685 0 318 | 19.7399995587766 0 1 319 | 19.7999995574355 0 1 320 | 19.8599995560944 4.06232070284008 0 321 | 19.9199995547533 4.06551967561808 0 322 | 19.9799995534122 0 1 323 | -------------------------------------------------------------------------------- /old/throttle_log_0_01.ks: -------------------------------------------------------------------------------- 1 | # Throttle PID Tuning 2 | # Kp: 1 3 | # t acc throt 4 | 0.0199999995529652 0 0 5 | 0.0599999986588955 0 1 6 | 0.119999997317791 0 1 7 | 0.179999995976686 0 1 8 | 0.239999994635582 0 1 9 | 0.279999993741512 0 1 10 | 0.319999992847443 0 1 11 | 0.379999991506338 0 1 12 | 0.419999990612268 0 1 13 | 0.479999989271164 0 1 14 | 0.539999987930059 0 1 15 | 0.57999998703599 0 1 16 | 0.639999985694885 0 1 17 | 0.699999984353781 0 1 18 | 0.739999983459711 0 1 19 | 0.799999982118607 0 1 20 | 0.859999980777502 0 1 21 | 0.919999979436398 0 1 22 | 0.979999978095293 0 1 23 | 1.01999997720122 0 1 24 | 1.07999997586012 0 1 25 | 1.13999997451901 0 1 26 | 1.19999997317791 0 1 27 | 1.25999997183681 0 1 28 | 1.29999997094274 0 1 29 | 1.33999997004867 0 1 30 | 1.39999996870756 0 1 31 | 1.45999996736646 0 1 32 | 1.49999996647239 0 1 33 | 1.55999996513128 0 1 34 | 1.61999996379018 0 1 35 | 1.65999996289611 0 1 36 | 1.719999961555 0 1 37 | 1.7799999602139 0 1 38 | 1.81999995931983 0 1 39 | 1.87999995797873 0 1 40 | 1.93999995663762 0 1 41 | 1.97999995574355 0 1 42 | 2.03999995440245 0 1 43 | 2.07999995350838 0 1 44 | 2.13999995216727 0 1 45 | 2.19999995082617 0 1 46 | 2.2399999499321 0 1 47 | 2.29999994859099 0 1 48 | 2.33999994769692 0 1 49 | 2.39999994635582 0 1 50 | 2.45999994501472 0 1 51 | 2.49999994412065 0 1 52 | 2.55999994277954 0 1 53 | 2.61999994143844 0 1 54 | 2.67999994009733 0 1 55 | 2.73999993875623 0 1 56 | 2.79999993741512 0 1 57 | 2.83999993652105 0 1 58 | 2.89999993517995 0 1 59 | 2.95999993383884 0 1 60 | 3.01999993249774 0 1 61 | 3.05999993160367 0 1 62 | 3.11999993026257 0 1 63 | 3.17999992892146 0 1 64 | 3.23999992758036 0 1 65 | 3.27999992668629 0 1 66 | 3.33999992534518 0 1 67 | 3.37999992445111 0 1 68 | 3.43999992311001 0 1 69 | 3.4999999217689 0 1 70 | 3.5599999204278 0 1 71 | 3.59999991953373 0 1 72 | 3.65999991819263 0 1 73 | 3.71999991685152 0 1 74 | 3.77999991551042 0 1 75 | 3.83999991416931 0 1 76 | 3.87999991327524 0 1 77 | 3.91999991238117 0 1 78 | 3.97999991104007 0 1 79 | 4.03999990969896 0 1 80 | 4.07999990880489 0 1 81 | 4.11999990791082 0 1 82 | 4.17999990656972 0 1 83 | 4.23999990522861 0 1 84 | 4.29999990388751 0 1 85 | 4.35999990254641 0 1 86 | 4.39999990165234 0 1 87 | 4.43999990075827 0 1 88 | 4.4799998998642 0 1 89 | 4.53999989852309 0 1 90 | 4.57999989762902 0 1 91 | 4.63999989628792 0 1 92 | 4.69999989494681 0 1 93 | 4.75999989360571 0 1 94 | 4.8199998922646 0 1 95 | 4.8799998909235 0 1 96 | 4.9399998895824 0 1 97 | 4.99999988824129 0 1 98 | 5.05999988690019 0 1 99 | 5.09999988600612 0 1 100 | 5.15999988466501 0 1 101 | 5.21999988332391 0 1 102 | 5.2799998819828 0 1 103 | 5.3399998806417 0 1 104 | 5.37999987974763 0 1 105 | 5.41999987885356 0 1 106 | 5.47999987751246 0 1 107 | 5.53999987617135 0 1 108 | 5.59999987483025 0 1 109 | 5.63999987393618 0 1 110 | 5.69999987259507 0 1 111 | 5.75999987125397 0 1 112 | 5.7999998703599 0 1 113 | 5.85999986901879 0 1 114 | 5.91999986767769 0 1 115 | 5.97999986633658 0 1 116 | 6.01999986544251 0 1 117 | 6.07999986410141 0 1 118 | 6.13999986276031 0 1 119 | 6.1999998614192 0 1 120 | 6.2599998600781 0 1 121 | 6.31999985873699 0 1 122 | 6.37999985739589 0 1 123 | 6.41999985650182 0 1 124 | 6.47999985516071 0 1 125 | 6.53999985381961 0 1 126 | 6.57999985292554 0 1 127 | 6.63999985158443 0 1 128 | 6.69999985024333 0 1 129 | 6.75999984890223 0 1 130 | 6.81999984756112 0 1 131 | 6.87999984622002 0 1 132 | 6.93999984487891 0 1 133 | 6.99999984353781 0 1 134 | 7.0599998421967 0 1 135 | 7.09999984130263 0 1 136 | 7.15999983996153 0 1 137 | 7.21999983862042 0 1 138 | 7.27999983727932 0 1 139 | 7.31999983638525 0 1 140 | 7.37999983504415 0 1 141 | 7.41999983415008 0 1 142 | 7.47999983280897 0 1 143 | 7.53999983146787 0 1 144 | 7.59999983012676 0 1 145 | 7.65999982878566 0 1 146 | 7.71999982744455 0 1 147 | 7.77999982610345 0 1 148 | 7.83999982476234 0 1 149 | 7.87999982386827 0 1 150 | 7.91999982297421 0 1 151 | 7.9799998216331 0 1 152 | 8.039999820292 0 1 153 | 8.09999981895089 0 1 154 | 8.15999981760979 0 1 155 | 8.21999981626868 0 1 156 | 8.27999981492758 0 1 157 | 8.33999981358647 0 1 158 | 8.39999981224537 0 1 159 | 8.4399998113513 0 1 160 | 8.47999981045723 0 1 161 | 8.51999980956316 0 1 162 | 8.57999980822206 0 1 163 | 8.63999980688095 0 1 164 | 8.69999980553985 0 1 165 | 8.75999980419874 0 1 166 | 8.81999980285764 0 1 167 | 8.85999980196357 0 1 168 | 8.8999998010695 0 1 169 | 8.95999979972839 0 1 170 | 9.01999979838729 0 1 171 | 9.07999979704618 0 1 172 | 9.13999979570508 0 1 173 | 9.19999979436398 0 1 174 | 9.25999979302287 0 1 175 | 9.31999979168177 0 1 176 | 9.3599997907877 0 1 177 | 9.39999978989363 0 1 178 | 9.43999978899956 0 1 179 | 9.49999978765845 0 1 180 | 9.55999978631735 0 1 181 | 9.61999978497624 0 1 182 | 9.67999978363514 0 1 183 | 9.73999978229404 0 1 184 | 9.79999978095293 0 1 185 | 9.85999977961183 0 1 186 | 9.89999977871776 0 1 187 | 9.93999977782369 0 1 188 | 9.99999977648258 0 1 189 | 10.0599997751415 0 1 190 | 10.1199997738004 0 1 191 | 10.1799997724593 0 1 192 | 10.2399997711182 0 1 193 | 10.2799997702241 0 1 194 | 10.31999976933 0 1 195 | 10.3799997679889 0 1 196 | 10.4199997670949 0 1 197 | 10.4599997662008 0 1 198 | 10.5199997648597 0 1 199 | 10.5599997639656 0 1 200 | 10.6199997626245 0 1 201 | 10.6599997617304 0 1 202 | 10.6999997608364 0 1 203 | 10.7599997594953 0 1 204 | 10.8199997581542 0 1 205 | 10.879999756813 0 1 206 | 10.919999755919 0 1 207 | 10.9599997550249 0 1 208 | 11.0199997536838 0 1 209 | 11.0799997523427 0 1 210 | 11.1399997510016 0 1 211 | 11.1999997496605 0 1 212 | 11.2599997483194 0 1 213 | 11.2999997474253 0 1 214 | 11.3399997465312 0 1 215 | 11.3999997451901 0 1 216 | 11.4399997442961 0 1 217 | 11.499999742955 0 1 218 | 11.5599997416139 0 1 219 | 11.6199997402728 0 1 220 | 11.6799997389317 0 1 221 | 11.7199997380376 0 1 222 | 11.7799997366965 0 1 223 | 11.8199997358024 0 1 224 | 11.8599997349083 0 1 225 | 11.9199997335672 0 1 226 | 11.9799997322261 0 1 227 | 12.039999730885 0 1 228 | 12.079999729991 0 1 229 | 12.1799997277558 0 1 230 | 12.2199997268617 0 1 231 | 12.2599997259676 0 1 232 | 12.2999997250736 0 1 233 | 12.3399997241795 0 1 234 | 12.3999997228384 0 1 235 | 12.4399997219443 0 1 236 | 12.4999997206032 0 1 237 | 12.5399997197092 0 1 238 | 12.5799997188151 0 1 239 | 12.619999717921 0 1 240 | 12.6599997170269 0 1 241 | 12.7199997156858 0 1 242 | 12.7599997147918 0 1 243 | 12.8199997134507 0 1 244 | 12.8799997121096 0 1 245 | 12.9199997112155 0 1 246 | 12.9599997103214 0 1 247 | 13.0199997089803 0 1 248 | 13.0599997080863 0 1 249 | 13.1199997067451 0 1 250 | 13.179999705404 0 1 251 | 13.21999970451 0 1 252 | # Throttle PID Tuning 253 | # Kp: 1 254 | # t acc throt 255 | 0.0399999991059303 1.17470455302384 0 256 | 0.159999996423721 0 1 257 | 0.239999994635582 2.35162059257561 0 258 | 0.319999992847443 0 1 259 | 0.379999991506338 0 1 260 | 0.439999990165234 2.3548514218073 0 261 | 0.519999988377094 0 1 262 | 0.57999998703599 0 1 263 | 0.639999985694885 2.35808920824871 0 264 | 0.699999984353781 2.35950457783411 0 265 | 0.759999983012676 0 1 266 | 0.819999981671572 0 1 267 | 0.879999980330467 2.3615401457991 0 268 | 0.939999978989363 2.3629576990272 0 269 | 0.999999977648258 0 1 270 | 1.05999997630715 0 1 271 | 1.11999997496605 2.36499466559855 0 272 | 1.17999997362494 2.36641441265973 0 273 | 1.23999997228384 0 1 274 | 1.29999997094274 0 1 275 | 1.35999996960163 2.36845292935629 0 276 | 1.41999996826053 2.36987462621928 0 277 | 1.47999996691942 0 1 278 | 1.53999996557832 0 1 279 | 1.59999996423721 2.37191504956515 0 280 | 1.65999996289611 2.3733394174407 0 281 | 1.719999961555 0 1 282 | 1.7799999602139 0 1 283 | 1.8399999588728 2.37538069268632 0 284 | 1.89999995753169 2.37680752328066 0 285 | 1.95999995619059 0 1 286 | 2.03999995440245 2.37789961107317 0 287 | 2.09999995306134 2.37932678978631 0 288 | 2.15999995172024 0 1 289 | 2.2399999499321 2.38041649019968 0 290 | 2.29999994859099 2.38184385458374 0 291 | 2.35999994724989 0 1 292 | 2.43999994546175 2.38293140275135 0 293 | 2.49999994412065 2.38435952593962 0 294 | 2.55999994277954 0 1 295 | 2.61999994143844 0 1 296 | 2.67999994009733 2.38639673873489 0 297 | 2.73999993875623 2.38782757127843 0 298 | 2.81999993696809 0 1 299 | 2.87999993562698 0 1 300 | 2.93999993428588 2.38996660775627 0 301 | 2.99999993294477 2.39139915545944 0 302 | 3.07999993115664 0 1 303 | 3.13999992981553 0 1 304 | 3.19999992847443 2.39353860692516 0 305 | 3.25999992713332 2.3949728740252 0 306 | 3.31999992579222 0 1 307 | 3.37999992445111 0 1 308 | 3.43999992311001 2.39701238482243 0 309 | 3.4999999217689 2.39844936941624 0 310 | 3.5599999204278 0 1 311 | 3.61999991908669 0 1 312 | 3.67999991774559 2.40049084148118 0 313 | 3.73999991640449 2.40193008370145 0 314 | 3.79999991506338 0 1 315 | 3.87999991327524 2.40301364109018 0 316 | 3.93999991193414 2.40445374794826 0 317 | 3.99999991059303 0 1 318 | 4.05999990925193 0 1 319 | 4.11999990791082 2.40649552389633 0 320 | 4.19999990612268 0 1 321 | 4.25999990478158 0 1 322 | 4.31999990344048 2.40978249860599 0 323 | 4.37999990209937 2.41122892555149 0 324 | 4.43999990075827 0 1 325 | 4.49999989941716 0 1 326 | 4.55999989807606 2.41327724021349 0 327 | 4.61999989673495 2.41472594651824 0 328 | 4.67999989539385 0 1 329 | 4.73999989405274 0 1 330 | 4.79999989271164 2.41677665887423 0 331 | 4.85999989137053 2.418227428995 0 332 | 4.9399998895824 0 1 333 | 4.99999988824129 0 1 334 | 5.05999988690019 2.420379610325 0 335 | 5.11999988555908 2.42183263072292 0 336 | 5.17999988421798 0 1 337 | 5.23999988287687 0 1 338 | 5.29999988153577 2.42388609971944 0 339 | 5.35999988019466 2.42534167969996 0 340 | 5.41999987885356 0 1 341 | 5.47999987751246 0 1 342 | 5.53999987617135 2.4273972090694 0 343 | 5.59999987483025 2.42885558566907 0 344 | 5.65999987348914 0 1 345 | 5.71999987214804 0 1 346 | 5.7999998703599 2.43139977322414 0 347 | 5.85999986901879 2.43286132388854 0 348 | 5.91999986767769 0 1 349 | 5.97999986633658 0 1 350 | 6.03999986499548 2.43492330368104 0 351 | 6.09999986365438 2.43638725185318 0 352 | 6.15999986231327 0 1 353 | 6.21999986097217 0 1 354 | 6.27999985963106 2.43845138550643 0 355 | 6.33999985828996 2.43991835157836 0 356 | 6.39999985694885 0 1 357 | 6.45999985560775 0 1 358 | 6.51999985426664 2.44198465902152 0 359 | 6.57999985292554 2.44345380248238 0 360 | 6.63999985158443 0 1 361 | 6.69999985024333 0 1 362 | 6.75999984890223 2.44552253946144 0 363 | 6.81999984756112 2.44699447437831 0 364 | 6.89999984577298 0 1 365 | 6.95999984443188 0 1 366 | 7.01999984309077 2.44916429093493 0 367 | 7.07999984174967 2.45063837065574 0 368 | 7.13999984040856 0 1 369 | 7.21999983862042 2.45172721087618 0 370 | 7.27999983727932 2.45320238570451 0 371 | 7.33999983593822 0 1 372 | 7.39999983459711 0 1 373 | 7.45999983325601 2.45527262458751 0 374 | 7.5199998319149 2.45675068170283 0 375 | 7.5799998305738 0 1 376 | 7.63999982923269 0 1 377 | 7.69999982789159 2.4588234471769 0 378 | 7.77999982610345 0 1 379 | 7.85999982431531 2.46119445381635 0 380 | 7.91999982297421 2.4626769207837 0 381 | 7.9799998216331 0 1 382 | 8.039999820292 0 1 383 | 8.09999981895089 2.46475366080743 0 384 | 8.15999981760979 2.46623878454664 0 385 | 8.23999981582165 0 1 386 | 8.29999981448054 0 1 387 | 8.35999981313944 2.46841598060831 0 388 | 8.41999981179833 2.46990348487145 0 389 | 8.47999981045723 0 1 390 | 8.53999980911613 0 1 391 | 8.59999980777502 2.47198401126686 0 392 | 8.65999980643392 2.47347417952097 0 393 | 8.71999980509281 0 1 394 | 8.77999980375171 0 1 395 | 8.8399998024106 2.4755569238306 0 396 | 8.91999980062246 0 1 397 | 8.97999979928136 0 1 398 | 9.03999979794025 2.47893946134455 0 399 | 9.09999979659915 2.48043609261114 0 400 | 9.15999979525805 0 1 401 | 9.21999979391694 0 1 402 | 9.27999979257584 2.48252737183495 0 403 | 9.33999979123473 2.48402695408135 0 404 | 9.39999978989363 0 1 405 | 9.45999978855252 0 1 406 | 9.51999978721142 2.48612036523246 0 407 | 9.57999978587031 2.48762265671775 0 408 | 9.63999978452921 0 1 409 | 9.6999997831881 0 1 410 | 9.759999781847 2.48971885147653 0 411 | 9.8199997805059 2.4912238722734 0 412 | 9.89999977871776 0 1 413 | 9.95999977737665 0 1 414 | 10.0199997760355 2.4934205353312 0 415 | 10.0799997746944 2.49492824130113 0 416 | 10.1399997733533 0 1 417 | 10.1999997720122 0 1 418 | 10.2599997706711 2.497028379894 0 419 | 10.31999976933 2.4985384040698 0 420 | 10.3799997679889 0 1 421 | 10.4399997666478 0 1 422 | 10.4999997653067 2.50064115609782 0 423 | 10.5599997639656 2.50215460787241 0 424 | 10.6199997626245 0 1 425 | 10.6799997612834 0 1 426 | 10.7399997599423 2.50426023929816 0 427 | 10.7999997586012 2.50577601670928 0 428 | 10.8599997572601 0 1 429 | 10.9399997554719 2.50687328329305 0 430 | 10.9999997541308 2.50839025463229 0 431 | 11.0599997527897 0 1 432 | 11.1199997514486 0 1 433 | 11.1799997501075 2.51049790550446 0 434 | 11.2399997487664 2.51201790485863 0 435 | 11.2999997474253 0 1 436 | 11.3599997460842 0 1 437 | 11.4199997447431 2.51412803259849 0 438 | 11.479999743402 2.51565056716152 0 439 | 11.5399997420609 0 1 440 | 11.5999997407198 0 1 441 | 11.6599997393787 2.51776380162973 0 442 | 11.7199997380376 2.51928988704918 0 443 | 11.7799997366965 0 1 444 | 11.8599997349083 2.52038752330547 0 445 | 11.9199997335672 2.52191462816276 0 446 | 11.9799997322261 0 1 447 | 12.039999730885 0 1 448 | 12.0999997295439 2.52402971232586 0 449 | 12.1599997282028 2.52555963697095 0 450 | 12.2199997268617 0 1 451 | 12.2799997255206 0 1 452 | 12.3399997241795 2.52767749802708 0 453 | 12.3999997228384 2.52921024724077 0 454 | 12.4599997214973 0 1 455 | 12.5199997201562 0 1 456 | 12.5799997188151 2.53133103366392 0 457 | 12.639999717474 2.53286685452686 0 458 | 12.6999997161329 0 1 459 | 12.7599997147918 0 1 460 | 12.8199997134507 2.53499070498974 0 461 | 12.8799997121096 2.53652963388928 0 462 | 12.9399997107685 0 1 463 | 12.9999997094274 0 1 464 | 13.0599997080863 2.5386564215761 0 465 | 13.1199997067451 2.54019870653142 0 466 | 13.179999705404 0 1 467 | 13.2399997040629 0 1 468 | 13.2999997027218 2.54232834472221 0 469 | 13.3799997009337 0 1 470 | 13.4399996995926 0 1 471 | 13.4999996982515 2.54581200804767 0 472 | 13.5799996964633 0 1 473 | 13.6399996951222 0 1 474 | 13.6999996937811 2.54930448797249 0 475 | 13.75999969244 2.55085739233051 0 476 | 13.8199996910989 0 1 477 | 13.8799996897578 0 1 478 | 13.9399996884167 2.55300165316393 0 479 | 14.0199996866286 0 1 480 | 14.0799996852875 0 1 481 | 14.1399996839464 2.55650957123848 0 482 | 14.1999996826053 2.55806939430247 0 483 | 14.2599996812642 0 1 484 | 14.3199996799231 0 1 485 | 14.379999678582 2.56022285762135 0 486 | 14.4399996772408 2.56178587318971 0 487 | 14.4999996758997 0 1 488 | 14.5599996745586 0 1 489 | 14.6599996723235 2.56498584641921 0 490 | 14.7199996709824 2.56655338333762 0 491 | 14.7999996691942 0 1 492 | 14.8599996678531 0 1 493 | 14.919999666512 2.56881516458054 0 494 | 14.9999996647239 0 1 495 | 15.0599996633828 0 1 496 | 15.1199996620417 2.57235398759474 0 497 | 15.1799996607006 2.57392901729163 0 498 | 15.2399996593595 0 1 499 | 15.2999996580184 0 1 500 | 15.3599996566772 2.57609950784997 0 501 | 15.4199996553361 2.57767707994558 0 502 | 15.479999653995 0 1 503 | 15.5399996526539 0 1 504 | 15.5999996513128 2.57985126927665 0 505 | 15.6799996495247 0 1 506 | 15.7599996477365 2.58235726588711 0 507 | 15.8199996463954 2.58393981531294 0 508 | 15.8799996450543 0 1 509 | 15.9399996437132 0 1 510 | 15.9999996423721 2.58611929761639 0 511 | 16.059999641031 2.58770531158381 0 512 | 16.1199996396899 0 1 513 | 16.1799996383488 0 1 514 | 16.2399996370077 2.58988777289057 0 515 | 16.2999996356666 2.59147686428498 0 516 | 16.3599996343255 0 1 517 | 16.4199996329844 0 1 518 | 16.4799996316433 2.59366282836887 0 519 | 16.5399996303022 2.59525515443607 0 520 | 16.5999996289611 0 1 521 | 16.6799996271729 2.59638187069411 0 522 | 16.7399996258318 2.59797586881098 0 523 | 16.7999996244907 0 1 524 | 16.8599996231496 0 1 525 | 16.9199996218085 2.60016369945074 0 526 | 16.9799996204674 2.60176074863445 0 527 | 17.0399996191263 0 1 528 | 17.0999996177852 0 1 529 | 17.1599996164441 2.60395258454247 0 530 | 17.219999615103 2.60555275270344 0 531 | 17.2799996137619 0 1 532 | 17.3399996124208 0 1 533 | 17.3999996110797 2.60774764502737 0 534 | 17.4599996097386 2.60935108744789 0 535 | 17.5199996083975 0 1 536 | 17.5799996070564 0 1 537 | 17.6399996057153 2.61154956239641 0 538 | 17.7199996039271 0 1 539 | 17.779999602586 0 1 540 | 17.8399996012449 2.61516087943033 0 541 | 17.8999995999038 2.61677163563847 0 542 | 17.9599995985627 0 1 543 | 18.0199995972216 0 1 544 | 18.0999995954335 2.61951710079392 0 545 | 18.1599995940924 2.62113172407188 0 546 | 18.2199995927513 0 1 547 | 18.2799995914102 0 1 548 | 18.3399995900691 2.6233449942134 0 549 | 18.399999588728 2.62496294612516 0 550 | 18.4599995873868 0 1 551 | 18.5199995860457 0 1 552 | 18.5799995847046 2.62717961862628 0 553 | 18.6399995833635 2.62880102045845 0 554 | 18.6999995820224 0 1 555 | 18.7599995806813 0 1 556 | 18.8399995788932 2.63156194471043 0 557 | 18.8999995775521 2.63318766516321 0 558 | 18.9799995757639 0 1 559 | --------------------------------------------------------------------------------