# Sensor control

**Detailed Description**

This section contains APIs related to sensor configuration, sensor control and data acquisition from sensors.

- *group* Telematics\_sensor\_control

    - Typedefs

- using SelfTestExResultCallback = std::function&lt;void(telux::common::ErrorCode result, telux::sensor::SelfTestResultParams selfTestResultParams)&gt;

    - This file hosts the sensor interfaces to configure, activate or get data from the individual sensors available - Gyroscope, Accelerometer, etc.

This function is invoked when a result for a self-test initiated using telux::sensor::ISensorClient::selfTest is performed.

- Param result:

    - **[in]** - Errorcode depicting result of the self test - telux::common::ErrorCode [in] selfTestResultParams - Struct to represent the result of sensor self test via telux::sensor::SelfTestResultParams

- using SelfTestResultCallback = std::function&lt;void(telux::common::ErrorCode result)&gt;

    - This function is invoked when a result for a self-test initiated using telux::sensor::ISensorClient::selfTest is available.

Deprecated This callback is no longer supported. Use telux::sensor::SelfTestExResultCallback.

- Param result:

    - **[in]** The result of the self test - telux::common::ErrorCode

- using ISensor = ISensorClient

    -

- class ISensorEventListener : public telux::common::ISDKListener

    - ISensorEventListener interface is used to receive notifications related to sensor events and configuration updates.

The listener method can be invoked from multiple different threads. Client needs to make sure that implementation is thread-safe.

Public Functions

- inline virtual void onEvent(std::shared\_ptr&lt;std::vector&lt;SensorEvent&gt;&gt; events)

    - This function is called to notify about available sensor events. Note the following constraints on this listener API It shall not perform time consuming (compute or I/O intensive) operations on this thread It shall not inovke an sensor APIs on this thread due to the underlying concurrency model

On platforms with Access control enabled, the client needs to have TELUX\_SENSOR\_DATA\_READ permission for this listener API to be invoked.

- Parameters:

    - **events** – **[in]** - List of sensor events

- inline virtual void onConfigurationUpdate(SensorConfiguration configuration)

    - This function is called to notify any change in the configuration of the ISensorClient object this listener is associated with.

On platforms with Access control enabled, the client needs to have TELUX\_SENSOR\_DATA\_READ permission for this listener API to be invoked.

- Parameters:

    - **configuration** – **[in]** - The new configuration of the sensor client. telux::sensor::SensorConfiguration. Fields that have changed can be identified using the telux::sensor::SensorConfiguration::updateMask and fields that are valid can be identified using telux::sensor::SensorConfiguration::validityMask

- inline virtual void onSelfTestFailed()

    - This API is invoked to notify a failed self-test that was triggered internally by the sensor service. For self-test explicitly requested via telux::sensor::ISensorClient::selfTest API, results will be delivered via SelfTestExResultCallback.

On platforms with Access control enabled, the client needs to have TELUX\_SENSOR\_DATA\_READ permission for this listener API to be invoked.

- inline virtual ~ISensorEventListener()

    - The destructor for the sensor event listener

- class ISensorClient

    - ISensorClient interface is used to access the different services provided by the sensor framework to configure, activate and acquire sensor data.

Each instance of this class is a unique sensor client to the underlying sensor framework and any number of such clients can exist in a given process. Each of these clients can acquire data from the underlying sensor framework with different configurations.

Public Functions

- virtual SensorInfo getSensorInfo() = 0

    - Get the information related to sensor

- Returns:

    - information retated to sensor - telux::sensor::SensorInfo

- virtual telux::common::Status configure(SensorConfiguration configuration) = 0

    - Configure the sensor client with desired sampling rate, batch count and rotation configuration. Any change in sampling rate or batch count or rotation configuration of the sensor will be notified via telux::sensor::ISensorEventListener::onConfigurationUpdate.

In case a sensor client needs to be reconfigured after having been activated, the client should be deactivated, configured and activated again as a part of the reconfiguration process.

It is always recommended that configuration of a client is done before activating it. If a client is activated without configuration, the client is configured with a default configuration and activated. The default configuration would have the sampling rate set to minimum sampling rate supported telux::sensor::SensorInfo::samplingRates, the batch count set to maximum batch count supported telux::sensor::SensorInfo::maxBatchCountSupported and rotated data will be delivered via telux::sensor::ISensorEventListener::onEvent.

On platforms with Access control enabled, Caller needs to have TELUX\_SENSOR\_DATA\_READ permission to invoke this API successfully.

- Parameters:

    - **configuration** – **[in]** - The desired configuration for the client telux::sensor::SensorConfiguration. Ensure the required validity mask telux::sensor::SensorConfiguration::validityMask is set for the configuration.

- Returns:

    - status of configuration request - telux::common::Status

- virtual SensorConfiguration getConfiguration() = 0

    - Get the current configuration of this sensor client

On platforms with Access control enabled, Caller needs to have TELUX\_SENSOR\_DATA\_READ permission to invoke this API successfully.

- Returns:

    - the current configuration of the client. telux::sensor::SensorConfiguration::validityMask should be checked to know which of the fields in the returned configuration is valid.

- virtual telux::common::Status activate() = 0

    - Activate the sensor client. Once activated, any available sensor event will be notified via telux::sensor::ISensorEventListener::onEvent

It is always recommended that configuration of a client is done before activating it. If a client is activated without configuration, the client is configured with the default configuration and activated. The default configuration would have the sampling rate set to minimum sampling rate supported telux::sensor::SensorInfo::samplingRates, the batch count set to maximum batch count supported telux::sensor::SensorInfo::maxBatchCountSupported and rotated data will be delivered via telux::sensor::ISensorEventListener::onEvent. Activating an already activated sensor would result in the API returning telux::common::Status::SUCCESS.

Activating this sensor client would not impact other inactive sensor clients.

On platforms with Access control enabled, Caller needs to have TELUX\_SENSOR\_DATA\_READ permission to invoke this API successfully.

- Returns:

    - status of activation request - telux::common::Status

- virtual telux::common::Status deactivate() = 0

    - Deactivate the sensor client. Once deactivated, no further sensor events will be notified via telux::sensor::ISensorEventListener::onEvent. Deactivating an already inactive sensor would result in the API returning telux::common::Status::SUCCESS.

Deactivating this sensor client would not impact other active sensor clients.

On platforms with Access control enabled, Caller needs to have TELUX\_SENSOR\_DATA\_READ permission to invoke this API successfully.

- Returns:

    - status of deactivation request - telux::common::Status

- virtual telux::common::Status selfTest(SelfTestType selfTestType, SelfTestExResultCallback cb) = 0

    - Initiate self test on this sensor

If there are no active data acquistion sessions corresponding to this sensor, the SensorResultType will be set to CURRENT and the self test will be performed for a given SelfTestType.

If there are active data acquisition sessions corresponding to this sensor, the SensorResultType will be set to HISTORICAL and the result will correspond to the previous self test performed for a given SelfTestType.

In case the self test for this sensor couldn’t be performed for a given SelfTestType, the callback is invoked with telux::common::ErrorCode::INFO\_UNAVAILABLE.

On platforms with Access control enabled, Caller needs to have TELUX\_SENSOR\_PRIVILEGED\_OPS permission to invoke this API successfully.

- Parameters:

    - - **selfTestType** – **[in]** - The type of self test to be performed - telux::sensor::SelfTestType
- **cb** – **[in]** - Callback to get the result of the self test initiated

- Returns:

    - status of the request - telux::common::Status. Note that the result of the self test done by the sensor is provided via the callback - telux::sensor::SelfTestExResultCallback

- virtual telux::common::Status registerListener(std::weak\_ptr&lt;ISensorEventListener&gt; listener) = 0

    - Register a listener for sensor related events

- Returns:

    - status of registration request - telux::common::Status

- virtual telux::common::Status deregisterListener(std::weak\_ptr&lt;ISensorEventListener&gt; listener) = 0

    - Deregister a sensor event listener

- Returns:

    - status of deregistration request - telux::common::Status

- inline virtual ~ISensorClient()

    - Destructor for ISensorClient.

Internally, the sensor client object is first deactivated and then destroyed.

- virtual telux::common::Status enableLowPowerMode() = 0

    - Deprecated APIs Request the sensor to operate in low power mode. The sensor should be in deactivated state to exercise this API. The success of this request depends on the capabilities of the underlying hardware.

Deprecated This API is no longer supported.

- Returns:

    - status of request - telux::common::Status

- virtual telux::common::Status disableLowPowerMode() = 0

    - Request the sensor to exit low power mode. The sensor should be in deactivated state to exercise this API. The success of this request depends on the capabilities of the underlying hardware.

Deprecated This API is no longer supported.

- Returns:

    - status of request - telux::common::Status

- virtual telux::common::Status selfTest(SelfTestType selfTestType, SelfTestResultCallback cb) = 0

    - Initiate self test on this sensor

If there are no active data acquistion sessions corresponding to this sensor, the self test will be performed based on the SelfTestType passed.

If there are active data acquisition sessions corresponding to this sensor, the self test will not be performed and the callback will be invoked with telux::common::ErrorCode::DEVICE\_IN\_USE.

On platforms with Access control enabled, Caller needs to have TELUX\_SENSOR\_PRIVILEGED\_OPS permission to invoke this API successfully.

Deprecated This API is no longer supported. Use selfTest(SelfTestType selfTestType, SelfTestExResultCallback cb) API instead.

- Parameters:

    - - **selfTestType** – **[in]** - The type of self test to be performed - telux::sensor::SelfTestType
- **cb** – **[in]** - Callback to get the result of the self test initiated

- Returns:

    - status of the request - telux::common::Status. Note that the result of the self test done by the sensor is provided via the callback - telux::sensor::SelfTestResultCallback

- class ISensorManager

    - Sensor Manager class provides APIs to interact with the sensor sub-system and get access to other sensor objects which can be used to configure, activate or get data from the individual sensors available - Gyro, Accelero, etc.

Public Functions

- virtual telux::common::ServiceStatus getServiceStatus() = 0

    - Checks the status of sensor sub-system and returns the result.

- Returns:

    - the status of sensor sub-system status telux::common::ServiceStatus

- virtual telux::common::Status getAvailableSensorInfo(std::vector&lt;SensorInfo&gt; &info) = 0

    - Get information related to the sensors available in the system.

- Parameters:

    - **info** – **[out]** List of information on sensors available in the system telux::sensor::SensorInfo

- Returns:

    - status of the request telux::common::Status

- virtual telux::common::Status getSensor(std::shared\_ptr&lt;ISensorClient&gt; &sensor, std::string name) = 0

    - Get an instance of ISensorClient to interact with the underlying sensor. The provided instance is not a singleton. Everytime this method is called a new sensor object is created. It is the caller’s responsibility to manage the object’s lifetime. Every instance of the sensor returned acts as new client and can configure the underlying sensor with it’s own configuration and it’s own callbacks for telux::sensor::SensorEvent and configuration update among other events telux::sensor::ISensorEventListener.

Deprecated Use getSensorClient API.

- Parameters:

    - - **sensor** – **[out]** - An instance of telux::sensor::ISensorClient to interact with the underlying sensor is provided as a result of the method If the initialization of the sensor and underlying system fails, sensor is set to nullptr
- **name** – **[in]** - The unique name of the sensor telux::sensor::SensorInfo::name that was provided in the list of sensor information by telux::sensor::ISensorManager::getAvailableSensorInfo

- Returns:

    - Status of request telux::common::Status

- virtual telux::common::Status getSensorClient(std::shared\_ptr&lt;ISensorClient&gt; &sensor, std::string name) = 0

    - Get an instance of ISensorClient to interact with the underlying sensor. The provided instance is not a singleton. Everytime this method is called a new sensor object is created. It is the caller’s responsibility to manage the object’s lifetime. Every instance of the sensor returned acts as new client and can configure the underlying sensor with it’s own configuration and it’s own callbacks for telux::sensor::SensorEvent and configuration update among other events telux::sensor::ISensorEventListener.

- Parameters:

    - - **sensor** – **[out]** - An instance of telux::sensor::ISensorClient to interact with the underlying sensor is provided as a result of the method If the initialization of the sensor and underlying system fails, sensor is set to nullptr
- **name** – **[in]** - The unique name of the sensor telux::sensor::SensorInfo::name that was provided in the list of sensor information by telux::sensor::ISensorManager::getAvailableSensorInfo

- Returns:

    - Status of request telux::common::Status

- virtual telux::common::Status setEulerAngleConfig(EulerAngleConfig eulerAngleConfig) = 0

    - This API is called to set Euler angles, used for sensor rotation matrix.

The sensor data should always be obtained w.r.t the vehicular frame. This API accepts the Euler angles which are used to compute the rotational matrix and provide the final rotated sensor data to the clients. It is advised to set the Euler angles by calling this API before activating any sensor clients.

On platforms with access control enabled, caller needs to have TELUX\_SENSOR\_PRIVILEGED\_OPS permission to invoke this API successfully.

- Parameters:

    - **eulerAngleConfig** – **[in]** - The Euler angle configuration.

- Returns:

    - status of Euler angle update request - telux::common::Status

- inline virtual ~ISensorManager()

    - Destructor for ISensorManager

Last Published: May 20, 2026

Previous Topic
 
uncalibrated Next Topic

Sensor feature control