Ocean
AndroidFactory.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_ANDROID_ANDROID_FACTORY_H
9 #define META_OCEAN_DEVICES_ANDROID_ANDROID_FACTORY_H
10 
12 
13 #include "ocean/devices/Factory.h"
14 
15 #include <android/sensor.h>
16 
17 namespace Ocean
18 {
19 
20 namespace Devices
21 {
22 
23 namespace Android
24 {
25 
26 /**
27  * This class implements a device factory for the Android feature based tracking system.
28  * @ingroup devicesandroid
29  */
30 class OCEAN_DEVICES_ANDROID_EXPORT AndroidFactory : public Factory
31 {
32  public:
33 
34  /**
35  * Registers this factory at the manager.
36  * Beware: Unregister this factory if not needed anymore.
37  * @return True, if this factory hasn't been registered before
38  */
39  static bool registerFactory();
40 
41  /**
42  * Unregisters this factory at the manger.
43  * This unregistration should be done after all created devices have been released.
44  * @return True, if this factory could be unregistered
45  */
46  static bool unregisterFactory();
47 
48  /**
49  * Sends a new GPS location to the tracker which is managed by this factory.
50  * This function is intended for location information which is determined e.g., on the Java side.
51  * @param latitude The position's latitude, in degree, always valid, with range [-90, 90]
52  * @param longitude The position's longitude, in degree, must be valid, with range [-180, 180]
53  * @param altitude The position's altitude, in meter, NumericF::minValue() if unknown
54  * @param direction The travel direction of the device, relative to north, in degree, north is 0 degree, east is 90 degree, with range [0, 360], -1 if unknown
55  * @param speed The device's speed, in meter per second, with range [0, infinity), -1 if unknown
56  * @param accuracy The horizontal accuracy as radius, in meter, with range [0, infinity), -1 if unknown
57  * @param altitudeAccuracy The vertical accuracy in meter, with range [0, infinity), -1 if unknown
58  * @param directionAccuracy The direction accuracy, in degree, with range [0, 180], -1 if unknown
59  * @param speedAccuracy The speed accuracy, in meter per second, with range [0, infinity), -1 if unknown
60  * @param timestamp The timestamp of the GPS location, must be valid
61  */
62  static void newGPSLocation(const double latitude, const double longitude, const float altitude, const float direction, const float speed, const float accuracy, const float altitudeAccuracy, const float directionAccuracy, const float speedAccuracy, const Timestamp& timestamp);
63 
64  private:
65 
66  /**
67  * Creates a new factory.
68  */
70 
71  /**
72  * Registers all devices.
73  */
75 
76  /**
77  * Creates a new 3DOF acceleration sensor.
78  * The caller is responsible to release the sensor.
79  * @param name The name of the new device, must be valid
80  * @param deviceType The device type of the device, must be valid
81  * @return The new sensor, nullptr if the sensor could not be created
82  */
83  Device* createAndroidAccelerationSensor3DOF(const std::string& name, const Device::DeviceType& deviceType);
84 
85  /**
86  * Creates a new 3DOF linear acceleration sensor.
87  * The caller is responsible to release the sensor.
88  * @param name The name of the new device, must be valid
89  * @param deviceType The device type of the device, must be valid
90  * @return The new sensor, nullptr if the sensor could not be created
91  */
92  Device* createAndroidLinearAccelerationSensor3DOF(const std::string& name, const Device::DeviceType& deviceType);
93 
94  /**
95  * Creates a new 3DOF orientation tracker.
96  * The caller is responsible to release the tracker.
97  * @param name The name of the new device, must be valid
98  * @param deviceType The device type of the device, must be valid
99  * @return The new tracker, nullptr if the tracker could not be created
100  */
101  Device* createAndroidOrientationTracker3DOF(const std::string& name, const Device::DeviceType& deviceType);
102 
103  /**
104  * Creates a new 3DOF raw gyro sensor.
105  * The caller is responsible to release the tracker.
106  * @param name The name of the new device, must be valid
107  * @param deviceType The device type of the device, must be valid
108  * @return The new sensor, nullptr if the sensor could not be created
109  */
110  Device* createAndroidGyroRawSensor3DOF(const std::string& name, const Device::DeviceType& deviceType);
111 
112  /**
113  * Creates a new 3DOF unbiased gyro sensor.
114  * The caller is responsible to release the tracker.
115  * @param name The name of the new device, must be valid
116  * @param deviceType The device type of the device, must be valid
117  * @return The new sensor, nullptr if the sensor could not be created
118  */
119  Device* createAndroidGyroUnbiasedSensor3DOF(const std::string& name, const Device::DeviceType& deviceType);
120 
121  /**
122  * Creates a new GPS tracker.
123  * The caller is responsible to release the tracker.
124  * @param name The name of the new device, must be valid
125  * @param deviceType The device type of the device, must be valid
126  * @return The new tracker, nullptr if the tracker could not be created
127  */
128  Device* createAndroidGPSTracker(const std::string& name, const Device::DeviceType& deviceType);
129 
130  /**
131  * Creates a new 3DOF gravity tracker.
132  * The caller is responsible to release the tracker.
133  * @param name The name of the new device, must be valid
134  * @param deviceType The device type of the device, must be valid
135  * @return The new tracker, nullptr if the tracker could not be created
136  */
137  Device* createAndroidGravityTracker3DOF(const std::string& name, const Device::DeviceType& deviceType);
138 
139  /**
140  * Creates a new 3DOF heading tracker.
141  * The caller is responsible to release the tracker.
142  * @param name The name of the new device, must be valid
143  * @param deviceType The device type of the device, must be valid
144  * @return The new tracker, nullptr if the tracker could not be created
145  */
146  Device* createAndroidHeadingTracker3DOF(const std::string& name, const Device::DeviceType& deviceType);
147 
148  private:
149 
150  /// The accelerometer sensor.
151  const ASensor* sensorAccelerometer_ = nullptr;
152 
153  /// The linear accelerometer sensor.
154  const ASensor* sensorLinearAccelerometer_ = nullptr;
155 
156  /// The rotation vector sensor.
157  const ASensor* sensorRotationVector_ = nullptr;
158 
159  /// The game rotation vector sensor, this sensor does not use a magnetometer to avoid issues with changing magnetic fields near metal objects.
160  const ASensor* sensorGameRotationVector_ = nullptr;
161 
162  /// The raw gyro sensor.
163  const ASensor* sensorGyroRaw_ = nullptr;
164 
165  /// The unbiased gyro sensor.
166  const ASensor* sensorGyroUnbiased_ = nullptr;
167 
168  /// The gravity sensor.
169  const ASensor* sensorGravity_ = nullptr;
170 };
171 
172 }
173 
174 }
175 
176 }
177 
178 #endif // META_OCEAN_DEVICES_ANDROID_ANDROID_FACTORY_H
This class implements a device factory for the Android feature based tracking system.
Definition: AndroidFactory.h:31
static void newGPSLocation(const double latitude, const double longitude, const float altitude, const float direction, const float speed, const float accuracy, const float altitudeAccuracy, const float directionAccuracy, const float speedAccuracy, const Timestamp &timestamp)
Sends a new GPS location to the tracker which is managed by this factory.
static bool unregisterFactory()
Unregisters this factory at the manger.
void registerDevices()
Registers all devices.
Device * createAndroidLinearAccelerationSensor3DOF(const std::string &name, const Device::DeviceType &deviceType)
Creates a new 3DOF linear acceleration sensor.
Device * createAndroidGravityTracker3DOF(const std::string &name, const Device::DeviceType &deviceType)
Creates a new 3DOF gravity tracker.
AndroidFactory()
Creates a new factory.
Device * createAndroidAccelerationSensor3DOF(const std::string &name, const Device::DeviceType &deviceType)
Creates a new 3DOF acceleration sensor.
Device * createAndroidGPSTracker(const std::string &name, const Device::DeviceType &deviceType)
Creates a new GPS tracker.
static bool registerFactory()
Registers this factory at the manager.
Device * createAndroidHeadingTracker3DOF(const std::string &name, const Device::DeviceType &deviceType)
Creates a new 3DOF heading tracker.
Device * createAndroidGyroUnbiasedSensor3DOF(const std::string &name, const Device::DeviceType &deviceType)
Creates a new 3DOF unbiased gyro sensor.
Device * createAndroidOrientationTracker3DOF(const std::string &name, const Device::DeviceType &deviceType)
Creates a new 3DOF orientation tracker.
Device * createAndroidGyroRawSensor3DOF(const std::string &name, const Device::DeviceType &deviceType)
Creates a new 3DOF raw gyro sensor.
Definition of a class holding the major and minor device type.
Definition: devices/Device.h:62
This class is the base class for all devices of any type.
Definition: devices/Device.h:28
This class implements a factory able to create instances of devices.
Definition: devices/Factory.h:28
This class implements a timestamp.
Definition: Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15