Skip to content

Commit

Permalink
Using ubuntu ntp server in systemtest (#346) (#348)
Browse files Browse the repository at this point in the history
* testing with ubuntu ntp server
* message makes a little more sense with abs
* bigger offsets allowed
* organizing imports with isort profile `google`

---------

Signed-off-by: Christian Henkel <[email protected]>
(cherry picked from commit c4f7231)
  • Loading branch information
ct2034 authored May 14, 2024
1 parent e3e410c commit 4dd2252
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@
import threading

import diagnostic_updater as DIAG

import ntplib

import rclpy
from rclpy.node import Node

Expand Down Expand Up @@ -145,16 +143,16 @@ def add_kv(stat_values, key, value):
if (abs(measured_offset) > self.offset):
st.level = DIAG.DiagnosticStatus.WARN
st.message = \
f'NTP offset above threshold: {measured_offset}>'\
f'NTP offset above threshold: abs({measured_offset})>'\
f'{self.offset} us'
if (abs(measured_offset) > self.error_offset):
st.level = DIAG.DiagnosticStatus.ERROR
st.message = \
f'NTP offset above error threshold: {measured_offset}>'\
f'NTP offset above error threshold: abs({measured_offset})>'\
f'{self.error_offset} us'
if (abs(measured_offset) < self.offset):
st.level = DIAG.DiagnosticStatus.OK
st.message = f'NTP Offset OK: {measured_offset} us'
st.message = f'NTP Offset OK: abs({measured_offset}) us'

return st

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,11 @@
import unittest

from diagnostic_msgs.msg import DiagnosticArray

import launch

import launch_ros

import launch_testing

from launch_testing_ros import WaitForTopics

import pytest

import rclpy


Expand All @@ -58,9 +52,10 @@ def generate_test_description():
executable='ntp_monitor.py',
name='ntp_monitor',
output='screen',
arguments=['--offset-tolerance', '10000',
'--error-offset-tolerance', '20000']
# 10s, 20s, we are not testing if your clock is correct
arguments=['--offset-tolerance', '100000',
'--error-offset-tolerance', '200000',
'--ntp_hostname', 'ntp.ubuntu.com']
# 100s, 200s, we are not testing if your clock is correct
),
launch_testing.actions.ReadyToTest()
])
Expand Down

0 comments on commit 4dd2252

Please sign in to comment.