Synchronizing Sensor Timestamps

Updated: April 19, 2023

The Sensor (sensor) service supports the use of Precision Time Protocol to synchronize the timestamps for sensors across multiple target boards.

The Sensor service generates the sensor timestamps based on the target board where the Precision Time Protocol daemon (ptpd) was started as the master. Other target boards run ptpd as workers. Timestamps for sensors are synchronized across the multiple boards. For more information on this daemon, see the ptpd entry in the Utilities Reference.

When you use Precision Time Protocol to synchronize sensor timestamps, you need to:

  1. Specify ptp with the reference_clock parameter in your sensor configuration file, for the units whose timestamps you want synchronized.

    In the sensor configuration file on each target board, you must configure the sensors to use Precision Time Protocol; for example:

    begin SENSOR_UNIT_1
        type = file_data
        name = vu8
        address = /usr/share/sensor_data/adas_example_leddartech_vu8
        direction = 0,0,0
        position = 0,0,0
        reference_clock = ptp
    end SENSOR_UNIT_1
    
  2. Specify ptpd to start as master on one of the target boards. This must be started prior to starting the Sensor service.

    To do so, start ptpd in master mode; for example:

    ...
    <SLM:component name="ptpd-master">
        <SLM:command>/base/scripts/ptpd-start-master.sh</SLM:command>
        <SLM:depend>settime</SLM:depend>
        <SLM:waitfor wait="pathname">/dev/ptpd</SLM:waitfor>
    </SLM:component>
    
    <SLM:component name="sensor">
        <SLM:command>/base/bin/sensor</SLM:command>
        <SLM:args>-U 521:521,1001 -r /accounts/1000/shared/camera
                    -c /base/etc/system/config/leddartech_vu8_capture_ptp.conf
                    -d /base/etc/system/config/leddartech_vu8_capture_interim.conf</SLM:args>
        <SLM:depend>resarb</SLM:depend>
        <SLM:depend>ptpd-master</SLM:depend>
        <SLM:depend>screen-ready</SLM:depend>
        <SLM:waitfor wait="pathname">/dev/sensor/data1</SLM:waitfor>
    </SLM:component>
    ...
    
    where ptpd-start-master.sh is a script that starts ptpd in master mode; for example:
    #!/bin/sh
    # start the PTP daemon in master mode
    ptpd -W -K -L -b $ETHERNET_IF_NAME
    
  3. Specify ptpd to start as worker on the other target boards. This must be started prior to starting the Sensor service.

    To do so, start ptpd in worker mode; for example:

    ...
    <SLM:component name="ptpd-worker">
        <SLM:command>/base/scripts/ptpd-start-worker.sh</SLM:command>
        <SLM:depend>settime</SLM:depend>
        <SLM:waitfor wait="pathname">/dev/ptpd</SLM:waitfor>
    </SLM:component>
    
    <SLM:component name="sensor">
        <SLM:command>/base/bin/sensor</SLM:command>
        <SLM:args>-U 521:521,1001 -r /accounts/1000/shared/camera
                     -c /base/etc/system/config/leddartech_vu8_capture_ptp.conf</SLM:args>
        <SLM:depend>resarb</SLM:depend>
        <SLM:depend>ptpd-worker</SLM:depend>
        <SLM:depend>screen-ready</SLM:depend>
        <SLM:waitfor wait="pathname">/dev/sensor/sensor1</SLM:waitfor>
    </SLM:component>
    ...
    
    where ptpd-start-worker.sh is a script that starts ptpd in worker mode; for example:
    #!/bin/sh
    # start the PTP daemon in worker mode
    ptpd -g -K -L -b $ETHERNET_IF_NAME