-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch_ship.py
More file actions
executable file
·50 lines (37 loc) · 1 KB
/
launch_ship.py
File metadata and controls
executable file
·50 lines (37 loc) · 1 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
#!/usr/bin/env python
import sys
import signal
import atexit
from base_config import str2bool
import base_config
from state_machine import state_machine
import time
print(chr(27)+'[2j')
print('\033c')
print('\x1bc')
def abort():
sm.abort()
sys.exit(0)
def handle_ctrlc(sig, frame):
sm.abort()
sys.exit(0)
signal.signal(signal.SIGINT, handle_ctrlc)
atexit.register(abort)
#config = "single_stage_leo"
#config = "two_stage_leo"
config = "kerbalx"
conn = base_config.begin()
sm = state_machine(conn, conn.space_center.active_vessel, "configs/" + config)
# Add the callback to trigger abort from in-game
abort = conn.add_stream(getattr, sm.vehicle.control, 'abort')
abort.add_callback(sm.abort)
abort.start()
print("Beginning launch with %s config" % config)
sm.trans('pre_hold')
while sm.state != "abort":
next_state = sm.flight.ready_for_state_change()
if next_state:
print("Transitioning to %s" % next_state)
sm.trans(next_state)
if sm.engines_need_update:
sm.flight.update_engines()