This repository has been archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ascent.py
65 lines (42 loc) · 1.52 KB
/
ascent.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import krpc
import config
import time
import threading
from control import Control
from orbital_parameters import OrbitalParameters
class AscendModule:
update_thread = None
vessel = None
conn = None
ref_frame = None
target_parameters = None
actual_parameters = None
controller = None
ruleset = None
finish = False
def __init__(self, conn, vessel, ruleset):
self.vessel = vessel
self.conn = conn
self.ruleset = ruleset
self.ref_frame = conn.space_center.ReferenceFrame.create_hybrid(
position=vessel.orbit.body.reference_frame,
rotation=vessel.surface_reference_frame)
self.controller = Control(conn, vessel, ruleset, self.ref_frame)
self.vessel.auto_pilot.engage()
self.update_thread = threading.Thread(target=self.update, name="Ascent Update Thread")
self.update_thread.run()
print(self.update_thread)
def set_orbital_parameters(self, params):
self.target_parameters = params
def update(self):
while not self.finish:
self.actual_parameters = OrbitalParameters(self.vessel)
if self.actual_parameters == self.target_parameters:
self.stop()
self.controller.update()
#self.conn.drawing.add_direction((1, 0, 0), self.ref_frame)
#self.conn.drawing.add_direction((0, 1, 0), self.ref_frame)
time.sleep(0.1)
def stop(self):
self.finish = True
self.update_thread.join(1)