Publish and Subscribe example

You can run the publish and subscribe example

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). This example demonstrates how to use the example to publish the data from a sensor and how to subscribe to it. The underlying mechanism used is Platform-independent Publish and Subscribe (PiPs). By default, the example uses Fast RTPS, but Scalable service-oriented middleware over IP (SOME/IP) and Data Distributed Services (DDS) can also be used. For more information, see pips_pubsub in the System Services guide.

Run the application

The following steps show how to run the example on this board using Fast RTPS:
  1. Connect to the board via console connection or telnet.
  2. Restart Sensor service but run it using prerecorded data from and sensors defined in the sensor configuration file (e.g., adas_example_capture.conf ) and the interim data units for publishers and subscribers in the interim data configuration file (e.g., adas_example_capture_interim.conf).
    # slay sensor
    # /bin/sensor -U 521:521 -r /roll -v -c
                        /etc/system/config/adas_example_capture.conf -d
                        /etc/system/config/adas_example_capture_interim.conf &
  3. Run the Publish and Subscribe example application in the background as both a subscribe and publisher. We do this because this is running on a single target.
    # pips_pubsub -s -p &
  4. To start seeing data published to and received from a subscribe, you must run an application that streams or publishes data. Run the sensor_example so that it prints data that's collected using the -d option.
    # sensor_example -d
    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
    

Examples:

The following examples show how to accomplish certain tasks.

How to subscribe to data from the interim data units

# sensor_example -d
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
Select which interim data you want to use:

        2) Unit: 2, Format: Lidar PointCloud, Name: vlp-16
        3) Unit: 3, Format: Radar Polar, Name: esr2.5
        4) Unit: 4, Format: Lidar Polar, Name: vu8
        5) Unit: 5, Format: GPS, Name: xsens_mti-g-710_gps
        6) Unit: 6, Format: IMU, Name: xsens_mti-g-710_imu
        7) Unit: 7, Format: GPS, Name: novatel_oem6_gps
        8) Unit: 8, Format: IMU, Name: novatel_oem6_imu
2
Received buffer 1 (0us since previous): time 83185001169 format 20 size 80
Received buffer 2 (21000us since previous): time 83185022407 format 20 size 80
Received buffer 3 (21000us since previous): time 83185043644 format 20 size 80
Received buffer 4 (22000us since previous): time 83185066209 format 20 size 80
Received buffer 5 (19000us since previous): time 83185086119 format 20 size 80
Received buffer 6 (22000us since previous): time 83185108684 format 20 size 80
Received buffer 7 (20000us since previous): time 83185128595 format 20 size 80
Received buffer 8 (21000us since previous): time 83185149833 format 20 size 80
Received buffer 9 (22000us since previous): time 83185171072 format 20 size 80
Received buffer 10 (43000us since previous): time 83185213548 format 20 size 80
...
...


#

Publish sensor data specified in the sensor configuration file

# sensor_example -d
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: 2, Type: Lidar, Name: vlp-16
        2) Unit: 3, Type: Radar, Name: esr2.5
        3) Unit: 4, Type: Lidar, Name: vu8
        4) Unit: 5, Type: GPS, Name: xsens_mti-g-710_gps
        5) Unit: 6, Type: IMU, Name: xsens_mti-g-710_imu
        6) Unit: 7, Type: GPS, Name: novatel_oem6_gps
        7) Unit: 8, Type: IMU, Name: novatel_oem6_imu
2
Received buffer 1 (0us since previous): time 83409288859 format 22 size 80
 RADAR POLAR: data_size 2048
Received buffer 2 (50000us since previous): time 83409338858 format 22 size 80
 RADAR POLAR: data_size 2048
Received buffer 3 (50000us since previous): time 83409388857 format 22 size 80
 RADAR POLAR: data_size 2048
Received buffer 4 (50000us since previous): time 83409438857 format 22 size 80
 RADAR POLAR: data_size 2048
Received buffer 5 (50000us since previous): time 83409488856 format 22 size 80
 RADAR POLAR: data_size 2048
Received buffer 6 (51000us since previous): time 83409539855 format 22 size 80
 RADAR POLAR: data_size 2048
Received buffer 7 (50000us since previous): time 83409589855 format 22 size 80
 RADAR POLAR: data_size 2048
Received buffer 8 (49000us since previous): time 83409638854 format 22 size 80
 RADAR POLAR: data_size 2048
Received buffer 9 (50000us since previous): time 83409688853 format 22 size 80
 RADAR POLAR: data_size 2048
Received buffer 10 (50000us since previous): time 83409738853 format 22 size 80
 RADAR POLAR: data_size 2048
...
...

#