Sensor example

The sensor view application demonstrates how to use the Sensor library to take sensor data, record it, and show it on the screen.

When you run the application, you require sensors configured in the sensor configuration file. This can include live sensor, such as a lidar or radar, or a prerecorded data file (file data). For information about connecting and configuring sensors, see the Connect cameras and sensors and Configure sensors and cameras on the reference image in this chapter.

To run the Sensor example application, run the (sensor_example) command using these optional parameters:
-b
Sets the number of buffers that can be received from the sensor. The default is 100.
-c
Consumption latency in microseconds. The default is 50.
-d
Prints information from the data callback from each buffer that's received.
-e
The example you want to run from the menu; if this option isn't specified, the application prompts for an example to run. The options that you specify using these numbers are:
  1. Sensor stream: Runs the example using a stream of data from the sensors specified in the configuration file.
  2. Sensor recorder: Records data from the connected sensors.
  3. Sensor data publisher: Publishes the sensor data.
  4. Sensor data subscriber: Subscribes to the sensor data.
  5. Sensor query: Queries information about the sensors.
  6. Sensor data query: Queries the data from the sensors.
-f
Sets the path to save the recording. If this option isn't specified, it uses the roll to get a unique filename from the roll directory specified in the Sensor service.
-p
Publish latency in microseconds. The default is 33000.
-s
Print information from status callback when the status is received.
-u
The sensor unit to use for testing as an integer value that corresponds to the unit you have specified in the sensor configuration file. For example, if you want to use SENSOR_UNIT_1, then specify 1. If this option isn't specified, a prompt appears to request for the sensor unit.

Run the application

The steps here allow you to run the Sensor example application. If you booted the default IFS provided with the reference image, the Sensor Example is running, but you won't be able to control it. Running the application in a separate session gives you control to change it.

  1. Connect to your board using ssh.
  2. If the Camera MUX 2x2 example is running, type slay camera_mux2x2 in your ssh session to stop it. The application should stop running (you see a blank display).
  3. Type sensor_example to run Sensor example. After press Enter, a menu appears. # sensor_example Select which example you want to run: 1) Sensor stream 2) Sensor recorder 3) Sensor data publisher 4) Sensor data subscriber 5) Sensor query 6) Sensor data query x) Exit the example
  4. Type the number of the option you want to run. You should see the result of the options in your console.

Examples:

The following examples show how to accomplish certain tasks.

Stream and then record sensor data

The following shows how you stream data from a file to sensor and then record that data:
# sensor_example
Select which example you want to run:
        1) Sensor stream
        2) Sensor recorder
        3) Sensor data publisher
        4) Sensor data subscriber
        5) Sensor query
        6) Sensor data query
        x) Exit the example
1
Select which sensor you want to use:
        1) Unit: 1, Type: File Camera, Name: front-camera
        2) Unit: 2, Type: Lidar, Name: vlp-16
        3) Unit: 3, Type: Radar, Name: esr2.5
        4) Unit: 4, Type: Lidar, Name: vu8
2
Select which example you want to run:
        1) Sensor stream
        2) Sensor recorder
        3) Sensor data publisher
        4) Sensor data subscriber
        5) Sensor query
        6) Sensor data query
        x) Exit the example
2
Select which sensor you want to use:
        1) Unit: 1, Type: File Camera, Name: front-camera
        2) Unit: 2, Type: Lidar, Name: vlp-16
        3) Unit: 3, Type: Radar, Name: esr2.5
        4) Unit: 4, Type: Lidar, Name: vu8
2
Recording to /accounts/1000/shared/camera/SENSOR_20170609_165800.raw
Select which example you want to run:
        1) Sensor stream
        2) Sensor recorder
        3) Sensor data publisher
        4) Sensor data subscriber
        5) Sensor query
        6) Sensor data query
        x) Exit the example
#

Get the position of a sensor

The following shows how to get the position of a sensor. This information is configured in the sensor configuration file.
# sensor_example
Select which example you want to run:
        1) Sensor stream
        2) Sensor recorder
        3) Sensor data publisher
        4) Sensor data subscriber
        5) Sensor query
        6) Sensor data query
        x) Exit the example
5
Select which sensor you want to use:
        1) Unit: 1, Type: File Camera, Name: front-camera
        2) Unit: 2, Type: Lidar, Name: vlp-16
        3) Unit: 3, Type: Radar, Name: esr2.5
        4) Unit: 4, Type: Lidar, Name: vu8
4
Sensor position: (2300.0, 0.0, 800.0), yaw: 0.0, pitch 0.0, roll 180.0
Select which example you want to run:
        1) Sensor stream
        2) Sensor recorder
        3) Sensor data publisher
        4) Sensor data subscriber
        5) Sensor query
        6) Sensor data query
        x) Exit the example

Build the Sensor example application

On your host computer, the source code is provided for Sensor example application as part of a ZIP file. You can build the source and deploy the binary on to your target.

  1. A ZIP file installed with the QNX Platform for ADAS - Base is located at $QNX_BASE/source/adas-sensor-examples-version.zip. You must extract it to get the ZIP file for the sensor examples.
  2. In the extraction_directory/source_package_adas_sensor directory, there's a README.txt that you can follow to build the application.
  3. Navigate to extraction_directory/source_package_adas_sensor/ apps/sensor_example/nto/x86_64/o and transfer the sensor_example file to the /usr/bin/ directory on the target. For example, you can use the IDE to transfer the file.
    Note: Ensure that you can create a backup of the original sensor_example executable before you deploy your newly built version of the Sensor example application.
  4. On your target, in a terminal connection, run the Sensor example application.