-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlog_position.py
More file actions
29 lines (25 loc) · 761 Bytes
/
Copy pathlog_position.py
File metadata and controls
29 lines (25 loc) · 761 Bytes
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
import sys
from unrealcv import client
from pynput import keyboard
client.connect()
def _onkeypress(key):
try: k = key.char # single-char keys
except: k = key.name # other keys
#check for quit condition
if key == keyboard.Key.esc:
print("LOG INFO: Time to quit")
return False
try:
if k == 'p': #On pressing 'p', capture position.
pose = client.request('vget /camera/0/pose')
print("[{}]".format(pose))
#You can do the rest.
except:
pass
def main():
keyboard_listener = keyboard.Listener(on_press=_onkeypress)
keyboard_listener.start()
keyboard_listener.join()
print("LOG INFO: Quit command completed")
if __name__ == "__main__":
sys.exit(main())