Ocean
AccelerationSensor3DOF.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_ACCELERATION_SENSOR_3DOF_H
9 #define META_OCEAN_DEVICES_ACCELERATION_SENSOR_3DOF_H
10 
11 #include "ocean/devices/Devices.h"
13 #include "ocean/devices/Sensor.h"
14 
15 #include "ocean/math/Vector3.h"
16 
18 
19 namespace Ocean
20 {
21 
22 namespace Devices
23 {
24 
25 // Forward declaration.
27 
28 /**
29  * Definition of a smart object reference for a 3DOF acceleration sensor.
30  * @see AccelerationSensor3DOF.
31  * @ingroup devices
32  */
34 
35 /**
36  * This class is the base class for all 3DOF acceleration sensors.
37  * @ingroup devices
38  */
39 class OCEAN_DEVICES_EXPORT AccelerationSensor3DOF : virtual public Sensor
40 {
41  public:
42 
43  /**
44  * Definition of a sample holding acceleration sensor 3DOF measurements.
45  * Each acceleration measurement value is defined in [m / s^2]
46  */
47  class OCEAN_DEVICES_EXPORT Acceleration3DOFSample : virtual public Measurement::Sample
48  {
49  public:
50 
51  /**
52  * Definition of a vector holding acceleration measurements.
53  * One measurement holds three different acceleration values for three separated axis.
54  */
55  typedef std::vector<Vector3> Measurements;
56 
57  public:
58 
59  /**
60  * Creates a new acceleration sensor 3DOF sample.
61  * @param timestamp Sample timestamp
62  * @param objectIds Measurement unit object ids each id corresponds to a different acceleration measurement
63  * @param measurements Sample measurements
64  * @param metadata Optional metadata of the new sample
65  */
66  Acceleration3DOFSample(const Timestamp& timestamp, const ObjectIds& objectIds, const Measurements& measurements, const Metadata& metadata = Metadata());
67 
68  /**
69  * Creates a new acceleration sensor 3DOF sample.
70  * @param timestamp Sample timestamp
71  * @param objectIds Measurement unit object ids each id corresponds to a different acceleration measurement
72  * @param measurements Sample measurements
73  * @param metadata Optional metadata of the new sample
74  */
75  Acceleration3DOFSample(const Timestamp& timestamp, ObjectIds&& objectIds, Measurements&& measurements, Metadata&& metadata = Metadata());
76 
77  /**
78  * Returns all measurement values, each acceleration value in [m / s^2]
79  * @return Measurement values
80  */
81  inline const Measurements& measurements() const;
82 
83  protected:
84 
85  /// Measurement values.
87  };
88 
89  /**
90  * Definition of a smart object reference for 3DOF acceleration sensor samples.
91  */
93 
94  public:
95 
96  /**
97  * Returns this device type.
98  * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_ACCELERATION_3DOF or SENSOR_LINEAR_ACCELERATION_3DOF
99  * @return Device type
100  */
101  static inline DeviceType deviceTypeAccelerationSensor3DOF(const SensorType sensorType);
102 
103  protected:
104 
105  /**
106  * Creates a new 3DOF acceleration sensor device.
107  * @param name The name of the acceleration sensor, must be valid
108  * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_ACCELERATION_3DOF or SENSOR_LINEAR_ACCELERATION_3DOF
109  */
110  AccelerationSensor3DOF(const std::string& name, const SensorType sensorType);
111 
112  /**
113  * Destructs a 3DOF acceleration sensor device.
114  */
116 };
117 
119 {
120  ocean_assert(sensorType == SENSOR_ACCELERATION_3DOF || sensorType == SENSOR_LINEAR_ACCELERATION_3DOF);
121 
123 }
124 
126 {
127  return measurements_;
128 }
129 
130 }
131 
132 }
133 
134 #endif // META_OCEAN_DEVICES_ACCELERATION_SENSOR_3DOF_H
Definition of a sample holding acceleration sensor 3DOF measurements.
Definition: AccelerationSensor3DOF.h:48
const Measurements & measurements() const
Returns all measurement values, each acceleration value in [m / s^2].
Definition: AccelerationSensor3DOF.h:125
Acceleration3DOFSample(const Timestamp &timestamp, const ObjectIds &objectIds, const Measurements &measurements, const Metadata &metadata=Metadata())
Creates a new acceleration sensor 3DOF sample.
Acceleration3DOFSample(const Timestamp &timestamp, ObjectIds &&objectIds, Measurements &&measurements, Metadata &&metadata=Metadata())
Creates a new acceleration sensor 3DOF sample.
std::vector< Vector3 > Measurements
Definition of a vector holding acceleration measurements.
Definition: AccelerationSensor3DOF.h:55
Measurements measurements_
Measurement values.
Definition: AccelerationSensor3DOF.h:86
This class is the base class for all 3DOF acceleration sensors.
Definition: AccelerationSensor3DOF.h:40
SmartObjectRef< Acceleration3DOFSample, Sample > Acceleration3DOFSampleRef
Definition of a smart object reference for 3DOF acceleration sensor samples.
Definition: AccelerationSensor3DOF.h:92
AccelerationSensor3DOF(const std::string &name, const SensorType sensorType)
Creates a new 3DOF acceleration sensor device.
static DeviceType deviceTypeAccelerationSensor3DOF(const SensorType sensorType)
Returns this device type.
Definition: AccelerationSensor3DOF.h:118
~AccelerationSensor3DOF() override
Destructs a 3DOF acceleration sensor device.
Definition of a class holding the major and minor device type.
Definition: devices/Device.h:62
@ DEVICE_SENSOR
Sensor device.
Definition: devices/Device.h:44
Definition of a sample holding a measurement.
Definition: Measurement.h:67
std::unordered_map< std::string, Value > Metadata
Definition of an unordered map mapping keys to values.
Definition: Measurement.h:61
std::vector< ObjectId > ObjectIds
Definition of a vector holding object ids.
Definition: Measurement.h:51
This class implements the base class for all sensors.
Definition: Sensor.h:36
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 smart device reference.
Definition: DeviceRef.h:36
This template class implements a smart object reference which is a specialization of an ObjectRef obj...
Definition: SmartObjectRef.h:90
This class implements a timestamp.
Definition: Timestamp.h:36
SmartDeviceRef< AccelerationSensor3DOF > AccelerationSensor3DOFRef
Definition of a smart object reference for a 3DOF acceleration sensor.
Definition: AccelerationSensor3DOF.h:26
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15