Skip to content

New Robot: Ouster OS 1 Setup PTP

Fernando Cladera edited this page Oct 21, 2024 · 8 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.1. 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.1 , 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

IMPORTANT: these steps have been tested with Ubuntu 22. Lower versions of Ubuntu may have a different configuration, particularly because the services are not interface dependent.

Software install

Install the following on the Robot NUC:

sudo apt install linuxptp ethtool

Cleanup old overrides

It is a good idea to clear old override files. These files could be dangling from older versions of Ubuntu if the system was reinstalled. To do this:

systemctl disable phc2sys.service
systemctl disable ptp4l.service
cd /etc/systemd/system
rm -rf phc2sys*
rm -rf ptp4l*

Create phc2sys override

We need to override this file as the default configuration is not adequate. Replace interface with your interface name (enp5s0, enp6s0).

systemctl edit --full [email protected]

Change the lines

Requires=ptp4l.service
After=ptp4l.service

To

And change the last line ExecStart to (replace interface)

ExecStart=
ExecStart=/usr/sbin/phc2sys -s CLOCK_REALTIME -c interface -O 0

Configure ptp4l

Note that the l in ptp4l.conf is an "el", not a "one".

Change the clockClass to 128:

sudo vim /etc/linuxptp/ptp4l.conf

(Optional) If the OS-1 is on a network interface other than eth0, Append to the end (brackets included), replacing interface with enp5s0, enp6s0, etc.

[interface]

Starting all the services

Replace interface with your interface name (enp5s0, enp6s0).

 sudo systemctl daemon-reload
 sudo systemctl enable --now [email protected]
 sudo systemctl enable --now [email protected]

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

Important: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