Skip to content

Commit

Permalink
NTP monitor improvements (#342) (#351)
Browse files Browse the repository at this point in the history
* NTP monitor improvements
* commit to run tests again
* bring back double callback
* remove whiteline

---------

Co-authored-by: Angsa Deployment Team <[email protected]>
(cherry picked from commit 7efb71a)

Co-authored-by: Tony Najjar <[email protected]>
  • Loading branch information
ct2034 and tonynajjar authored Jun 26, 2024
1 parent 61ac5e2 commit 5c5f0b3
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ def __init__(self, ntp_hostname, ntp_port, offset=500, self_offset=500,
do_self_test=True):
"""Initialize the NTPMonitor."""
super().__init__(__class__.__name__)
self.declare_parameter('frequency', 10.0)
frequency = self.get_parameter('frequency').get_parameter_value().double_value

self.ntp_hostname = ntp_hostname
self.ntp_port = ntp_port
Expand Down Expand Up @@ -85,8 +87,8 @@ def __init__(self, ntp_hostname, ntp_port, offset=500, self_offset=500,

# we need to periodically republish this
self.current_msg = None
self.pubtimer = self.create_timer(0.1, self.pubCB)
self.checktimer = self.create_timer(0.1, self.checkCB)
self.pubtimer = self.create_timer(1/frequency, self.pubCB)
self.checktimer = self.create_timer(1/frequency, self.checkCB)

def pubCB(self):
with self.mutex:
Expand All @@ -95,6 +97,7 @@ def pubCB(self):

def checkCB(self):
new_msg = DIAG.DiagnosticArray()
new_msg.header.stamp = self.get_clock().now().to_msg()

st = self.ntp_diag(self.stat)
if st is not None:
Expand Down Expand Up @@ -159,7 +162,7 @@ def add_kv(stat_values, key, value):

def ntp_monitor_main(argv=sys.argv[1:]):
# filter out ROS args
argv = [a for a in argv if not a.startswith('__') and not a == '--ros-args' and not a == '-r']
argv = argv[:argv.index('--ros-args')] if '--ros-args' in argv else argv

import argparse
parser = argparse.ArgumentParser()
Expand Down

0 comments on commit 5c5f0b3

Please sign in to comment.