Ocean
AndroidGyroSensor3DOF.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_GYRO_SENSOR_3_DOF_H
9 #define META_OCEAN_DEVICES_ANDROID_ANDROID_GYRO_SENSOR_3_DOF_H
10 
13 
15 
16 namespace Ocean
17 {
18 
19 namespace Devices
20 {
21 
22 namespace Android
23 {
24 
25 /**
26  * This class implements all 3DOF acceleration sensors (including the linear acceleration sensors).
27  * @ingroup devicesandroid
28  */
29 class OCEAN_DEVICES_EXPORT AndroidGyroSensor3DOF :
30  virtual public AndroidSensor,
31  virtual public GyroSensor3DOF
32 {
33  friend class AndroidFactory;
34 
35  public:
36 
37  /**
38  * Returns the name of this sensor.
39  * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_GYRO_RAW_3DOF or SENSOR_GYRO_UNBIASED_3DOF
40  * @return The sensor's name
41  */
42  static inline std::string deviceNameAndroidGyroSensor3DOF(const SensorType sensorType);
43 
44  /**
45  * Returns the device type of this sensor.
46  * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_GYRO_RAW_3DOF or SENSOR_GYRO_UNBIASED_3DOF
47  * @return The sensor's device type
48  */
49  static inline DeviceType deviceTypeAndroidGyroSensor3DOF(const SensorType sensorType);
50 
51  protected:
52 
53  /**
54  * Creates a new 3DOF acceleration sensor device.
55  * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_GYRO_RAW_3DOF or SENSOR_GYRO_UNBIASED_3DOF
56  * @param sensor The Android sensor providing the sensor measurements, must be valid
57  */
58  AndroidGyroSensor3DOF(const SensorType sensorType, const ASensor* sensor);
59 
60  /**
61  * Destructs a 3DOF acceleration sensor device.
62  */
64 
65  /**
66  * The actual event function of this device.
67  * @see AndroidDevice::onEventFunction().
68  */
69  int onEventFunction() override;
70 
71  protected:
72 
73  /// The Android event timestamp of the first sensor event.
74  int64_t firstAndroidEventTimestamp_ = 0ll;
75 
76  /// The Unix event timestamp of the first sensor event.
77  Timestamp firstUnixEventTimestamp_ = Timestamp(false);
78 };
79 
81 {
82  ocean_assert(sensorType == SENSOR_GYRO_RAW_3DOF || sensorType == SENSOR_GYRO_UNBIASED_3DOF);
83 
84  if (sensorType == SENSOR_GYRO_RAW_3DOF)
85  {
86  return std::string("Android 3DOF Gyro Raw Sensor");
87  }
88 
89  return std::string("Android 3DOF Gyro Unbiased Sensor");
90 }
91 
93 {
94  ocean_assert(sensorType == SENSOR_GYRO_RAW_3DOF || sensorType == SENSOR_GYRO_UNBIASED_3DOF);
95 
96  return deviceTypeGyroSensor3DOF(sensorType);
97 }
98 
99 }
100 
101 }
102 
103 }
104 
105 #endif // META_OCEAN_DEVICES_ANDROID_ANDROID_GYRO_SENSOR_3_DOF_H
This class implements a device factory for the Android feature based tracking system.
Definition: AndroidFactory.h:31
This class implements all 3DOF acceleration sensors (including the linear acceleration sensors).
Definition: AndroidGyroSensor3DOF.h:32
~AndroidGyroSensor3DOF() override
Destructs a 3DOF acceleration sensor device.
static DeviceType deviceTypeAndroidGyroSensor3DOF(const SensorType sensorType)
Returns the device type of this sensor.
Definition: AndroidGyroSensor3DOF.h:92
int onEventFunction() override
The actual event function of this device.
static std::string deviceNameAndroidGyroSensor3DOF(const SensorType sensorType)
Returns the name of this sensor.
Definition: AndroidGyroSensor3DOF.h:80
AndroidGyroSensor3DOF(const SensorType sensorType, const ASensor *sensor)
Creates a new 3DOF acceleration sensor device.
This class implements a sensor for the Android library.
Definition: AndroidSensor.h:41
Definition of a class holding the major and minor device type.
Definition: devices/Device.h:62
This class is the base class for all 3DOF gyro sensors.
Definition: GyroSensor3DOF.h:40
static DeviceType deviceTypeGyroSensor3DOF(const SensorType sensorType)
Returns this device type.
Definition: GyroSensor3DOF.h:116
SensorType
Definition of different sensor types.
Definition: Sensor.h:43
@ SENSOR_GYRO_RAW_3DOF
3DOF gyro sensor (raw samples).
Definition: Sensor.h:51
@ SENSOR_GYRO_UNBIASED_3DOF
3DOF gyro sensor (unbiased samples).
Definition: Sensor.h:53
This class implements a timestamp.
Definition: Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15