Ocean
GyroSensor3DOF.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_GYRO_SENSOR_3DOF_H
9 #define META_OCEAN_DEVICES_GYRO_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.
26 class GyroSensor3DOF;
27 
28 /**
29  * Definition of a smart object reference for a 3DOF gyro sensor.
30  * @see GyroSensor3DOF.
31  * @ingroup devices
32  */
34 
35 /**
36  * This class is the base class for all 3DOF gyro sensors.
37  * @ingroup devices
38  */
39 class OCEAN_DEVICES_EXPORT GyroSensor3DOF : virtual public Sensor
40 {
41  public:
42 
43  /**
44  * Definition of a sample holding gyro sensor 3DOF measurements.
45  * Each gyro measurement value is defined in [rad / s]
46  */
47  class OCEAN_DEVICES_EXPORT Gyro3DOFSample : virtual public Measurement::Sample
48  {
49  public:
50 
51  /**
52  * Definition of a vector holding gyro measurements.
53  * One measurement holds three different gyro values for three separated axis.
54  */
55  typedef std::vector<Vector3> Measurements;
56 
57  public:
58 
59  /**
60  * Creates a new gyro sensor 3DOF sample.
61  * @param timestamp Sample timestamp
62  * @param objectIds Measurement unit object ids each id corresponds to a different gyro measurement
63  * @param measurements Sample measurements
64  */
65  Gyro3DOFSample(const Timestamp& timestamp, const ObjectIds& objectIds, const Measurements& measurements);
66 
67  /**
68  * Creates a new gyro sensor 3DOF sample.
69  * @param timestamp Sample timestamp
70  * @param objectIds Measurement unit object ids each id corresponds to a different gyro measurement
71  * @param measurements Sample measurements
72  */
73  Gyro3DOFSample(const Timestamp& timestamp, ObjectIds&& objectIds, Measurements&& measurements);
74 
75  /**
76  * Returns all measurement values, each value in [rad / s]
77  * @return Measurement values
78  */
79  inline const Measurements& measurements() const;
80 
81  protected:
82 
83  /// Measurement values.
85  };
86 
87  /**
88  * Definition of a smart object reference for 3DOF gyro sensor samples.
89  */
91 
92  public:
93 
94  /**
95  * Returns this device type.
96  * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_GYRO_RAW_3DOF or SENSOR_GYRO_UNBIASED_3DOF
97  * @return Device type
98  */
99  static inline DeviceType deviceTypeGyroSensor3DOF(const SensorType sensorType);
100 
101  protected:
102 
103  /**
104  * Creates a new 3DOF gyro sensor device.
105  * @param name The name of the gyro sensor
106  * @param sensorType The type of the sensor (the subtype of the device), can be SENSOR_GYRO_RAW_3DOF or SENSOR_GYRO_UNBIASED_3DOF
107  */
108  GyroSensor3DOF(const std::string& name, const SensorType sensorType);
109 
110  /**
111  * Destructs a 3DOF gyro sensor device.
112  */
113  ~GyroSensor3DOF() override;
114 };
115 
117 {
118  ocean_assert(sensorType == SENSOR_GYRO_RAW_3DOF || sensorType == SENSOR_GYRO_UNBIASED_3DOF);
119 
120  return GyroSensor3DOF::DeviceType(DEVICE_SENSOR, sensorType);
121 }
122 
124 {
125  return measurements_;
126 }
127 
128 }
129 
130 }
131 
132 #endif // META_OCEAN_DEVICES_GYRO_SENSOR_3DOF_H
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 gyro sensor 3DOF measurements.
Definition: GyroSensor3DOF.h:48
std::vector< Vector3 > Measurements
Definition of a vector holding gyro measurements.
Definition: GyroSensor3DOF.h:55
Gyro3DOFSample(const Timestamp &timestamp, ObjectIds &&objectIds, Measurements &&measurements)
Creates a new gyro sensor 3DOF sample.
Gyro3DOFSample(const Timestamp &timestamp, const ObjectIds &objectIds, const Measurements &measurements)
Creates a new gyro sensor 3DOF sample.
const Measurements & measurements() const
Returns all measurement values, each value in [rad / s].
Definition: GyroSensor3DOF.h:123
Measurements measurements_
Measurement values.
Definition: GyroSensor3DOF.h:84
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
SmartObjectRef< Gyro3DOFSample, Sample > Gyro3DOFSampleRef
Definition of a smart object reference for 3DOF gyro sensor samples.
Definition: GyroSensor3DOF.h:90
GyroSensor3DOF(const std::string &name, const SensorType sensorType)
Creates a new 3DOF gyro sensor device.
~GyroSensor3DOF() override
Destructs a 3DOF gyro sensor device.
Definition of a sample holding a measurement.
Definition: Measurement.h:67
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_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 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< GyroSensor3DOF > GyroSensor3DOFRef
Definition of a smart object reference for a 3DOF gyro sensor.
Definition: GyroSensor3DOF.h:26
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15