-
Notifications
You must be signed in to change notification settings - Fork 1
/
osc_test.py
51 lines (48 loc) · 2.28 KB
/
osc_test.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
from pythonosc import dispatcher, osc_server, udp_client, osc_message_builder
from osc_server import broadcast_state
from util import osc_dispatch
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument( "--state", dest="new-state",
help="set teh new state", metavar="STATE")
parser.add_argument( "--action", dest="action",
help="set teh new action", metavar="ACTION")
parser.add_argument('--surface', action='store_true', default=False, help="send dummy surface data")
parser.add_argument('--startsurface', action='store_true', default=False, help="test surface start")
parser.add_argument('--resetsurface', action='store_true', default=False, help="test surface reset")
parser.add_argument('--stopsurface', action='store_true', default=False, help="test surface stop")
# Parse Args
args = parser.parse_args()
print("Arguments: ", args)
args = parser.parse_args()
if vars(args)['new-state']:
state = vars(args)['new-state']
action = vars(args)['action']
print('changing state and action to {},{}'.format(state, action))
osc_dispatch('/newstate',state)
if action == 'talking':
osc_dispatch('/talking', 1, ip="0.0.0.0", num_tries=4)
elif action == 'thinking':
osc_dispatch('/thinking', 1)
elif action == 'expectant':
osc_dispatch("/silent", 1)
elif action == 'start':
osc_dispatch("/reset", 1)
elif action == 'stop':
osc_dispatch("/end", 1)
else:
print("No Action Recognized")
elif args.startsurface:
print("Telling surfaces to turn on")
osc_dispatch('/startsurface', 1)
elif args.stopsurface:
print("Telling surfaces to close")
osc_dispatch('/closesurface', 1)
elif args.resetsurface:
print("Telling surfaces to start over")
osc_dispatch('/resetsurface', 1)
elif args.surface:
print("Sending Surface Message")
## foo = json.loads('{"number": 1.0, "other": 4.3}')
osc_dispatch('/surface-sentiments', '{"sentiment": 0.15, "focus": 0.65, "energy": -0.3, "unit": "test", "words": ["inspired", "anxious", "understanding"], "parts": ["hand", "eye", "head"]}')