-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalthrust.ks
More file actions
52 lines (39 loc) · 1.12 KB
/
calthrust.ks
File metadata and controls
52 lines (39 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
@LAZYGLOBAL OFF.
PARAMETER targetTWR.
LOCAL engineList IS LIST().
LOCAL currentThrustLimit TO 100.
LOCK currentTWR TO SHIP:AVAILABLETHRUST/(SHIP:MASS*SHIP:SENSORS:GRAV:MAG).
CLEARSCREEN.
// Reset thrust limits.
LIST ENGINES IN engineList.
FOR engine IN engineList {
SET engine:THRUSTLIMIT TO currentThrustLimit.
}
// TODO: Change to calibrate just above the target TWR.
// For example, if the next iteration brings the current TWR
// below the target TWR, undo the last change to the thrust
// limit and stop there. Being just above the target is
// better than being below.
PRINT "Calibrating...".
UNTIL FALSE {
// Check if current TWR is more than target TWR.
IF currentTWR > targetTWR {
SET currentThrustLimit TO currentThrustLimit - 0.5.
IF currentThrustLimit < 5 {
SET currentThrustLimit TO 5.
}
// Limit thrust on engines.
LIST ENGINES IN engineList.
FOR engine IN engineList {
SET engine:THRUSTLIMIT TO currentThrustLimit.
}
IF currentThrustLimit = 5 {
// It's as low as we can go.
BREAK.
}
} ELSE {
BREAK.
}
}
PRINT "Final TWR: " + currentTWR.
PRINT "Calibration complete!".