Using Chrony to Synchronise System Clocks for Robotic Platforms

Preamble

If you are utilising multiple Ubuntu systems in your robotic deployment it can be advantageous to have the system clocks synchronised. This is a fairly common occurrence with engineers looking to utilise the distributed nature of ROS and other middleware. If you are interested in this you might also be interested in my previous post on sharing internet connections over a LAN.

Requirements

For this you’ll need at least two separate Ubuntu systems connected to each other over a LAN, VPN or similar. You’ll also need to have static IP addresses assigned for each system.

For the case of this example I’ll assume machine designated as the server to be 172.31.1.10 and the client to be 172.31.1.*.

Both machines will need to install Chrony…

sudo apt-get update
sudo apt-get install chrony

I think it’s useful to have our configuration files separate to the original. To do this…

sudo mkdir /etc/chrony/chrony.conf.d/

…and add the following line to the end of /etc/chrony/chrony.conf…

include /etc/chrony/chrony.conf.d/*

Client Side Setup

Create our configuration file…

touch /etc/chrony/chrony.conf.d/client.conf

…and add the following…

server 172.31.1.10 port 123 minpoll 5 maxpoll 10 iburst maxdelay 0.3 trust

…and restarted Chrony.

sudo systemctl restart chrony

Server Setup

Create our configuration file…

touch /etc/chrony/chrony.conf.d/server.conf

…and add the following…

allow 172.31.1.0/24
port 123
acquisitionport 123

…and restarted Chrony.

sudo systemctl restart chrony

Testing

On the NTP server we can check for connections using…

watch sudo chronyc -n clients

If we ssh over to the client, we can check the server connection using…

watch chronyc -n sourcestats

Resources and Further Reading

Chrony Examples Chrony Conf Documentation

See here and here for advice on testing and further reading related to time synchronisation and ROS.

Hey you!

Found this useful or interesting?

Consider donating to support.

Any question, comments, corrections or suggestions?

Reach out on the social links below through the buttons.