-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforward.py
More file actions
executable file
·31 lines (26 loc) · 1.06 KB
/
forward.py
File metadata and controls
executable file
·31 lines (26 loc) · 1.06 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
#!/usr/bin/env python
from pymocap.manager import Manager
from pymocap.readers.natnet_reader import NatnetReader
from pymocap.writers.osc_writer import OscWriter
import sys
# config
natnet_host = '0.0.0.0' if len(sys.argv) < 2 else sys.argv[1]
natnet_multicast = '239.255.42.99' if len(sys.argv) < 3 else sys.argv[2]
natnet_port = 1511 if len(sys.argv) < 4 else sys.argv[3]
osc_host = '127.0.0.1' if len(sys.argv) < 5 else sys.argv[4]
osc_port = 8080 if len(sys.argv) < 6 else sys.argv[5]
# initialize
manager = Manager()
writer = OscWriter({'host':osc_host, 'port':osc_port, 'manager':manager})
reader = NatnetReader(manager=manager, host=natnet_host, multicast=natnet_multicast, port=natnet_port)
# execution loop
while True:
try:
# when the reader receives new data, it will process it and feed it into the manager
# the manager will trigger some events when it gets new data
# the writer will respond to the manager's events and output information
reader.update()
except KeyboardInterrupt:
break
reader.stop()
writer.stop()