forked from djungelorm/krpc-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kerbal-x.py
33 lines (27 loc) · 845 Bytes
/
kerbal-x.py
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
import krpc
import time
from krpctoolkit.launch import Ascend
from krpctoolkit.staging import AutoStage
from krpctoolkit.maneuver import circularize, ExecuteNode
target_altitude = 120000
conn = krpc.connect(name='Kerbal-X')
vessel = conn.space_center.active_vessel
print('Launching')
ascend = Ascend(conn, vessel, target_altitude)
staging = AutoStage(conn, vessel)
while not ascend():
staging()
time.sleep(0.1)
print('Coasting out of atmosphere')
altitude = conn.add_stream(getattr, vessel.flight(), 'mean_altitude')
atmosphere_altitude = vessel.orbit.body.atmosphere_depth * 1.01
while altitude() < atmosphere_altitude:
pass
print('Circularizing')
vessel.control.remove_nodes()
node = circularize(conn, vessel)
execute = ExecuteNode(conn, vessel, node)
while not execute():
time.sleep(0.1)
node.remove()
print('Complete')