Sensor example

The Sensor example application demonstrates how to use the Sensor library to acquire sensor data, record it, publish and subscribe sensor interim data, and display debug information about the data on a console connection.

When you run the application, you require sensors configured in the sensor configuration file or data units configured in the data 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 streaming: Subscribes to the sensor data
  5. Sensor data subscriber recording: Subscribes to the sensor data and records it to file
  6. Sensor recording: Subscribes to the sensor data and record.
  7. Sensor data query: Queries the data from the sensors.
  8. Sensor data subscriber (event mode): Subscribes to the sensor data using event mode.
-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.
-m
Set the mode of the callback or event. Valid modes are:
  • read-only
  • read-write
  • read-write-exclusive
-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.
-w
Provide the vehicle speed information to the sensor (if supported).

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 another example application is running, type slay example_app in your ssh session to stop it (where example_app is the name of the example application that's running. 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 streaming
            5) Sensor data subscriber recording
            6) Sensor query
            7) Sensor data query
            8) Sensor data subscriber (event mode)
            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 streaming
        5) Sensor data subscriber recording
        6) Sensor query
        7) Sensor data query
        8) Sensor data subscriber (event mode)
        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 streaming
        5) Sensor data subscriber recording
        6) Sensor query
        7) Sensor data query
        8) Sensor data subscriber (event mode)
        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 streaming
        5) Sensor data subscriber recording
        6) Sensor query
        7) Sensor data query
        8) Sensor data subscriber (event mode)
        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 streaming
        5) Sensor data subscriber recording
        6) Sensor query
        7) Sensor data query
        8) Sensor data subscriber (event mode)
        x) Exit the example
6
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 streaming
        5) Sensor data subscriber recording
        6) Sensor query
        7) Sensor data query
        8) Sensor data subscriber (event mode)
        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 SDP 7.0 installation directory/source/adas-sensor-examples-2.0.buildnumber.zip. You must extract it to get the ZIP file for the sensor examples.
  2. In the SDP 7.0 installation directory/source/source_package_adas_sensor directory that's extracted, there's a README.txt that you can follow to build the application.
  3. Navigate to SDP 7.0 installation 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, type sensor_example to run the application.