Skip to content

New Robot: Ouster OS 1 Setup PTP

Fernando Cladera edited this page Aug 15, 2022 · 10 revisions

The Ouster OS-1 timestamp does not follow Unix time, and as a result the matching messages with other sensors in ROS is difficult. We use PTP synchronization to synchronize the OS-1 Clock using the Robot NUC computer.

This page details:

  1. Set up a static IP for the OS-1 (preferable over the default DHCP).
  2. Set up the network connection between the NUC and the OS-1.
  3. Set up PTP to synchronize OS-1 clock with NUC clock.
  4. Change the lidar mode (2048x10).

Set up Static IP

Follow the instructions described in Issue: Setting static IP address #114:

Connect to the OS-1 using DHCP and get the [DHCP_IP_ADDRESS].

Choose the OS-1 Static IPv4 Address to set [STATIC_IP_ADDRESS], typically something like 192.168.100.12.

Set the Static IP:

echo '"[STATIC_IP_ADDRESS]/24"' | http -v PUT http://[DHCP_IP_ADDRESS]/api/v1/system/network/ipv4/override

Set up Network Connection

This step is analogous to the Setup connections 1 and 3 in the New Robot: PicoStation page.

The Ouster IPv4 address is the static IP specified in the above section Set up Static IP. Notice the OS-1 is usually on a different subnet than the Picostation.

Set up PTP

The high level steps are:

  1. Tell ethernet card to be a PTP grandmaster by giving it a high priority (clockClass, lower numbers are higher priority)
  2. Tell OS-1 to use the PTP time for it's timestamping and save this config to EEPROM
  3. Start a daemon (phc2sys) to synchronize linux system time with the clock on the ethernet interface with an offset of 0.
  4. Configure the daemons to start on boot

Master - Setup steps

Install the following on the Robot NUC:

sudo apt install linuxptp ethtool

(Optional) If the OS-1 is on a network interface other than eth0. Note that the l in ptp4l.conf is an "el", not a "one":

  1. sudo vim /etc/linuxptp/ptp4l.conf

  2. Append to the end (brackets included), replacing interface with eth0, eth1, etc.

    [interface]

    In this example, interface was eno1:

Create an /etc/systemd/system/ptp4l.service.d/override.conf:

sudo mkdir -p /etc/systemd/system/ptp4l.service.d
sudo vim /etc/systemd/system/ptp4l.service.d/override.conf

Paste the following:

[Service]
ExecStart=
ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf

Create an /etc/systemd/system/phc2sys.service.d/override.conf

sudo mkdir -p /etc/systemd/system/phc2sys.service.d
sudo vim /etc/systemd/system/phc2sys.service.d/override.conf

Paste the following, replace eth0 with the relevant interface name:

[Service]
ExecStart=
ExecStart=/usr/sbin/phc2sys -s CLOCK_REALTIME -c eth0 -O 0

Change the clockClass to 128:

sudo vim /etc/linuxptp/ptp4l.conf

Ouster PTP Configuration

Open Netcat, which opens a sort of terminal window, changing 192.168.100.12 to the static IPv4 you set for the OS-1:

netcat 192.168.100.12 7501

Inside Netcat, run:

set_config_param timestamp_mode TIME_FROM_PTP_1588
reinitialize
write_config_txt

Starting phc2sys to sync Master Clock

On NUC (DON'T DO THIS ON XAVIER!)

sudo systemctl enable phc2sys

Then reboot and power cycle the Ouster.

Check if the PTP synchronization worked:

Check the linux time on the NUC

date +%s

Check the OS-1 time using netcat:

netcat 192.168.100.12 7501
get_time_info

The two times should match. If the PTP synchronization does not work, then get_time_info would return the number of seconds since the OS-1 was turned on.

Change lidar mode

netcat 192.168.100.12 7501
get_config_param active lidar_mode
set_config_param lidar_mode 2048x10
write_config_txt
reinitialize

The new lidar mode should be reflected in the Ouster webpage:

Clone this wiki locally