-
Notifications
You must be signed in to change notification settings - Fork 2
/
control-display.py
55 lines (45 loc) · 1.5 KB
/
control-display.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
import krpc, curses, time, sys
import numpy as np
import numpy.linalg as la
# Set up curses
stdscr = curses.initscr()
curses.nocbreak()
stdscr.keypad(1)
curses.noecho()
try:
# Connect to kRPC
conn = krpc.connect(name='Control Display')
control = conn.space_center.active_vessel.control
pitch = conn.add_stream(getattr, control, 'pitch')
yaw = conn.add_stream(getattr, control, 'yaw')
roll = conn.add_stream(getattr, control, 'roll')
throttle = conn.add_stream(getattr, control, 'throttle')
sas = conn.add_stream(getattr, control, 'sas')
sas_mode = conn.add_stream(getattr, control, 'sas_mode')
rcs = conn.add_stream(getattr, control, 'rcs')
while True:
stdscr.clear()
stdscr.addstr(0,0,'-- Controls --')
if sas():
sas_text = 'SAS enabled (%s)' % str(sas_mode()).split('.')[1]
else:
sas_text = 'SAS disabled'
if rcs():
rcs_text = 'RCS enabled'
else:
rcs_text = 'RCS disabled'
# Output information
stdscr.addstr(2,0,'Pitch: {:+6.3f}'.format(pitch()))
stdscr.addstr(3,0,'Yaw: {:+6.3f}'.format(yaw()))
stdscr.addstr(4,0,'Roll: {:+6.3f}'.format(roll()))
stdscr.addstr(5,0,'Throttle: {:>3.0f}%'.format(throttle()*100.0))
stdscr.addstr(6,0,sas_text)
stdscr.addstr(7,0,rcs_text)
stdscr.refresh()
time.sleep(0.1)
finally:
# Shutdown curses
curses.nocbreak()
stdscr.keypad(0)
curses.echo()
curses.endwin()