Bike-X
0.8
Main Page
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
OVR_DeviceMessages.h
Go to the documentation of this file.
1
/************************************************************************************
2
3
PublicHeader: OVR.h
4
Filename : OVR_DeviceMessages.h
5
Content : Definition of messages generated by devices
6
Created : February 5, 2013
7
Authors : Lee Cooper
8
9
Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
10
11
Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
12
you may not use the Oculus VR Rift SDK except in compliance with the License,
13
which is provided at the time of installation or download, or which
14
otherwise accompanies this software in either electronic or hard copy form.
15
16
You may obtain a copy of the License at
17
18
http://www.oculusvr.com/licenses/LICENSE-3.1
19
20
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
21
distributed under the License is distributed on an "AS IS" BASIS,
22
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
See the License for the specific language governing permissions and
24
limitations under the License.
25
26
*************************************************************************************/
27
28
#ifndef OVR_DeviceMessages_h
29
#define OVR_DeviceMessages_h
30
31
#include "
OVR_DeviceConstants.h
"
32
#include "
OVR_DeviceHandle.h
"
33
34
#include "
Kernel/OVR_Math.h
"
35
#include "
Kernel/OVR_Array.h
"
36
#include "
Kernel/OVR_Color.h
"
37
#include "
Kernel/OVR_String.h
"
38
39
namespace
OVR {
40
41
class
DeviceBase;
42
class
DeviceHandle;
43
class
String;
44
45
46
#define OVR_MESSAGETYPE(devName, msgIndex) ((Device_##devName << 8) | msgIndex)
47
48
// MessageType identifies the structure of the Message class; based on the message,
49
// casting can be used to obtain the exact value.
50
enum
MessageType
51
{
52
// Used for unassigned message types.
53
Message_None
= 0,
54
55
// Device Manager Messages
56
Message_DeviceAdded
=
OVR_MESSAGETYPE
(Manager, 0),
// A new device is detected by manager.
57
Message_DeviceRemoved
=
OVR_MESSAGETYPE
(Manager, 1),
// Existing device has been plugged/unplugged.
58
// Sensor Messages
59
Message_BodyFrame
=
OVR_MESSAGETYPE
(Sensor, 0),
// Emitted by sensor at regular intervals.
60
Message_ExposureFrame
=
OVR_MESSAGETYPE
(Sensor, 1),
61
Message_PixelRead
=
OVR_MESSAGETYPE
(Sensor, 2),
62
63
// Latency Tester Messages
64
Message_LatencyTestSamples
=
OVR_MESSAGETYPE
(LatencyTester, 0),
65
Message_LatencyTestColorDetected
=
OVR_MESSAGETYPE
(LatencyTester, 1),
66
Message_LatencyTestStarted
=
OVR_MESSAGETYPE
(LatencyTester, 2),
67
Message_LatencyTestButton
=
OVR_MESSAGETYPE
(LatencyTester, 3),
68
69
Message_CameraFrame
=
OVR_MESSAGETYPE
(Camera, 0),
70
Message_CameraAdded
=
OVR_MESSAGETYPE
(Camera, 1),
71
};
72
73
//-------------------------------------------------------------------------------------
74
// Base class for all messages.
75
class
Message
76
{
77
public
:
78
Message
(
MessageType
type =
Message_None
,
79
DeviceBase
* pdev = 0) :
Type
(type),
pDevice
(pdev)
80
{ }
81
82
MessageType
Type
;
// What kind of message this is.
83
DeviceBase
*
pDevice
;
// Device that emitted the message.
84
};
85
86
87
// Sensor BodyFrame notification.
88
// Sensor uses Right-Handed coordinate system to return results, with the following
89
// axis definitions:
90
// - Y Up positive
91
// - X Right Positive
92
// - Z Back Positive
93
// Rotations a counter-clockwise (CCW) while looking in the negative direction
94
// of the axis. This means they are interpreted as follows:
95
// - Roll is rotation around Z, counter-clockwise (tilting left) in XY plane.
96
// - Yaw is rotation around Y, positive for turning left.
97
// - Pitch is rotation around X, positive for pitching up.
98
99
//-------------------------------------------------------------------------------------
100
// ***** Sensor
101
102
class
MessageBodyFrame
:
public
Message
103
{
104
public
:
105
MessageBodyFrame
(
DeviceBase
* dev)
106
:
Message
(
Message_BodyFrame
, dev),
Temperature
(0.0f),
TimeDelta
(0.0f)
107
{
108
}
109
110
Vector3f
Acceleration
;
// Acceleration in m/s^2.
111
Vector3f
RotationRate
;
// Angular velocity in rad/s.
112
Vector3f
MagneticField
;
// Magnetic field strength in Gauss.
113
float
Temperature
;
// Temperature reading on sensor surface, in degrees Celsius.
114
float
TimeDelta
;
// Time passed since last Body Frame, in seconds.
115
116
// The absolute time from the host computers perspective that the message should be
117
// interpreted as. This is based on incoming timestamp and processed by a filter
118
// that syncs the clocks while attempting to keep the distance between messages
119
// device clock matching.
120
//
121
// Integration should use TimeDelta, but prediction into the future should derive
122
// the delta time from PredictToSeconds - AbsoluteTimeSeconds.
123
//
124
// This value will generally be <= the return from a call to ovr_GetTimeInSeconds(),
125
// but could be greater by under 1 ms due to system time update interrupt delays.
126
//
127
double
AbsoluteTimeSeconds
;
128
};
129
130
// Sent when we receive a device status changes (e.g.:
131
// Message_DeviceAdded, Message_DeviceRemoved).
132
class
MessageDeviceStatus
:
public
Message
133
{
134
public
:
135
MessageDeviceStatus
(
MessageType
type,
DeviceBase
* dev,
const
DeviceHandle
&hdev)
136
:
Message
(type, dev),
Handle
(hdev) { }
137
138
DeviceHandle
Handle
;
139
};
140
141
class
MessageExposureFrame
:
public
Message
142
{
143
public
:
144
MessageExposureFrame
(
DeviceBase
* dev)
145
:
Message
(
Message_ExposureFrame
, dev),
146
CameraPattern
(0),
CameraFrameCount
(0),
CameraTimeSeconds
(0) { }
147
148
UByte
CameraPattern
;
149
UInt32
CameraFrameCount
;
150
double
CameraTimeSeconds
;
151
};
152
153
class
MessagePixelRead
:
public
Message
154
{
155
public
:
156
MessagePixelRead
(
DeviceBase
* dev)
157
:
Message
(
Message_PixelRead
, dev),
158
PixelReadValue
(0),
SensorTimeSeconds
(0),
FrameTimeSeconds
(0) { }
159
160
UByte
PixelReadValue
;
161
UInt32
RawSensorTime
;
162
UInt32
RawFrameTime
;
163
double
SensorTimeSeconds
;
164
double
FrameTimeSeconds
;
165
};
166
167
//-------------------------------------------------------------------------------------
168
// ***** Latency Tester
169
170
// Sent when we receive Latency Tester samples.
171
class
MessageLatencyTestSamples
:
public
Message
172
{
173
public
:
174
MessageLatencyTestSamples
(
DeviceBase
* dev)
175
:
Message
(
Message_LatencyTestSamples
, dev)
176
{
177
}
178
179
Array<Color>
Samples
;
180
};
181
182
// Sent when a Latency Tester 'color detected' event occurs.
183
class
MessageLatencyTestColorDetected
:
public
Message
184
{
185
public
:
186
MessageLatencyTestColorDetected
(
DeviceBase
* dev)
187
:
Message
(
Message_LatencyTestColorDetected
, dev)
188
{
189
}
190
191
UInt16
Elapsed
;
192
Color
DetectedValue
;
193
Color
TargetValue
;
194
};
195
196
// Sent when a Latency Tester 'change color' event occurs.
197
class
MessageLatencyTestStarted
:
public
Message
198
{
199
public
:
200
MessageLatencyTestStarted
(
DeviceBase
* dev)
201
:
Message
(
Message_LatencyTestStarted
, dev)
202
{
203
}
204
205
Color
TargetValue
;
206
};
207
208
// Sent when a Latency Tester 'button' event occurs.
209
class
MessageLatencyTestButton
:
public
Message
210
{
211
public
:
212
MessageLatencyTestButton
(
DeviceBase
* dev)
213
:
Message
(
Message_LatencyTestButton
, dev)
214
{
215
}
216
217
};
218
219
//-------------------------------------------------------------------------------------
220
// ***** Camera
221
222
// Sent by camera, frame.
223
class
MessageCameraFrame
:
public
Message
224
{
225
public
:
226
MessageCameraFrame
(
DeviceBase
* dev)
227
:
Message
(
Message_CameraFrame
, dev),
CameraHandle
(
NULL
),
pFrameData
(
NULL
)
228
{
229
LostFrames
= 0;
230
}
231
232
void
SetInfo
(
UInt32
frameNumber,
double
timeSeconds,
UInt32
width,
UInt32
height,
UInt32
format)
233
{
234
FrameNumber
= frameNumber;
235
ArrivalTimeSeconds
= timeSeconds;
236
Width
= width;
237
Height
= height;
238
Format
= format;
239
}
240
241
void
SetData
(
const
UByte
* pdata,
UInt32
sizeInBytes)
242
{
243
pFrameData
= pdata;
244
FrameSizeInBytes
= sizeInBytes;
245
}
246
247
UInt32
FrameNumber
;
// an index of the frame
248
double
ArrivalTimeSeconds
;
// frame time in seconds, as recorded by the host computer
249
const
UByte
*
pFrameData
;
// a ptr to frame data.
250
UInt32
FrameSizeInBytes
;
// size of the data in the pFrameData.
251
UInt32
Width
,
Height
;
// width & height in pixels.
252
UInt32
Format
;
// format of pixel, see CameraDevice::PixelFormat enum
253
UInt32
LostFrames
;
// number of lost frames before this frame
254
String
DeviceIdentifier
;
// identifies the device sensing the message
255
UInt32
*
CameraHandle
;
// Identifies the camera object associated with this frame
256
};
257
258
// Sent when a new camera is connected
259
class
MessageCameraAdded
:
public
Message
260
{
261
public
:
262
MessageCameraAdded
(
DeviceBase
* dev)
263
:
Message
(
Message_CameraAdded
, dev) { }
264
265
MessageCameraAdded
(
UInt32
* cam)
266
:
Message
(
Message_CameraAdded
,
NULL
),
CameraHandle
(cam) { }
267
268
UInt32
*
CameraHandle
;
// Identifies the camera object associated with this frame
269
};
270
271
}
// namespace OVR
272
273
#endif
OVR::Message_None
Definition:
OVR_DeviceMessages.h:53
OVR_Array.h
OVR::MessageDeviceStatus
Definition:
OVR_DeviceMessages.h:132
OVR::Message_LatencyTestStarted
Definition:
OVR_DeviceMessages.h:66
OVR::MessageLatencyTestColorDetected::TargetValue
Color TargetValue
Definition:
OVR_DeviceMessages.h:193
OVR_Color.h
OVR::MessageCameraFrame
Definition:
OVR_DeviceMessages.h:223
OVR::Message_ExposureFrame
Definition:
OVR_DeviceMessages.h:60
OVR::DeviceHandle
Definition:
OVR_DeviceHandle.h:54
OVR::Message::Message
Message(MessageType type=Message_None, DeviceBase *pdev=0)
Definition:
OVR_DeviceMessages.h:78
OVR::MessageCameraFrame::SetInfo
void SetInfo(UInt32 frameNumber, double timeSeconds, UInt32 width, UInt32 height, UInt32 format)
Definition:
OVR_DeviceMessages.h:232
NULL
#define NULL
OVR::MessageBodyFrame::TimeDelta
float TimeDelta
Definition:
OVR_DeviceMessages.h:114
OVR::MessageLatencyTestColorDetected::DetectedValue
Color DetectedValue
Definition:
OVR_DeviceMessages.h:192
OVR::MessageCameraAdded
Definition:
OVR_DeviceMessages.h:259
OVR_DeviceHandle.h
OVR::MessageExposureFrame::CameraPattern
UByte CameraPattern
Definition:
OVR_DeviceMessages.h:148
OVR::Message_CameraAdded
Definition:
OVR_DeviceMessages.h:70
OVR::UInt16
uint16_t UInt16
Definition:
OVR_Types.h:251
OVR::MessageLatencyTestButton
Definition:
OVR_DeviceMessages.h:209
OVR::MessagePixelRead::RawFrameTime
UInt32 RawFrameTime
Definition:
OVR_DeviceMessages.h:162
OVR::DeviceBase
Definition:
OVR_Device.h:100
OVR::UInt32
uint32_t UInt32
Definition:
OVR_Types.h:253
OVR::MessageExposureFrame::CameraTimeSeconds
double CameraTimeSeconds
Definition:
OVR_DeviceMessages.h:150
OVR::MessageCameraFrame::pFrameData
const UByte * pFrameData
Definition:
OVR_DeviceMessages.h:249
OVR_String.h
OVR::MessageCameraFrame::DeviceIdentifier
String DeviceIdentifier
Definition:
OVR_DeviceMessages.h:254
OVR::MessageBodyFrame::MessageBodyFrame
MessageBodyFrame(DeviceBase *dev)
Definition:
OVR_DeviceMessages.h:105
OVR::MessageBodyFrame::Temperature
float Temperature
Definition:
OVR_DeviceMessages.h:113
OVR::MessageCameraAdded::MessageCameraAdded
MessageCameraAdded(UInt32 *cam)
Definition:
OVR_DeviceMessages.h:265
OVR::MessageCameraFrame::FrameNumber
UInt32 FrameNumber
Definition:
OVR_DeviceMessages.h:247
OVR::Message_DeviceRemoved
Definition:
OVR_DeviceMessages.h:57
OVR::MessageBodyFrame::Acceleration
Vector3f Acceleration
Definition:
OVR_DeviceMessages.h:110
OVR::MessageCameraFrame::LostFrames
UInt32 LostFrames
Definition:
OVR_DeviceMessages.h:253
OVR::UByte
uint8_t UByte
Definition:
OVR_Types.h:249
OVR::MessageLatencyTestSamples::Samples
Array< Color > Samples
Definition:
OVR_DeviceMessages.h:179
OVR::Array
Definition:
OVR_Array.h:747
OVR::MessageLatencyTestStarted
Definition:
OVR_DeviceMessages.h:197
OVR::Message::Type
MessageType Type
Definition:
OVR_DeviceMessages.h:82
OVR::MessageCameraFrame::Height
UInt32 Height
Definition:
OVR_DeviceMessages.h:251
OVR::MessageLatencyTestSamples
Definition:
OVR_DeviceMessages.h:171
OVR::MessageExposureFrame
Definition:
OVR_DeviceMessages.h:141
OVR::MessageCameraFrame::CameraHandle
UInt32 * CameraHandle
Definition:
OVR_DeviceMessages.h:255
OVR::MessageExposureFrame::MessageExposureFrame
MessageExposureFrame(DeviceBase *dev)
Definition:
OVR_DeviceMessages.h:144
OVR::MessageCameraFrame::MessageCameraFrame
MessageCameraFrame(DeviceBase *dev)
Definition:
OVR_DeviceMessages.h:226
OVR::String
Definition:
OVR_String.h:53
OVR::Message_LatencyTestButton
Definition:
OVR_DeviceMessages.h:67
OVR::MessagePixelRead::RawSensorTime
UInt32 RawSensorTime
Definition:
OVR_DeviceMessages.h:161
OVR::MessageLatencyTestSamples::MessageLatencyTestSamples
MessageLatencyTestSamples(DeviceBase *dev)
Definition:
OVR_DeviceMessages.h:174
OVR::MessageCameraAdded::MessageCameraAdded
MessageCameraAdded(DeviceBase *dev)
Definition:
OVR_DeviceMessages.h:262
OVR::MessageCameraFrame::ArrivalTimeSeconds
double ArrivalTimeSeconds
Definition:
OVR_DeviceMessages.h:248
OVR_DeviceConstants.h
OVR::MessagePixelRead::MessagePixelRead
MessagePixelRead(DeviceBase *dev)
Definition:
OVR_DeviceMessages.h:156
OVR::MessageCameraFrame::SetData
void SetData(const UByte *pdata, UInt32 sizeInBytes)
Definition:
OVR_DeviceMessages.h:241
OVR::MessageLatencyTestStarted::TargetValue
Color TargetValue
Definition:
OVR_DeviceMessages.h:205
OVR::Message_LatencyTestColorDetected
Definition:
OVR_DeviceMessages.h:65
OVR::MessageCameraFrame::FrameSizeInBytes
UInt32 FrameSizeInBytes
Definition:
OVR_DeviceMessages.h:250
OVR::Message
Definition:
OVR_DeviceMessages.h:75
OVR::Message_CameraFrame
Definition:
OVR_DeviceMessages.h:69
OVR::Message::pDevice
DeviceBase * pDevice
Definition:
OVR_DeviceMessages.h:83
OVR::MessageLatencyTestColorDetected::MessageLatencyTestColorDetected
MessageLatencyTestColorDetected(DeviceBase *dev)
Definition:
OVR_DeviceMessages.h:186
OVR::MessageBodyFrame::RotationRate
Vector3f RotationRate
Definition:
OVR_DeviceMessages.h:111
OVR::MessagePixelRead::SensorTimeSeconds
double SensorTimeSeconds
Definition:
OVR_DeviceMessages.h:163
OVR::MessageCameraFrame::Width
UInt32 Width
Definition:
OVR_DeviceMessages.h:251
OVR::MessageDeviceStatus::MessageDeviceStatus
MessageDeviceStatus(MessageType type, DeviceBase *dev, const DeviceHandle &hdev)
Definition:
OVR_DeviceMessages.h:135
OVR::MessageLatencyTestButton::MessageLatencyTestButton
MessageLatencyTestButton(DeviceBase *dev)
Definition:
OVR_DeviceMessages.h:212
OVR::Message_BodyFrame
Definition:
OVR_DeviceMessages.h:59
OVR::Message_DeviceAdded
Definition:
OVR_DeviceMessages.h:56
OVR::MessagePixelRead::PixelReadValue
UByte PixelReadValue
Definition:
OVR_DeviceMessages.h:160
OVR::MessageCameraAdded::CameraHandle
UInt32 * CameraHandle
Definition:
OVR_DeviceMessages.h:268
OVR::MessageDeviceStatus::Handle
DeviceHandle Handle
Definition:
OVR_DeviceMessages.h:138
OVR::MessagePixelRead
Definition:
OVR_DeviceMessages.h:153
OVR::MessageBodyFrame
Definition:
OVR_DeviceMessages.h:102
OVR::MessageLatencyTestColorDetected::Elapsed
UInt16 Elapsed
Definition:
OVR_DeviceMessages.h:191
OVR::MessageBodyFrame::MagneticField
Vector3f MagneticField
Definition:
OVR_DeviceMessages.h:112
OVR::Vector3< float >
OVR::MessageBodyFrame::AbsoluteTimeSeconds
double AbsoluteTimeSeconds
Definition:
OVR_DeviceMessages.h:127
OVR::MessageLatencyTestStarted::MessageLatencyTestStarted
MessageLatencyTestStarted(DeviceBase *dev)
Definition:
OVR_DeviceMessages.h:200
OVR::Color
Definition:
OVR_Color.h:34
OVR_Math.h
OVR::MessagePixelRead::FrameTimeSeconds
double FrameTimeSeconds
Definition:
OVR_DeviceMessages.h:164
OVR::MessageExposureFrame::CameraFrameCount
UInt32 CameraFrameCount
Definition:
OVR_DeviceMessages.h:149
OVR::Message_PixelRead
Definition:
OVR_DeviceMessages.h:61
OVR::MessageLatencyTestColorDetected
Definition:
OVR_DeviceMessages.h:183
OVR::MessageCameraFrame::Format
UInt32 Format
Definition:
OVR_DeviceMessages.h:252
OVR_MESSAGETYPE
#define OVR_MESSAGETYPE(devName, msgIndex)
Definition:
OVR_DeviceMessages.h:46
OVR::MessageType
MessageType
Definition:
OVR_DeviceMessages.h:50
OVR::Message_LatencyTestSamples
Definition:
OVR_DeviceMessages.h:64
ovr
sdk
src
OVR_DeviceMessages.h
Generated on Wed Oct 1 2014 00:45:20 for Bike-X by
1.8.6