Ocean
IOSOrientationTracker3DOF.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_DEVICES_IOS_IOS_ORIENTATION_TRACKER_3_DOF_H
9 #define META_OCEAN_DEVICES_IOS_IOS_ORIENTATION_TRACKER_3_DOF_H
10 
11 #include "ocean/devices/ios/IOS.h"
14 
16 
17 namespace Ocean
18 {
19 
20 namespace Devices
21 {
22 
23 namespace IOS
24 {
25 
26 /**
27  * This class implements all 3DOF orientation tracker purely based on the IMU information of the device.
28  * The resulting transformation (3DOF orientation) is defined w.r.t. the world coordinate system.<br>
29  * That means the transformation will transform points defined in the coordinate system of the device into points defined in the world coordinate system (pointWorld = wTd * pointDevice).<br>
30  * When holding the device (in portrait mode), the x-axis points towards the right of the device, the y-axis points upwards, and the z-axis points towards the user:<br>
31  * <pre>
32  * device top
33  * ...........................
34  * . .
35  * . ^ .
36  * . Y | .
37  * . | .
38  * . | .
39  * . O ---------> .
40  * . / X .
41  * . / Z .
42  * . v .
43  * . .
44  * ...........................
45  * . home button .
46  * ...........................
47  * device bottom
48  * </pre>
49  * The x-axis and y-axis of the world coordinate system will be arbitrary.<br>
50  * The negative z-axis of the world coordinate system will always point towards the ground (the negative z-axis is identical with the gravity vector).
51  *
52  * Beware: The coordinate system of the camera may be different from the coordinate system of the device.<br>
53  * E.g., the image of an iPhone camera is commonly located in the upper right corner of the device,<br>
54  * with horizontal image axis pointing to the bottom of the device (along the negative y-axis of the device),
55  * and with vertical image axis pointing to the left of the device (along the negative x-axis of the device).
56  * @ingroup devicesios
57  */
58 class OCEAN_DEVICES_IOS_EXPORT IOSOrientationTracker3DOF :
59  virtual public IOSDevice,
60  virtual public OrientationTracker3DOF
61 {
62  friend class IOSFactory;
63 
64  public:
65 
66  /**
67  * Starts the device.
68  * @see Device::start().
69  */
70  bool start() override;
71 
72  /**
73  * Pauses the device.
74  * @see Device::pause().
75  */
76  bool pause() override;
77 
78  /**
79  * Stops the device.
80  * @see Device::stop().
81  */
82  bool stop() override;
83 
84  /**
85  * Returns the name of this sensor.
86  * @return The sensor's name
87  */
88  static inline std::string deviceNameIOSOrientationTracker3DOF();
89 
90  protected:
91 
92  /**
93  * Creates a new 3DOF orientation tracker device.
94  */
96 
97  /**
98  * Destructs a 3DOF orientation sensor device.
99  */
101 
102  private:
103 
104  /**
105  * Callback function for obtaining new samples from the device.
106  * @param deviceMotion iOS DeviceMotion readout
107  */
108  void onDeviceMotion(CMDeviceMotion* deviceMotion);
109 
110  private:
111 
112  // Callback id for this tracker.
114 
115  /// The object id of this tracker.
116  ObjectId trackerObjectId_ = invalidObjectId();
117 };
118 
120 {
121  return std::string("IOS 3DOF Orientation Tracker");
122 }
123 
124 }
125 
126 }
127 
128 }
129 
130 #endif // META_OCEAN_DEVICES_IOS_IOS_ORIENTATION_TRACKER_3_DOF_H
This class implements a device for the IOS library.
Definition: IOSDevice.h:29
This class implements a device factory for the IOS feature based tracking system.
Definition: IOSFactory.h:29
This class implements all 3DOF orientation tracker purely based on the IMU information of the device.
Definition: IOSOrientationTracker3DOF.h:61
IOSOrientationTracker3DOF()
Creates a new 3DOF orientation tracker device.
bool stop() override
Stops the device.
bool pause() override
Pauses the device.
static std::string deviceNameIOSOrientationTracker3DOF()
Returns the name of this sensor.
Definition: IOSOrientationTracker3DOF.h:119
void onDeviceMotion(CMDeviceMotion *deviceMotion)
Callback function for obtaining new samples from the device.
bool start() override
Starts the device.
~IOSOrientationTracker3DOF() override
Destructs a 3DOF orientation sensor device.
static constexpr ListenerId invalidListenerId()
Returns an invalid listener id.
Definition: MotionManager.h:121
unsigned int ListenerId
Definition of a listener id for a registered callbacks.
Definition: MotionManager.h:43
unsigned int ObjectId
Definition of an object id.
Definition: Measurement.h:46
This class is the base class for all 3DOF orientation tracker objects.
Definition: OrientationTracker3DOF.h:38
const ObjectId invalidObjectId
Definition of an invalid object id.
Definition: rendering/Rendering.h:65
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15