forked from Seneral/SerialHMD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerialComm.txt
156 lines (119 loc) · 3.55 KB
/
SerialComm.txt
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
GOAL: Low-latency serial communication between OpenVR driver and IMU device
IMU Device:
RPI0 (+ RTIMULib2):
- High latency due to overhead and threading
+ Reusability: same setup for future project
+ Guaranteed best algorithms for interpreting IMU data
+ Library includes Calibration
Arduino (+ IMU specific library):
+ Lowest Latency possible
- No algorithms for interpreting IMU data ?
- No on-board calibration ?
{ OPEN VR DRIVER
vrHMD connected:
// TODO, check Serial Ports for connected headset:
Get all valid connected serial ports
1. Check identification of device
2. If not necessarily unique, send serial to request ID
vrHMD init:
If not done already, send serial to request ID
Send serial to start stream of pose data
Start thread
Thread:
volatile bool abort
while true:
read latest serial data
write pose to TrackedDevicePoseUpdated
if abort: abort
vrHMD close:
Set thread abort
Wait for thread join
}
{ RPI0?
Startup:
Initiate interval check
Interval check (1s):
Read serial data to check for requests
Answer request for ID, stream start, stream abort
While streaming, retain interval to check for abort?
If abort: abort
--OR incorporate abort serial read in Thread?--
Send ID:
Send some hardcoded values for identification purposes
Start Stream:
Start separate streaming thread with high priority
Thread:
volatile bool abort
while true:
Read latest IMU data
Write data to serial ports
If not done in main thread:
Read serial to check for abort request
If abort: abort
End Stream
Set thread abort
Wait for thread join
}
{ Arduino?
bool send
Init:
Loop:
if send:
Read latest IMU data
Write data to serial port
Read serial to check for abort: Toggle send
else:
Read serial data to check for request
Request for ID: Send ID
Request for stream start, stream abort: Toggle send
Wait for 1s
}
{ Communication Protocol
Request/Response Format with variable codes (Key: [#_# / #_*(_)#])
Stream Format with limited ID, designed for throughput: 1 Byte ID, fixed number of bytes, next stream or command
Singular Request / Push / Response Format: #ID# / #ID*D#
Identifier 'ID' 1 byte, Data 'D' variable length
Default IDs: I - Identification, S - Stream/Source
Register / Deliver new Stream: #T*ID#
Identifier 'ID' and Type 'T' both one byte
Types: H - Head, S - Skeleton, C - Controller
Request fo
Start Head Tracking Stream Request: #1*H# (with ID 1)
Stream Response Format: 1 ID Byte,
M-S Identification Request: #I# #I*SerialHMD-DIY# (Identified as SerialHMD)
M-S Request Streams: #S# #S*HC# (1 Head & 1 Controller)
M-S Register Streams: #H*1# #C*2# #H*1# #C*2# (Register Head-1 and Controller-2)
S-M-S Push new Sources: #S*C# #C*3# #C*3# (New Controller connected and registered as 3)
Example Comm:
#I# #I*SerialHMD-DIY#
#S# #S*H#
#H*1# #1#
1YYYYPPPPRRRR
1YYYYPPPPRRRR
1YYYYPPPPRRRR
1YYYYPPPPRRRR
#S*C#
1YYYYPPPPRRRR
1YYYYPPPPRRRR
#C*2# #2#
2YYPPRRXXYY00
1YYYYPPPPRRRR
1YYYYPPPPRRRR
1YYYYPPPPRRRR
1YYYYPPPPRRRR
2YYPPRRXXYY20 // Button 2 pressed
1YYYYPPPPRRRR
1YYYYPPPPRRRR
1YYYYPPPPRRRR
1YYYYPPPPRRRR
2YYPPRRXXYY25 // Button 2 & 5 pressed
1YYYYPPPPRRRR
1YYYYPPPPRRRR
1YYYYPPPPRRRR
1YYYYPPPPRRRR
2YYPPRRXXYY50 // Button 5 pressed, Button 2 released
1YYYYPPPPRRRR
1YYYYPPPPRRRR
1YYYYPPPPRRRR
1YYYYPPPPRRRR
}