Bike-X  0.8
 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.
51 {
52  // Used for unassigned message types.
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.
62 
63  // Latency Tester Messages
68 
71 };
72 
73 //-------------------------------------------------------------------------------------
74 // Base class for all messages.
75 class Message
76 {
77 public:
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:
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  //
128 };
129 
130 // Sent when we receive a device status changes (e.g.:
131 // Message_DeviceAdded, Message_DeviceRemoved).
133 {
134 public:
136  : Message(type, dev), Handle(hdev) { }
137 
139 };
140 
142 {
143 public:
147 
151 };
152 
153 class MessagePixelRead : public Message
154 {
155 public:
157  : Message(Message_PixelRead, dev),
159 
165 };
166 
167 //-------------------------------------------------------------------------------------
168 // ***** Latency Tester
169 
170 // Sent when we receive Latency Tester samples.
172 {
173 public:
176  {
177  }
178 
180 };
181 
182 // Sent when a Latency Tester 'color detected' event occurs.
184 {
185 public:
188  {
189  }
190 
194 };
195 
196 // Sent when a Latency Tester 'change color' event occurs.
198 {
199 public:
202  {
203  }
204 
206 };
207 
208 // Sent when a Latency Tester 'button' event occurs.
210 {
211 public:
214  {
215  }
216 
217 };
218 
219 //-------------------------------------------------------------------------------------
220 // ***** Camera
221 
222 // Sent by camera, frame.
224 {
225 public:
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
260 {
261 public:
263  : Message(Message_CameraAdded, dev) { }
264 
267 
268  UInt32* CameraHandle; // Identifies the camera object associated with this frame
269 };
270 
271 } // namespace OVR
272 
273 #endif
Message(MessageType type=Message_None, DeviceBase *pdev=0)
void SetInfo(UInt32 frameNumber, double timeSeconds, UInt32 width, UInt32 height, UInt32 format)
#define NULL
uint16_t UInt16
Definition: OVR_Types.h:251
uint32_t UInt32
Definition: OVR_Types.h:253
MessageBodyFrame(DeviceBase *dev)
uint8_t UByte
Definition: OVR_Types.h:249
MessageType Type
MessageExposureFrame(DeviceBase *dev)
MessageCameraFrame(DeviceBase *dev)
MessageLatencyTestSamples(DeviceBase *dev)
MessageCameraAdded(DeviceBase *dev)
MessagePixelRead(DeviceBase *dev)
void SetData(const UByte *pdata, UInt32 sizeInBytes)
DeviceBase * pDevice
MessageDeviceStatus(MessageType type, DeviceBase *dev, const DeviceHandle &hdev)
MessageLatencyTestButton(DeviceBase *dev)
MessageLatencyTestStarted(DeviceBase *dev)
#define OVR_MESSAGETYPE(devName, msgIndex)