|
@@ -0,0 +1,271 @@
|
|
1
|
+clearscreen.
|
|
2
|
+
|
|
3
|
+SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.0.
|
|
4
|
+SET terminal:width TO 41.
|
|
5
|
+SET terminal:height TO 23.
|
|
6
|
+SET GETVOICE(0):wave to "triangle".
|
|
7
|
+SET GETVOICE(0):attack to 0.
|
|
8
|
+
|
|
9
|
+WAIT 0.5.
|
|
10
|
+print "=========================================".
|
|
11
|
+print " Launch to orbit program".
|
|
12
|
+print " First arg is a target TWR".
|
|
13
|
+print " Second arg is target altitude in m".
|
|
14
|
+print "=========================================".
|
|
15
|
+print "".
|
|
16
|
+DECLARE PARAMETER wantedTWR is 2.3, wantedALT is 95000, wantedHEAD is 90, maneuver_prep is 50.
|
|
17
|
+
|
|
18
|
+GETVOICE(0):PLAY( NOTE(300, .1) ).wait(0.1).GETVOICE(0):PLAY( NOTE(400, .2) ).wait(0.1).
|
|
19
|
+
|
|
20
|
+declare function LocalG {
|
|
21
|
+ // Return local gravity
|
|
22
|
+ return ship:body:mu / ship:body:position:mag ^ 2.
|
|
23
|
+}
|
|
24
|
+
|
|
25
|
+declare function getTwrThrust {
|
|
26
|
+ // Estimate thrust for a given TWR (1.5 by default)
|
|
27
|
+ DECLARE PARAMETER TWR is 1.5.
|
|
28
|
+ set m to ship:mass.
|
|
29
|
+ set w to m * LocalG().
|
|
30
|
+ set p to ship:sensors:pres / 100.
|
|
31
|
+ set t to ship:maxthrustat(p).
|
|
32
|
+ set throt to (TWR * w) / t.
|
|
33
|
+ if throt <= 1.0 {
|
|
34
|
+ return throt.
|
|
35
|
+ } else {
|
|
36
|
+ return 1.0.
|
|
37
|
+ }
|
|
38
|
+}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+declare function dt {
|
|
42
|
+ SET dtim TO TIME - start.
|
|
43
|
+ return dtim:minute+"m"+dtim:second+"s".
|
|
44
|
+}
|
|
45
|
+
|
|
46
|
+declare function spd {
|
|
47
|
+ if ship:distance < 40000 {
|
|
48
|
+ return ship:velocity:surface:mag.
|
|
49
|
+ } else {
|
|
50
|
+ return ship:velocity:orbit:mag.
|
|
51
|
+ }
|
|
52
|
+}
|
|
53
|
+
|
|
54
|
+SET ctl TO ship:control.
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+SET ctl:MAINTHROTTLE TO 0.0.
|
|
58
|
+LOCK throttle TO 0.0.
|
|
59
|
+print "Ready to orbit at "+wantedALT/1000+"km with TWR " + wantedTWR.
|
|
60
|
+HUDTEXT("Orbit "+wantedALT/1000+"km sequence ready(TWR "+wantedTWR+")", 10, 2, 20, red, false).
|
|
61
|
+HUDTEXT("Waiting 1st stage to run", 10, 2, 20, red, false).
|
|
62
|
+WAIT UNTIL not stage:ready.
|
|
63
|
+WAIT UNTIL ship:maxthrust() <> 0.
|
|
64
|
+HUDTEXT("Orbit sequence started. Lift off in 13s", 2, 2, 20, green, false).
|
|
65
|
+GETVOICE(0):PLAY( LIST(
|
|
66
|
+ SLIDENOTE(300, 320, 0.45, .5), SLIDENOTE(320, 300, 0.42, 0.5),
|
|
67
|
+ SLIDENOTE(300, 320, 0.45, .5), SLIDENOTE(320, 300, 0.42, 0.5),
|
|
68
|
+ SLIDENOTE(300, 320, 0.45, .5), SLIDENOTE(320, 300, 0.42, 0.5))).
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+HUDTEXT("Throttle will be " + round(getTwrThrust(wantedTWR)*100) + "% for TWR " + wantedTWR, 5, 2, 20, green, false).
|
|
72
|
+print "Throttle at takeoff :" + round(getTwrThrust(wantedTWR)*100) + "% for TWR " + wantedTWR.
|
|
73
|
+WAIT 2.0.
|
|
74
|
+HUDTEXT("Moving controls in all directions...", 3, 2, 15, blue, false).
|
|
75
|
+SET ctl:yaw TO -1.0.
|
|
76
|
+SET ctl:pitch TO -1.0.
|
|
77
|
+SET ctl:roll TO -1.0.
|
|
78
|
+WAIT 1.0.
|
|
79
|
+HUDTEXT("So cool !", 3, 2, 12, blue, false).
|
|
80
|
+SET ctl:yaw TO 1.0.
|
|
81
|
+SET ctl:pitch TO 1.0.
|
|
82
|
+SET ctl:roll TO 1.0.
|
|
83
|
+WAIT 1.0.
|
|
84
|
+SET ctl:yaw TO 0.0.
|
|
85
|
+SET ctl:pitch TO 0.0.
|
|
86
|
+SET ctl:roll TO 0.0.
|
|
87
|
+WAIT 1.0.
|
|
88
|
+
|
|
89
|
+DECLARE i TO 10.
|
|
90
|
+UNTIL i < 1 {
|
|
91
|
+ HUDTEXT(i, 1, 2, 20, green, false).
|
|
92
|
+ print i+" " AT (0,7).
|
|
93
|
+ GETVOICE(0):PLAY( NOTE(300, .2) ).
|
|
94
|
+ wait(1.0).
|
|
95
|
+ SET i TO i - 1.
|
|
96
|
+}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+lock THROTTLE to getTwrThrust(wantedTWR).
|
|
100
|
+HUDTEXT("Lift off !", 2, 2, 20, green, false).
|
|
101
|
+GETVOICE(0):PLAY( NOTE(400, .1) ).wait(0.1).GETVOICE(0):PLAY( NOTE(300, .2) ).
|
|
102
|
+DECLARE start TO TIME.
|
|
103
|
+print "-----------------------------------------".
|
|
104
|
+print dt() + " Lift off !".
|
|
105
|
+
|
|
106
|
+UNTIL spd() > 1 {
|
|
107
|
+ WAIT 0.1.
|
|
108
|
+}
|
|
109
|
+
|
|
110
|
+HUDTEXT(dt()+" Rotation 0", 2, 2, 20, green, false).
|
|
111
|
+GETVOICE(0):PLAY( NOTE(400, .1) ).wait(0.1).GETVOICE(0):PLAY( NOTE(400, .1) ).
|
|
112
|
+lock STEERING to HEADING(wantedHEAD,90).
|
|
113
|
+print dt() + " Heading "+ wantedHEAD.
|
|
114
|
+
|
|
115
|
+UNTIL spd() > 50 {
|
|
116
|
+ WAIT 0.1.
|
|
117
|
+}
|
|
118
|
+
|
|
119
|
+HUDTEXT(dt()+" Rotation 1", 2, 2, 20, green, false).
|
|
120
|
+GETVOICE(0):PLAY( NOTE(400, .1) ).wait(0.1).GETVOICE(0):PLAY( NOTE(300, .2) ).
|
|
121
|
+
|
|
122
|
+SET tgt_spd TO 600.
|
|
123
|
+print dt() + " Next rotation at "+tgt_spd+" m/s".
|
|
124
|
+
|
|
125
|
+lock STEERING to HEADING(wantedHEAD,70).
|
|
126
|
+
|
|
127
|
+UNTIL spd() > tgt_spd {
|
|
128
|
+ WAIT 0.1.
|
|
129
|
+}
|
|
130
|
+
|
|
131
|
+HUDTEXT(dt()+" Rotation 2", 2, 2, 20, green, false).
|
|
132
|
+GETVOICE(0):PLAY( NOTE(400, .1) ).wait(0.1).GETVOICE(0):PLAY( NOTE(300, .2) ).
|
|
133
|
+print dt() + " Last rotation 1000 m/s".
|
|
134
|
+
|
|
135
|
+//declare function endrot {
|
|
136
|
+// return 60 - ((spd() - tgt_spd) * (60 - 10) / (1000 - tgt_spd)).
|
|
137
|
+//}
|
|
138
|
+//lock STEERING to HEADING(wantedHEAD,endrot()).
|
|
139
|
+//WAIT UNTIL spd() > 1000 or SHIP:ORBIT:APOAPSIS > wantedALT.
|
|
140
|
+//if endrot() >= 10 {
|
|
141
|
+// LOCK STEERING to HEADING(wantedHEAD, 10).
|
|
142
|
+//} else {
|
|
143
|
+// LOCK STEERING to ship:prograde.
|
|
144
|
+//}
|
|
145
|
+
|
|
146
|
+UNTIL spd() > 1000 {
|
|
147
|
+ LOCK STEERING to ship:prograde.
|
|
148
|
+ WAIT 0.1.
|
|
149
|
+}
|
|
150
|
+LOCK STEERING to ship:prograde.
|
|
151
|
+
|
|
152
|
+HUDTEXT("Waiting for AP to reach 80km", 5, 2, 20, green, false).
|
|
153
|
+GETVOICE(0):PLAY( NOTE(400, .1) ).wait(0.1).GETVOICE(0):PLAY( NOTE(300, .2) ).
|
|
154
|
+print dt() + " Waiting for AP to reach "+wantedALT/1000+"km".
|
|
155
|
+
|
|
156
|
+WAIT UNTIL SHIP:ORBIT:APOAPSIS > wantedALT.
|
|
157
|
+
|
|
158
|
+HUDTEXT("Apoapsis 100km reached", 5, 2, 20, green, false).
|
|
159
|
+GETVOICE(0):PLAY( LIST(NOTE(300, .1),NOTE(400, .2),NOTE(400, 0.2), NOTE(220,0.2)) ).
|
|
160
|
+
|
|
161
|
+UNLOCK throttle.
|
|
162
|
+SET ctl:MAINTHROTTLE TO 0.0.
|
|
163
|
+LOCK THROTTLE to 0.0.
|
|
164
|
+LOCK steering TO ship:prograde.
|
|
165
|
+print dt() + " Engine cut-off".
|
|
166
|
+print dt() + " Waiting for AP. ETA : " + ROUND(ETA:APOAPSIS) + "s".
|
|
167
|
+
|
|
168
|
+// TODO : calculate timeout given TWR
|
|
169
|
+SET ins_alrm TO addAlarm("Maneuver",time:seconds+(ETA:APOAPSIS - maneuver_prep + 0.6), "[kOS] "+(wantedALT/1000)+"km orbit insertion", "Targeting "+(wantedALT/1000)+"km").
|
|
170
|
+
|
|
171
|
+WAIT UNTIL MOD(round(eta:apoapsis), 5) = 0.
|
|
172
|
+UNTIL ETA:APOAPSIS < maneuver_prep {
|
|
173
|
+ if wantedALT - SHIP:ORBIT:APOAPSIS > 100 {
|
|
174
|
+ LOCK throttle TO 1.0.
|
|
175
|
+ WAIT UNTIL SHIP:ORBIT:APOAPSIS > wantedALT.
|
|
176
|
+ LOCK throttle TO 0.0.
|
|
177
|
+ }
|
|
178
|
+ if MOD(round(ETA:APOAPSIS), 5) = 0 {
|
|
179
|
+ HUDTEXT("Time to apoapsis " + round(eta:apoapsis) + "s", 5, 2, 20, green, false).
|
|
180
|
+ HUDTEXT("Time to insertion maneuver " + round(eta:apoapsis) - maneuver_prep + "s", 5, 2, 20, green, false).
|
|
181
|
+ }
|
|
182
|
+ WAIT .3.
|
|
183
|
+}
|
|
184
|
+DELETEALARM(ins_alrm:id).
|
|
185
|
+
|
|
186
|
+LOCK steering TO ship:prograde.
|
|
187
|
+DECLARE prev_ETA to ETA:APOAPSIS.
|
|
188
|
+LOCK throttle TO 1.0.
|
|
189
|
+SET throt TO SHIP:CONTROL:MAINTHROTTLE.
|
|
190
|
+SET throt_min TO 0.7.
|
|
191
|
+SET throt_brk TO 0.2.
|
|
192
|
+
|
|
193
|
+print dt() + " Starting insertion".
|
|
194
|
+GETVOICE(0):PLAY( NOTE(300, .1) ).wait(0.1).GETVOICE(0):PLAY( NOTE(400, .2) ).
|
|
195
|
+HUDTEXT("Starting insertion", 5, 2, 20, green, false).
|
|
196
|
+
|
|
197
|
+// TODO : Problem occurs when there is stages left to drop
|
|
198
|
+// causing wrong estimation overtaking AP
|
|
199
|
+UNTIL SHIP:ORBIT:PERIAPSIS > wantedALT {
|
|
200
|
+ SET dETA TO ETA:APOAPSIS - prev_ETA.
|
|
201
|
+ if ETA:APOAPSIS > 120 {
|
|
202
|
+ print dt() + " AP behind us ! Full thrust to safe orbit !".
|
|
203
|
+ HUDTEXT("AP behind us ! Full thrust for orbit !", 0.1 ,2,20, red, false).
|
|
204
|
+ SET throt TO 1.0.
|
|
205
|
+ WAIT UNTIL SHIP:ORBIT:PERIAPSIS > 68000.
|
|
206
|
+ HUDTEXT("Wrong orbitreached "+dt(), 25, 2, 20, red, false).
|
|
207
|
+ break.
|
|
208
|
+ } else {
|
|
209
|
+ if dETA < 0 {
|
|
210
|
+ SET throt to throt + 0.0005.
|
|
211
|
+ if throt > 1.0 {
|
|
212
|
+ print dt() + "Node approach, notenough thrust !!".
|
|
213
|
+ SET throt TO 1.0.
|
|
214
|
+ WAIT 1.0.
|
|
215
|
+ }
|
|
216
|
+ if throt < throt_min - throt_brk {
|
|
217
|
+ GETVOICE(0):PLAY( SLIDENOTE(220,250, .3, .3) ).
|
|
218
|
+ set throt to throt_min.
|
|
219
|
+ } else {
|
|
220
|
+ //GETVOICE(0):PLAY( NOTE(300 + ((throt - .5) * 500), .1) ).
|
|
221
|
+ }
|
|
222
|
+ }
|
|
223
|
+ if dETA > 0 {
|
|
224
|
+ SET throt TO throt - 0.0005.
|
|
225
|
+ if throt < 0.0 {
|
|
226
|
+ print "Failing ! Node escape, WTF !!".
|
|
227
|
+ SET throt TO 0.
|
|
228
|
+ } else {
|
|
229
|
+ if throt < throt_min - throt_brk AND ETA:APOAPSIS > 10
|
|
230
|
+ {
|
|
231
|
+ // Breaking !
|
|
232
|
+ GETVOICE(0):PLAY( SLIDENOTE(250, 220, .3, .3) ).
|
|
233
|
+ SET throt TO 0.
|
|
234
|
+ LOCK throttle TO 0.
|
|
235
|
+ print "AP ETA " + round(ETA:APOAPSIS,1) + "s throttle BREAK" AT (0, terminal:height - 1).
|
|
236
|
+ if ETA:APOAPSIS > 20 {
|
|
237
|
+ WAIT((ETA:APOAPSIS / 3.5)-0.1).
|
|
238
|
+ } else {
|
|
239
|
+ if ETA:APOAPSIS > 10 {
|
|
240
|
+ WAIT 1.0.
|
|
241
|
+ }
|
|
242
|
+ }
|
|
243
|
+ } else {
|
|
244
|
+ //GETVOICE(0):PLAY( NOTE(300 + ((throt - .5) * 500), .1) ).
|
|
245
|
+ }
|
|
246
|
+ }
|
|
247
|
+ }
|
|
248
|
+ }
|
|
249
|
+ //SET SHIP:CONTROL:MAINTHROTTLE TO throt.
|
|
250
|
+ //SET SHIP:CONTROL:PILOTMAINTHROTTLE TO throt.
|
|
251
|
+ LOCK throttle TO throt.
|
|
252
|
+ //LOCK throttle TO throt.
|
|
253
|
+ SET prev_ETA to ETA:APOAPSIS.
|
|
254
|
+ print "AP ETA " + round(ETA:APOAPSIS,1) + "s throttle "+ round(throt * 100) + "% " AT (0, terminal:height - 1).
|
|
255
|
+ //HUDTEXT("AP ETA " + ETA:APOAPSIS + "s throttle "+ throt * 100 + "%", 0.1,2,20, green, false).
|
|
256
|
+ WAIT 0.
|
|
257
|
+}
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+print dt() + " Orbiting !".
|
|
261
|
+HUDTEXT("Orbiting after "+dt(), 15, 2, 20, green, false).
|
|
262
|
+HUDTEXT("programs exiting...", 15, 2, 20, red, false).
|
|
263
|
+GETVOICE(0):PLAY( LIST(
|
|
264
|
+ SLIDENOTE(300, 320, 0.3, .3), SLIDENOTE(320, 300, 0.3, 0.3),
|
|
265
|
+ SLIDENOTE(300, 320, 0.3, .3), SLIDENOTE(320, 300, 0.3, 0.3),
|
|
266
|
+ SLIDENOTE(300, 320, 0.3, .3), SLIDENOTE(320, 300, 0.3, 0.3))).
|
|
267
|
+
|
|
268
|
+unlock STEERING.
|
|
269
|
+unlock throttle.
|
|
270
|
+SET SHIP:CONTROL:MAINTHROTTLE TO 0.0.
|
|
271
|
+SET SHIP:CONTROL:PILOTMAINTHROTTLE TO 0.0.
|