Network Time Protocol (NTP)
Heard this from a Computerphile video, used for time Synchronization.
Wow, this is actually fascinating. First really used this at Enlighted.
In the case ROS, syncing to an NTP server helps reduce jitter between clocks on devices.
ROS 2 is dependent upon synchronized clocks between nodes to have all data in the same reference time. When the Create® 3 is publishing on topics, it is publishing its data with the timestamp of its system clock, which synchronizes with an NTP server.
- Network Time Protocol (NTP) - Computerphile - YouTube
- Before, Tom tells me they had these time-telling services https://www.aarp.org/work/careers/call-this-number-for-time-fd/, where you would call them to get the actual time
If the Create® 3’s Wi-Fi is connected to a network with internet connection, it will sync to a global time NTP server. The Create® 3 NTP config is also set to listen for servers on USB IP address 192.168.186.1 and 192.168.186.3. If the compute board is connected over USB to the Create® 3 with the compute board assigned one of these IP addresses on its USB interface, NTP on the compute board can keep the clocks between the compute board and Create® 3 in sync, even without an internet connection. If there is an internet connection on both compute board and Create® 3, configuring the NTP server on the compute board to serve the Create® 3 can still add value by reducing jitter between clocks. If your Create® 3 and compute board have an internet connection, this is not required, but is still recommended.
I don’t think if ROS comes out of the box like this, but this is super important to set up.
- I guess ROS uses the system clock, so it is up to the OS to set up proper timing
- On your Compute Board, install chrony NTP server package
sudo apt install chrony
- Edit the config file
sudo vi /etc/chrony/chrony.conf
Add the following lines after the
pool #.ubuntu.pool.ntp.org iburst maxsources #block
server 192.168.186.2 presend 0 minpoll 0 maxpoll 0 iburst prefer trust # Enable serving time to ntp clients on 192.168.186.0 subnet. allow 192.168.186.0/24
Optionally add the following lines immediately afterward if your SBC will not have a connection to a reference clock (i.e., the Internet)
# Serve time even if not synchronized to a time source local stratum 10
sudo service chrony restart
- Verify compute NTP server is talking to the Create® 3
sudo chronyc clients
Confirm 192.168.182.2 shows non 0 number in NTP column
Hostname NTP Drop Int IntL Last Cmd Drop Int Last =============================================================================== 192.168.186.2 51 0 5 - 32 0 0 - - localhost 0 0 - - - 31 0 7 4
Note that if there is a large jump in the time, the Create® 3 may not accept it until its next reboot. This can be verified by checking the Create® 3 robot’s log for a line like
user.notice ntpd: ntpd: reply from 192.168.186.3: delay ### is too high, ignoring
If this happens, simply restart the robot (not just the application) via the webserver over the USB network connection.