# Sensor service

**Detailed Description**

This section contains APIs, data structures and components to access the sensor sub-system.

- *group* Telematics\_sensor\_service

    - Typedefs

- using SensorConfigMask = std::bitset&lt;SensorConfigParams::SENSOR\_CONFIG\_NUM\_PARAMS&gt;

    -

Enums

- enum SensorType

    - Enumeration of different sensors available.

*Values:*

- enumerator ACCELEROMETER

    - ID for the accelerometer sensor

- enumerator GYROSCOPE

    - ID for the gyroscope sensor

- enumerator GYROSCOPE\_UNCALIBRATED

    - ID for the uncalibrated gyroscope sensor

- enumerator ACCELEROMETER\_UNCALIBRATED

    - ID for the uncalibrated accelerometer sensor

- enumerator INVALID

    - Denotes that the sensor type is either unknown or invalid

- enum SensorConfigParams

    - Enumeration listing the different configuration parameters in SensorConfiguration

*Values:*

- enumerator SAMPLING\_RATE

    - Corresponds to SensorConfiguration::samplingRate

- enumerator BATCH\_COUNT

    - Corresponds to SensorConfiguration::batchCount

- enumerator ROTATE

    - Corresponds to SensorConfiguration::isRotated

- enumerator SENSOR\_CONFIG\_NUM\_PARAMS

    -

- enum SelfTestType

    - Types of self test the sensor can perform.

*Values:*

- enumerator POSITIVE

    - To initiate self test with positive values

- enumerator NEGATIVE

    - To initiate self test with negative values

- enumerator ALL

    - To initiate self test of all types in a single shot

- enum SensorResultType

    - Enum to represent the result of sensor self test.

*Values:*

- enumerator HISTORICAL

    - When sensor is busy, self-test is not possible and historical result would be provided.

- enumerator CURRENT

    - When sensor is idle, self test is performed and the current result would be provided.

- struct SensorInfo

    - Information related to sensor.

Public Members

- int id

    - Unique identifier for the sensor.

- SensorType type

    - The type of sensor, telux::sensor::SensorType

- std::string name

    - The name of the sensor This name is used to get a reference to a sensor with telux::sensor::ISensorManager::getSensorClient

- std::string vendor

    - The name of the vendor

- std::vector&lt;float&gt; samplingRates

    - List of supported sampling rates by the sensor hardware, number of samples per second (Hz)

- float maxSamplingRate

    - The maximum sampling rate the sensor can be configured for. This can be set in /etc/sensors.conf for each sensor and should be less than the maximum sampling rate supported by the sensor hardware, number of samples per second (Hz)

This attribute should be considered while using the API telux::sensor::ISensorClient::configure

- uint32\_t maxBatchCountSupported

    - Maximum batch count supported by the sensor, i.e. the maximum number of sensor events that the underlying framework can buffer.

This attribute should be considered while using the API telux::sensor::ISensorClient::configure

- uint32\_t minBatchCountSupported

    - Minimum batch count supported by the sensor. This is set in /etc/sensors.conf for each sensor.

This attribute should be considered while using the API telux::sensor::ISensorClient::configure

- int range

    - The range offered by the sensor. This configuration can be set in /etc/sensors.conf for each sensor.

For accelerometers, this is the number of Gs (force per unit mass due to gravity) in either direction (+/-) on each axis

For gyroscopes, this is the number of degrees per second (dps) in either direction (+/-) along each axis

- int version

    - The version of the sensor considering the hardware part and the driver

- float resolution

    - This is the smallest difference between two values reported by this sensor, in meter per second per second for accelerometer, radians per second for gyroscope

- float maxRange

    - The maximum range this sensor offers, in meter per second per second for accelerometer, radians per second for gyroscope. This attribute depends on the SensorInfo::range of the sensor set in the configuration file. For example, a range of 1G results in a maximum range of approximately 9.8 m/s/s and a range of 2G gives a maximum range of about 19.6 m/s/s.

- struct SensorConfiguration

    - Configurable parameters of a sensor.

Public Members

- float samplingRate

    - The sampling rate for the sensor, number of samples per second (Hz)

In case of telux::sensor::ISensorClient::configure, the requested sampling rate should be one of the sampling rates provided in the telux::sensor::SensorInfo::samplingRates and should be less than the telux::sensor::SensorInfo::maxSamplingRate.

If the requested sampling rate is less than the minimum value in the telux::sensor::SensorInfo::samplingRates, it will be set to the least of the values in telux::sensor::SensorInfo::samplingRates

If the requested sampling rate is not one of the supported sampling rates in telux::sensor::SensorInfo::samplingRates, the requested value is floored to the nearest value in telux::sensor::SensorInfo::samplingRates

Consider telux::sensor::SensorInfo::samplingRates having values 12, 26, 52. If requested sampling rate in configure API is 7, the sampling rate considered by the sensor framework would be 12. If requested sampling rate in configure API is 51, the sampling rate considered by the sensor framework would be 26.

In case of a configuration update received via telux::sensor::ISensorEventListener::onConfigurationUpdate, the current sampling rate configuration is passed to the listener

- uint32\_t batchCount

    - The batch count of the sensor.

Batch count is the count of number of samples the underlying framework would buffer before notifying the client of the data. The intention is to reduce the number of interactions between the hardware, framework and the user application to reduce power consumption, improve compute efficiency and reduce number of interactions between different components. It is important to consider latency while deciding the batch count for a sensor. Higher the batch count, more is the latency for the samples.

In case of telux::sensor::ISensorClient::configure, the requested batch count should be lesser than the maximum supported batch count telux::sensor::SensorInfo::maxBatchCountSupported. Also, the batch count considered is impacted by the telux::sensor::SensorInfo::minBatchCountSupported.

If the requested batch count is less than telux::sensor::SensorInfo::minBatchCountSupported, it will be set to telux::sensor::SensorInfo::minBatchCountSupported

If the requested batch count is not a multiple of telux::sensor::SensorInfo::minBatchCountSupported, the requested value is floored to the nearest multiple of telux::sensor::SensorInfo::minBatchCountSupported

Consider telux::sensor::SensorInfo::minBatchCountSupported having a value of 7. If requested batchCount in configure API is 2, the batchCount considered by the sensor framework would be 7. If requested batchCount in configure API is 23, the batchCount considered by the sensor framework would be 21.

In case of a configuration update telux::sensor::ISensorEventListener::onConfigurationUpdate, this field indicates the current configuration for batch count.

- bool isRotated

    - Configures if the sensor data provided is rotated as per Euler angles set.

In case of telux::sensor::ISensorClient::configure, if the flag “isRotated” is set, the data provided via telux::sensor::ISensorEventListener::onEvent will be rotated based on Euler angle set via telux::sensor::ISensorManager::setEulerAngleConfig.

In case of a configuration update received via telux::sensor::ISensorEventListener::onConfigurationUpdate, the current rotation configuration is provided to the listener.

- SensorConfigMask validityMask

    - Bitset indicating the validity of the received sensor configuration via telux::sensor::ISensorClient::getConfiguration and telux::sensor::ISensorEventListener::onConfigurationUpdate. The configuration items that were never set would have return false when tested for using std::bitset::test.

Further, this bitset should be set by the user to indicate the valid fields while configuring the sensor using telux::sensor::ISensorClient::configure. For continuous stream of data from a sensor, the validity of SAMPLING\_RATE, BATCH\_COUNT and ROTATE from SensorConfigParams should be considered. If the sensor had been already configured with sampling rate, batch count and rotation required, it is possible to reconfigure the sensor partially with just one of these attributes and setting the required validity flag.

- SensorConfigMask updateMask

    - Bitset indicating the parameters that were updated since last notification via telux::sensor::ISensorEventListener::onConfigurationUpdate

- struct EulerAngleConfig

    - Euler angles for a sensor.

Public Members

- float roll

    - 

- float pitch

    - 

- float yaw

    -

- struct MotionSensorData

    - Structure of a single sample from a motion sensor.

Public Members

- float x

    - x-axis data, meter per second per second for accelerometer, radians per second for gyroscope

- float y

    - y-axis data, meter per second per second for accelerometer, radians per second for gyroscope

- float z

    - z-axis data, meter per second per second for accelerometer, radians per second for gyroscope

- struct UncalibratedMotionSensorData

    - Structure of a single sample from uncalibrated motion sensor.

Public Members

- MotionSensorData data

    - Uncalibrated motion sensor data MotionSensorData

- MotionSensorData bias

    - Bias for the uncalibrated data MotionSensorData

- struct SensorEvent

    - Structure of a single sensor event.

Public Members

- uint64\_t timestamp

    - Timestamp when the event was generated on the hardware, nanosecond since boot-up

- union telux::sensor::SensorEvent::[anonymous] [anonymous]

    -

- struct SensorFeature

    - Feature offered by sensor hardware and/or software framework.

Public Members

- std::string name

    - Name of the feature

- struct SensorFeatureEvent

    - Structure of an event that is generated from a sensor feature.

Public Members

- uint64\_t timestamp

    - Best estimate of timestamp indicating the time of occurance of the event, nanosecond since boot-up

- std::string name

    - Name of the feature that generated the event

- int id

    - The ID of the generated event

- struct SelfTestResultParams

    - Represents the result of the sensor self test when telux::sensor::ISensorClient::selfTest is invoked with the telux::sensor::SelfTestAdvancedParamsCallback callback.

Public Members

- SensorResultType sensorResultType\_

    - Sensor result type as per SensorResultType.

- uint64\_t timestamp\_

    - Boot timestamp in ns. Represents the timestamp of the self-test.

- struct MotionDetectionConfigLimits

    - Represents the upper and lower bound limits for each configuration required to detect motion. The limits can be retrieved using telux::sensor::ISensorFeatureManager::getMotionDetectionConfigLimits API.

Public Members

- float minThreshold

    - Minimum threshold that can be set for MotionDetectionConfig::threshold

- float maxThreshold

    - Maximum threshold that can be set for MotionDetectionConfig::threshold

- int minDuration

    - Minimum duration that can be set for MotionDetectionConfig::duration

- int maxDuration

    - Maximum duration that can be set for MotionDetectionConfig::duration

- float minSamplingRate

    - Minimum frequency that can be set for MotionDetectionConfig::samplingRate

- float maxSamplingRate

    - Maximum frequency that can be set for MotionDetectionConfig::samplingRate

- struct MotionDetectionConfig

    - Represents the parameters that should be used to detect motion for a sensor.

A client can set the motion detection parameters using telux::sensor::ISensorFeatureManager::enableMotionDetection API and can retrieve the parameters if it was already set using telux::sensor::ISensorFeatureManager::getMotionDetectionConfig API.

Public Members

- float threshold

    - Threshold is the minimum value that must be exceeded to generate an event. Units - In mg.

- int duration

    - Duration is the period for which the sensor data should be above the threshold, to generate the motion detection event. If this is 0, this means, the sensor event would be immediately triggered after the threshold is crossed. Units - In ms.

- float samplingRate

    - Sampling rate is the frequency at which the sensor should generate samples for the purpose of motion detection. Units - In Hz.

- int sensorId

    - When a client enables the motion detection configuration using telux::sensor::ISensorFeatureManager::enableMotionDetection API, the sensor id points to the id of the sensor for which the configuration is being set.

When a client requests the motion detection configuration using telux::sensor::ISensorFeatureManager::getMotionDetectionConfigs API, the sensor id points to the id of the sensor for which the configuration is already set.

- class SensorFactory

    - SensorFactory is the central factory to create instances of sensor objects.

Public Functions

- virtual std::shared\_ptr&lt;ISensorManager&gt; getSensorManager(telux::common::InitResponseCb clientCallback = nullptr) = 0

    - Get an instance of Sensor Manager. The ownership of the returned object is with the caller of this method. The reference to the instance is not held by the SensorFactory. If the returned reference is released, any request for ISensorManager shall result in creation of a new instance

- Parameters:

    - **clientCallback** – **[in]** Optional callback to get the initialization status of SensorManager telux::common::InitResponseCb

- Returns:

    - An instance of ISensorManager If the initialization of the manager and underlying system fails, nullptr is returned

- virtual std::shared\_ptr&lt;ISensorFeatureManager&gt; getSensorFeatureManager(telux::common::InitResponseCb clientCallback = nullptr) = 0

    - Get an instance of Sensor Feature Manager. The ownership of the returned object is with the caller of this method. The reference to the instance is not held by the SensorFactory. If the returned reference is released, any request for ISensorFeatureManager shall result in creation of a new instance

- Parameters:

    - **clientCallback** – **[in]** Optional callback to get the initialization status of SensorFeatureManager telux::common::InitResponseCb

- Returns:

    - An instance of ISensorFeatureManager If the initialization of the manager and underlying system fails, nullptr is returned

Public Static Functions

- static SensorFactory &getInstance()

    - Get Sensor Factory instance.

- Returns:

    - The singleton instance of SensorFactory object

Private Functions

- SensorFactory(const SensorFactory&) = delete

    - 

- SensorFactory &operator=(const SensorFactory&) = delete

    -

- telux::sensor::SensorEvent.\_\_unnamed\_\_

    - Sensor data

Public Members

- MotionSensorData calibrated

    - Calibrated data - should be accessed when the SensorType that generated the sensor event accounts for calibration - SensorType::ACCELEROMETER or SensorType::GYROSCOPE

- UncalibratedMotionSensorData uncalibrated

    - Uncalibrated data - should be accessed when the SensorType that generated the sensor event provides uncalibrated data along with bias information - SensorType::ACCELEROMETER\_UNCALIBRATED or SensorType::GYROSCOPE\_UNCALIBRATED

Last Published: May 20, 2026

Previous Topic
 
Sensor Next Topic

Sensor control