Skip to content

New Robot: Ouster OS 1 Setup PTP

Falcon 4 Kumar Lab edited this page Dec 21, 2022 · 7 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:

Take note of the Serial Number of the lidar you are configuring by looking on the top sticker of the unit. There should be a 12 digit number. This hostname of this unit is os-xxxxxxxxxxxx.local where the x's are the 12 digit number. This hostname will be referred to as [sensor_hostname]

Connect the OS-1 to the Motherboard on the robot through ethernet. Run ip a to see if there is a connection through the ethernet interface (typically enp0s31f6) on the robots.

If there is no IP address for your ethernet device, through NetworkManager, simply change the IPV4 connection to "Link-Local Only" and run sudo systemctl restart NetworkManager.service and then run ip a. If you notice the address is still missing from this command, perform a reboot to the system.

After seeing an address is assigned to the ethernet device, simply ping -4 -c3 [sensor_hostname]

There should be a response with an IP address. This is the IP address of the Ouster unit and will be referred to as [DHCP_LL_IP_ADDRESS] throughout the remainder of this guide.

Choose the OS-1 Static IPv4 Address to set [STATIC_IP_ADDRESS], 192.168.100.12 should be used for this, as to keep consistency throughout the platforms.

Set the Static IP:

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

Set up Network Connection

Now that the Ouster Static IP Address is set, one must configure the host machine to be able to reach that address. This is done by using NetworkManager to set a Static IP of 192.168.100.X where X is NOT 12. From there, run sudo systemctl restart NetworkManager.service and then run ip a. If you notice the address of your ethernet device is not 192.168.100.X , perform a reboot to the system.

From there, ping 192.168.100.12 to confirm you have a proper connection to the Static IP that was set on the Ouster.

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]

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

 sudo systemctl daemon-reload
 sudo systemctl enable --now ptp4l.service

Ouster PTP Configuration

Open Netcat,changing 192.168.100.12 to the static IPv4 you set for the OS-1:

netcat 192.168.100.12 7501

After this, nothing will be displayed, directly continue to 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