Ocean
Loading...
Searching...
No Matches
AndroidAccelerationSensor3DOF.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_ACCELERATION_SENSOR_3_DOF_H
9#define META_OCEAN_DEVICES_ANDROID_ANDROID_ACCELERATION_SENSOR_3_DOF_H
10
13
15
16namespace Ocean
17{
18
19namespace Devices
20{
21
22namespace Android
23{
24
25/**
26 * This class implements all 3DOF acceleration sensors (including linear acceleration sensors).
27 *
28 * The coordinate system is as follows (assuming the phone is lying flat on a table):<br>
29 * The X-axis points to the right, the Y-axis points away from the user, and the Z-axis points towards the sky.
30 *
31 * The non-linear acceleration sensor will show a positive 9.81 m/s² reading for the Z-axis when the device is lying flat on the table.<br>
32 * When moving the device along an individual axis towards the positive direction, the acceleration value for that axis will be positive.
33 * @ingroup devicesandroid
34 */
35class OCEAN_DEVICES_EXPORT AndroidAccelerationSensor3DOF :
36 virtual public AndroidSensor,
37 virtual public AccelerationSensor3DOF
38{
39 friend class AndroidFactory;
40
41 public:
42
43 /**
44 * Returns the name of this sensor.
45 * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_ACCELERATION_3DOF or SENSOR_LINEAR_ACCELERATION_3DOF
46 * @return The sensor's name
47 */
48 static inline std::string deviceNameAndroidAccelerationSensor3DOF(const SensorType sensorType);
49
50 /**
51 * Returns the device type of this sensor.
52 * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_ACCELERATION_3DOF or SENSOR_LINEAR_ACCELERATION_3DOF
53 * @return The sensor's device type
54 */
55 static inline DeviceType deviceTypeAndroidAccelerationSensor3DOF(const SensorType sensorType);
56
57 protected:
58
59 /**
60 * Creates a new 3DOF acceleration sensor device.
61 * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_ACCELERATION_3DOF or SENSOR_LINEAR_ACCELERATION_3DOF
62 * @param sensor The Android sensor providing the sensor measurements, must be valid
63 */
64 AndroidAccelerationSensor3DOF(const SensorType sensorType, const ASensor* sensor);
65
66 /**
67 * Destructs a 3DOF acceleration sensor device.
68 */
70
71 /**
72 * The actual event function of this device.
73 * @see AndroidDevice::onEventFunction().
74 */
75 int onEventFunction() override;
76
77 protected:
78
79 /// The Android event timestamp of the first sensor event.
80 int64_t firstAndroidEventTimestamp_ = 0ll;
81
82 /// The Unix event timestamp of the first sensor event.
83 Timestamp firstUnixEventTimestamp_ = Timestamp(false);
84};
85
87{
88 ocean_assert(sensorType == SENSOR_ACCELERATION_3DOF || sensorType == SENSOR_LINEAR_ACCELERATION_3DOF);
89
90 if (sensorType == SENSOR_ACCELERATION_3DOF)
91 {
92 return std::string("Android 3DOF Acceleration Sensor");
93 }
94
95 return std::string("Android 3DOF Linear Acceleration Sensor");
96}
97
104
105}
106
107}
108
109}
110
111#endif // META_OCEAN_DEVICES_ANDROID_ANDROID_ACCELERATION_SENSOR_3_DOF_H
This class is the base class for all 3DOF acceleration sensors.
Definition AccelerationSensor3DOF.h:40
static DeviceType deviceTypeAccelerationSensor3DOF(const SensorType sensorType)
Returns this device type.
Definition AccelerationSensor3DOF.h:118
This class implements all 3DOF acceleration sensors (including linear acceleration sensors).
Definition AndroidAccelerationSensor3DOF.h:38
AndroidAccelerationSensor3DOF(const SensorType sensorType, const ASensor *sensor)
Creates a new 3DOF acceleration sensor device.
~AndroidAccelerationSensor3DOF() override
Destructs a 3DOF acceleration sensor device.
static DeviceType deviceTypeAndroidAccelerationSensor3DOF(const SensorType sensorType)
Returns the device type of this sensor.
Definition AndroidAccelerationSensor3DOF.h:98
static std::string deviceNameAndroidAccelerationSensor3DOF(const SensorType sensorType)
Returns the name of this sensor.
Definition AndroidAccelerationSensor3DOF.h:86
int onEventFunction() override
The actual event function of this device.
This class implements a device factory for the Android feature based tracking system.
Definition AndroidFactory.h:31
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
SensorType
Definition of different sensor types.
Definition Sensor.h:43
@ SENSOR_ACCELERATION_3DOF
3DOF acceleration sensor.
Definition Sensor.h:47
@ SENSOR_LINEAR_ACCELERATION_3DOF
3DOF linear acceleration sensor (excluding gravity).
Definition Sensor.h:49
This class implements a timestamp.
Definition Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition Accessor.h:15