The Sensor library provides an application with a consistent interface to simultaneously access up to sixty-four
sensors connected to the hardware platform.
Overview
The Sensor library is one of the main components of the Sensor Framework. It allows applications to
access all sensors that are available through the Sensor Framework. In the context of the
Sensor library, a sensor can be any one of camera, lidar, radar, or GPS system.
Figure 1. Sensor Library and the Sensor Framework
The Sensor library provides the following functions:
- Opening and closing a connection to a sensor
- Starting and stopping streaming from a sensor
- Starting and stopping recording data from a sensor
- Receiving data from a sensor when the sensor is streaming
- Receiving status events from a sensor
- Publishing interim data to the Sensor Framework that can be consumed by subscribers
- Subscribing to the Sensor Framework to receive interim data from publishers
Sensor configuration
The sensors that are available to your application is based on a static configuration
file that the Sensor service loads once on its startup.
For more information, see the
Sensor configuration file
section in the System Services guide.
If you're using a camera specifically, and need to change its settings dynamically, then you need to use the
Camera library instead. See the
Camera Developer's Guide.
Interim data configuration
The interim data units that are used for interim data are based on a static configuration
file that the Sensor service loads once on its startup.
For more information, see the
Interim data configuration file
section in the System Services guide.
Sensor library header files
To use the Sensor library, these are the header files that you can use:
- sensor_api.h
-
This is the main interface to the Sensor library. You must always include
this header file to use the Sensor library. For more information, see sensor_api.h
in the Sensor Library Reference.
- sensor_interim_data.h
-
This file includes interfaces to publish interim data to the Sensor Framework. For more
information, see sensor_interim_data.h in the
Sensor Library Reference.
Using the Sensor API
Most sensor applications follow a similar workflow:
- Open a connection to the logical sensor or interim data unit.
- Register callback functions or events to receive sensor and interim data and status.
- Start the sensor or interim data unit to stream data.
-
While sensor is streaming, your application may:
- access sensor (or interim) data or status (e.g., handle sensor events that you've registered for)
- record sensor or interim data
- subscribe or publish interim data
- Stop the sensor or interim data unit from streaming data.
- Close the connection to the sensor or interim data unit.