Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Settings
- clearscreen.
- set TargetAp to 300000.
- set Azimuth to 190.
- lock g to constant:g * body:mass / body:radius^2.
- lock twr to ship:mass * g / ship:availablethrust.
- set startsteer to lookDirUp(up:forevector, ship:facing:topvector).
- set PitchKickAlt to 100.
- set sec to 50.
- set min to 20.
- set hour to 4.
- set clock to "04:20:50".
- set rm to 1.
- print "Running hardware...".
- wait 5.
- set n to time:seconds + ((hour-time:hour)*60+min-time:minute)*60+(sec-time:second).
- lock t to (n - time:seconds)+10.
- lock rclock to time:clock.
- until rclock >= clock and rclock <= clock {
- clearscreen.
- print "Left: " + t + " Seconds".
- wait 0.1.
- }
- set done to False.
- until false {
- //Liftoff
- print "Ready for launch".
- wait 0.
- sas off.
- wait 4.
- stage.
- print "Water Deluge System Activated!".
- wait 3.
- stage.
- lock throttle to 0.05.
- wait 1.
- set now to time:seconds.
- lock t to time:seconds - now.
- lock throttle to min(1, t/1).
- print "Ignition!".
- wait 2.
- stage.
- lock steering to startsteer.
- print "Liftoff!".
- set rm to 2.
- wait 0.
- //Ascent
- wait 0.
- if rm = 2 {
- wait 5.
- print "Falcon 9 is cleared the towers...".
- wait until ship:altitude > PitchKickAlt - 50.
- lock steering to heading(Azimuth, 90).
- wait until ship:altitude > PitchKickAlt.
- lock gravityturn to 90-(((ship:apoapsis/TargetAp)^0.6)*100).
- lock steering to heading(Azimuth, gravityturn).
- print "Gravity Turn".
- wait until ship:altitude > 2150.
- lock throttle to 1.55 * twr.
- set oldq to ship:q.
- wait 0.1.
- set newq to ship:q.
- until newq < oldq {
- set oldq to ship:q.
- wait 0.1.
- set newq to ship:q.
- }
- print "Max-Q".
- wait 24.
- lock throttle to 2.5*twr.
- //Stage separation
- wait until ship:altitude > 33200.
- set now to time:seconds.
- lock t to time:seconds - now.
- set thr to throttle.
- lock throttle to max(0, thr-t/2).
- print "MECO".
- rcs on.
- wait 1.
- toggle ag2.
- wait 1.5.
- stage.
- set ship:control:fore to 1.
- wait 3.
- lock throttle to 0.01.
- stage.
- wait 1.
- set now to time:seconds.
- lock t to time:seconds - now.
- lock throttle to min(0.5, t/1).
- set ship:control:fore to 0.
- print "SES-1".
- wait 3.
- stage.
- //Fairing separation
- wait until ship:altitude > 72000.
- stage.
- print "Fairing Separation Confirmed!".
- wait 3.
- set thr to 0.5.
- lock throttle to thr.
- set pitch to 35.
- lock steering to heading(Azimuth, pitch).
- set targeteta1 to 180.
- set pid1 to pidloop(0.4,0.02,0.02, 0.05,1).
- set pid1:setpoint to targeteta1.
- set pid2 to pidloop(0.08,0.05,0.05, -55,65).
- set pid2:setpoint to TargetAp.
- until ship:apoapsis > TargetAp*0.98 {
- set thr to pid1:update(time:seconds,eta:apoapsis).
- set pitch to pid2:update(time:seconds,ship:apoapsis).
- wait 0.01.
- }
- set targeteta2 to 15.
- set pid1:setpoint to targeteta2.
- until ship:apoapsis > TargetAp and ship:periapsis > TargetAp*0.98 {
- set thr to pid1:update(time:seconds,eta:apoapsis).
- set pitch to pid2:update(time:seconds,ship:apoapsis).
- set targeteta2 to (((TargetAp-ship:periapsis)/targeteta1)/targeteta1)+10.
- if ship:verticalspeed < 1 {
- set pid1 to pidloop(0.1,0.05,0.05, 0.05,1).
- set pid2 to pidloop(0.75,0.1,0.02, -10,15).
- set pid1:setpoint to 1.
- set pid2:setpoint to 1.
- set pitch to pid2:update(time:seconds, ship:verticalspeed).
- set thr to pid1:update(time:seconds,ship:verticalspeed).
- }
- wait 0.01.
- }
- set rm to 3.
- }
- wait 0.
- if rm = 3 {
- lock throttle to 0.
- unlock steering.
- wait 0.1.
- set ship:control:fore to -1.
- wait 1.5.
- set ship:control:fore to 0.
- run maneuvernode2.ks.
- set rm to 4.
- }
- if rm = 4 {
- run payloaddeploy.ks.
- }
- set done to True.
- break.
- }
Advertisement
Add Comment
Please, Sign In to add comment