Skip to content

Commit

Permalink
Submaster (python): set alive when first seen for simulation=1 (#613)
Browse files Browse the repository at this point in the history
* now should be the same as cc

* need updated

* clear about redefine
  • Loading branch information
ZwX1616 authored May 22, 2024
1 parent 5812f2c commit 51cbf62
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions messaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ def __init__(self, services: List[str], poll: Optional[str] = None,
self.ignore_average_freq = [] if ignore_avg_freq is None else ignore_avg_freq
self.ignore_alive = [] if ignore_alive is None else ignore_alive
self.ignore_valid = [] if ignore_valid is None else ignore_valid
if bool(int(os.getenv("SIMULATION", "0"))):
self.ignore_alive = services
self.ignore_average_freq = services

self.simulation = bool(int(os.getenv("SIMULATION", "0")))

# if freq and poll aren't specified, assume the max to be conservative
assert frequency is None or poll is None, "Do not specify 'frequency' - frequency of the polled service will be used."
Expand Down Expand Up @@ -241,7 +240,7 @@ def update_msgs(self, cur_time: float, msgs: List[capnp.lib.capnp._DynamicStruct
self.valid[s] = msg.valid

for s in self.data:
if SERVICE_LIST[s].frequency > 1e-5:
if SERVICE_LIST[s].frequency > 1e-5 and not self.simulation:
# alive if delay is within 10x the expected frequency
self.alive[s] = (cur_time - self.recv_time[s]) < (10. / SERVICE_LIST[s].frequency)

Expand All @@ -261,7 +260,10 @@ def update_msgs(self, cur_time: float, msgs: List[capnp.lib.capnp._DynamicStruct
self.freq_ok[s] = avg_freq_ok or recent_freq_ok
else:
self.freq_ok[s] = True
self.alive[s] = True
if self.simulation:
self.alive[s] = self.seen[s] # alive is defined as seen when simulation flag set
else:
self.alive[s] = True

def all_alive(self, service_list: Optional[List[str]] = None) -> bool:
if service_list is None:
Expand Down

0 comments on commit 51cbf62

Please sign in to comment.