IFL-CAMP / iiwa_stack

ROS integration for the KUKA LBR IIWA R800/R820 (7/14 Kg).
Other
331 stars 248 forks source link

[Wiki] NTP server setup #208

Open exo-core opened 5 years ago

exo-core commented 5 years ago

As the wiki page about syncing the clocks via NTP is still an open to-do and I had to setup the NTP machine from scratch again today, I thought it might be a good idea to document what needed to do.


  1. sudo apt install ntp
  2. Create a copy of your current NTP configuration: sudo mv /etc/ntp.conf /etc/ntp.conf.backup
  3. Create a new configuration file at `/etc/ntp.conf`` and past the following configuration there:

    tinker panic 0
    
    server ntp1.informatik.tu-muenchen.de
    server ntp2.informatik.tu-muenchen.de
    
    restrict default kod nomodify notrap nopeer noquery
    restrict -6 default kod nomodify notrap nopeer noquery
    
    restrict 127.0.0.1
    restrict ::1
    
    restrict 131.159.254.0 mask 255.255.254.0
    
    driftfile /var/lib/ntp/ntp.drift
    
    server 127.127.1.0
    fudge 127.127.1.0 stratum 10
    
    # Allow LAN machines to synchronize with this ntp server
    restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
    restrict 192.168.2.0 mask 255.255.255.0 nomodify notrap
  4. Adjust the file by changing the replacing the NTP servers in the lines

    server ntp1.informatik.tu-muenchen.de
    server ntp2.informatik.tu-muenchen.de
    
    ...
    
    restrict 131.159.254.0 mask 255.255.254.0

    to the ones of your choice. If you are in a local network of a university or research organization you might need to use the NTP server(s) provided by your IT department.

  5. You might also need to adjust the network range in the last two lines:
    # Allow LAN machines to synchronize with this ntp server
    restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
    restrict 192.168.2.0 mask 255.255.255.0 nomodify notrap

    In our case our iiwa's IP is set to 192.168.1.3

  6. (Re)start your NTP service: sudo service ntp restart
  7. Check you server status with watch ntpq -np. The output should look like this:
     remote           refid      st t when poll reach   delay   offset  jitter
    ==============================================================================
    127.127.1.0     .LOCL.          10 l   60   64   17    0.000    0.000   0.000
    +131.159.254.94  131.159.254.95   3 u   59   64   17    1.910    1.280   1.319
    *131.159.254.77  131.159.254.95   3 u   51   64   17    1.213   -0.178   0.881
  8. Set Enable NTP in the iiwa configuration to true
  9. Enjoy correct timestamps :wink:
JimmyDaSilva commented 4 years ago

@exo-core Thanks for sharing your experience to help others. I seem to have a communication issue creating jumps in the commands received by the KRC. I would like to make sure it is not coming from a bad configuration of NTP.

Do you know how I could check that the ROSSmartServo app is indeed finding/using my ntp server ?

(I am in the same case as you, my university is providing a NTP server on the network)

Thanks a lot again, Jimmy