Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpython_test.py
More file actions
Latest commit
162 lines (147 loc) · 7.97 KB
/
Copy pathpython_test.py
File metadata and controls
162 lines (147 loc) · 7.97 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
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
importbhaptics_python
importasyncio
importtime
asyncdefmain():
print("Hello World")
app_id=""
api_key=""
app_version=-1
result=awaitbhaptics_python.registry_and_initialize(app_id,api_key,"")
print(result)
device_index=1
whileTrue:
user_input=input("input ('q': exit): ").strip()
request_id=0
device_address=""
device_address_swap=""
event_name=""
ifuser_input=='q':
print("program exit")
break
elifuser_input=='':
continue
elifuser_input=='p':
request_id=awaitbhaptics_python.play_event(event_name)
print(f"{event_name} play_event request_id : {request_id}")
elifuser_input=='pd':
request_id=awaitbhaptics_python.play_event(event_name, device_index)
print(f"{event_name} play_event request_id : {request_id}")
elifuser_input=='s':
awaitbhaptics_python.stop_by_request_id(request_id)
elifuser_input=='o':
awaitbhaptics_python.stop_by_event_name(event_name)
elifuser_input=='a':
awaitbhaptics_python.stop_all()
elifuser_input=='d':
motor_len=40
values= [0for_inrange(motor_len)]
foriinrange(motor_len):
values[i] =40
ifi>0:
values[i-1] =0
request_id=awaitbhaptics_python.play_dot(0, 1000, values)
time.sleep(1)
elifuser_input=='dd':
motor_len=40
values= [0for_inrange(motor_len)]
foriinrange(motor_len):
values[i] =40
ifi>0:
values[i-1] =0
request_id=awaitbhaptics_python.play_dot(0, 1000, values, device_index)
time.sleep(1)
elifuser_input=='path':
x= [0.738, 0.723, 0.709, 0.696, 0.682, 0.667, 0.653, 0.639, 0.624, 0.611, 0.597, 0.584, 0.57, 0.557, 0.542, 0.528, 0.515, 0.501, 0.487, 0.474, 0.46, 0.447, 0.432, 0.419, 0.406, 0.393, 0.378, 0.365, 0.352, 0.338, 0.324, 0.311, 0.297]
y= [0.68, 0.715, 0.749, 0.782, 0.816, 0.852, 0.885, 0.921, 0.956, 0.952, 0.918, 0.885, 0.848, 0.816, 0.779, 0.743, 0.71, 0.673, 0.639, 0.606, 0.571, 0.537, 0.5, 0.467, 0.434, 0.4, 0.363, 0.329, 0.296, 0.261, 0.226, 0.192, 0.157]
values= [40for_inrange(len(x))]
foriinrange(len(x)):
slice_x= [x[i]]
slice_y= [y[i]]
slice_intensity= [values[i]]
request_id=awaitbhaptics_python.play_path(0, 1000, slice_x, slice_y, slice_intensity)
time.sleep(1)
elifuser_input=='pathd':
x= [0.738, 0.723, 0.709, 0.696, 0.682, 0.667, 0.653, 0.639, 0.624, 0.611, 0.597, 0.584, 0.57, 0.557, 0.542, 0.528, 0.515, 0.501, 0.487, 0.474, 0.46, 0.447, 0.432, 0.419, 0.406, 0.393, 0.378, 0.365, 0.352, 0.338, 0.324, 0.311, 0.297]
y= [0.68, 0.715, 0.749, 0.782, 0.816, 0.852, 0.885, 0.921, 0.956, 0.952, 0.918, 0.885, 0.848, 0.816, 0.779, 0.743, 0.71, 0.673, 0.639, 0.606, 0.571, 0.537, 0.5, 0.467, 0.434, 0.4, 0.363, 0.329, 0.296, 0.261, 0.226, 0.192, 0.157]
values= [40for_inrange(len(x))]
foriinrange(len(x)):
slice_x= [x[i]]
slice_y= [y[i]]
slice_intensity= [values[i]]
request_id=awaitbhaptics_python.play_path(0, 1000, slice_x, slice_y, slice_intensity, device_index)
time.sleep(1)
elifuser_input=='g':
glove_len=8
repeat_count=0
motors= [100for_inrange(glove_len)]
playtimes= [8for_inrange(glove_len)]
shapes= [2for_inrange(glove_len)]
for_inrange(5):
awaitbhaptics_python.play_glove(8, motors, playtimes, shapes, repeat_count)
time.sleep(0.04)
time.sleep(0.5)
for_inrange(5):
awaitbhaptics_python.play_glove(9, motors, playtimes, shapes, repeat_count)
time.sleep(0.04)
elifuser_input=='ping':
awaitbhaptics_python.ping(device_address)
elifuser_input=='pinga':
awaitbhaptics_python.ping_all()
elifuser_input=='vsm':
awaitbhaptics_python.set_device_vsm(device_address, 400)
elifuser_input=='swap':
awaitbhaptics_python.swap_position(device_address_swap)
elifuser_input=='event':
event_time=awaitbhaptics_python.get_event_time(event_name)
print(f"get_event_time({event_name}) : {event_time}")
elifuser_input=='i':
print(f"{event_name} is_playing_event_by_request_id ({request_id}) {awaitbhaptics_python.is_playing_event_by_request_id(request_id)}")
print(f"{event_name} is_playing_event_by_event_id {awaitbhaptics_python.is_playing_event_by_event_id(event_name)}")
print(f"is_playing_event {awaitbhaptics_python.is_playing_event()}")
elifuser_input=='json':
print(f"get_device_info_json {awaitbhaptics_python.get_device_info_json()}")
print(f"get_haptic_mappings_json {awaitbhaptics_python.get_haptic_mappings_json()}")
elifuser_input=='haptic':
message=awaitbhaptics_python.get_haptic_messages(app_id, api_key, app_version)
mappings=awaitbhaptics_python.get_haptic_mappings(app_id, api_key, app_version)
print(f"get_haptic_messages {message}")
print(f"get_haptic_mappings {mappings}")
elifuser_input=='position':
foriinrange(10):
print(f"is_bhaptics_connected({i}) {awaitbhaptics_python.is_bhaptics_device_connected(i)}")
elifuser_input=='loop':
request_id=awaitbhaptics_python.play_loop(event_name, 5.0, 1.0, 0.0, 0.0, 1000, 10)
print(f"{event_name} play_loop request_id {request_id}")
elifuser_input=='result':
awaitbhaptics_python.play_without_result(event_name, 5.0, 1.0, 0.0, 0.0)
print(f"{event_name} play_without_result")
elifuser_input=='ppp':
request_id=awaitbhaptics_python.play_param(event_name, 5.0, 1.0, 0.0, 0.0)
print(f"{event_name} play_position_with_parameter request_id {request_id}")
elifuser_input=='loopd':
request_id=awaitbhaptics_python.play_loop(event_name, 5.0, 1.0, 0.0, 0.0, 1000, 10, device_index)
print(f"{event_name} play_loop request_id {request_id}")
elifuser_input=='resultd':
awaitbhaptics_python.play_without_result(event_name, 5.0, 1.0, 0.0, 0.0, device_index)
print(f"{event_name} play_without_result")
elifuser_input=='pppd':
request_id=awaitbhaptics_python.play_param(event_name, 5.0, 1.0, 0.0, 0.0, device_index)
print(f"{event_name} play_position_with_parameter request_id {request_id}")
elifuser_input=='retry':
awaitbhaptics_python.retry_initialize(app_id, api_key)
elifuser_input=='is':
print(f"is_connected {awaitbhaptics_python.is_connected()}")
elifuser_input=='close':
awaitbhaptics_python.close()
elifuser_input=='running':
print(f"is_bhaptics_player_running {awaitbhaptics_python.is_bhaptics_player_running()}")
elifuser_input=='install':
print(f"is_bhaptics_player_installed {awaitbhaptics_python.is_bhaptics_player_installed()}")
elifuser_input=='runt':
print(f"run_bhaptics_player {awaitbhaptics_python.run_bhaptics_player(true)}")
elifuser_input=='runf':
print(f"run_bhaptics_player {awaitbhaptics_python.run_bhaptics_player(false)}")
else:
# 여기에 입력값에 대한 처리를 추가할 수 있습니다.
print(f"You entered: {user_input}")
asyncio.run(main())