Skip to content

Commit

Permalink
rename carEvents -> onroadEvents (commaai#30577)
Browse files Browse the repository at this point in the history
* rename carEvents -> onroadEvents

* bump cereal

* bump cereal
  • Loading branch information
adeebshihadeh authored Dec 2, 2023
1 parent 8e00ce6 commit b97e5b0
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion cereal
12 changes: 6 additions & 6 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, CI=None):

# Setup sockets
self.pm = messaging.PubMaster(['sendcan', 'controlsState', 'carState',
'carControl', 'carEvents', 'carParams'])
'carControl', 'onroadEvents', 'carParams'])

self.sensor_packets = ["accelerometer", "gyroscope"]
self.camera_packets = ["roadCameraState", "driverCameraState", "wideRoadCameraState"]
Expand Down Expand Up @@ -212,7 +212,7 @@ def set_initial_state(self):
self.state = State.enabled

def update_events(self, CS):
"""Compute carEvents from carState"""
"""Compute onroadEvents from carState"""

self.events.clear()

Expand Down Expand Up @@ -823,11 +823,11 @@ def publish_logs(self, CS, start_time, CC, lac_log):
cs_send.carState.events = car_events
self.pm.send('carState', cs_send)

# carEvents - logged every second or on change
# onroadEvents - logged every second or on change
if (self.sm.frame % int(1. / DT_CTRL) == 0) or (self.events.names != self.events_prev):
ce_send = messaging.new_message('carEvents', len(self.events))
ce_send.carEvents = car_events
self.pm.send('carEvents', ce_send)
ce_send = messaging.new_message('onroadEvents', len(self.events))
ce_send.onroadEvents = car_events
self.pm.send('onroadEvents', ce_send)
self.events_prev = self.events.names.copy()

# carParams - logged every 50 seconds (> 1 per segment)
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/debug/count_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
end_time = max(end_time, msg.logMonoTime)
start_time = min(start_time, msg.logMonoTime)

if msg.which() == 'carEvents':
for e in msg.carEvents:
if msg.which() == 'onroadEvents':
for e in msg.onroadEvents:
cnt_events[e.name] += 1
elif msg.which() == 'controlsState':
if len(alerts) == 0 or alerts[-1][1] != msg.controlsState.alertType:
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/test/process_replay/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ optional arguments:
--blacklist-procs BLACKLIST_PROCS Blacklist given processes from the test (e.g. controlsd)
--blacklist-cars BLACKLIST_CARS Blacklist given cars from the test (e.g. HONDA)
--ignore-fields IGNORE_FIELDS Extra fields or msgs to ignore (e.g. carState.events)
--ignore-msgs IGNORE_MSGS Msgs to ignore (e.g. carEvents)
--ignore-msgs IGNORE_MSGS Msgs to ignore (e.g. onroadEvents)
--update-refs Updates reference logs using current commit
--upload-only Skips testing processes and uploads logs from previous test run
```
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/test/process_replay/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def pytest_addoption(parser: pytest.Parser):
parser.addoption("--ignore-fields", type=str, nargs="*", default=[],
help="Extra fields or msgs to ignore (e.g. carState.events)")
parser.addoption("--ignore-msgs", type=str, nargs="*", default=[],
help="Msgs to ignore (e.g. carEvents)")
help="Msgs to ignore (e.g. onroadEvents)")
parser.addoption("--update-refs", action="store_true",
help="Updates reference logs using current commit")
parser.addoption("--upload-only", action="store_true",
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/test/process_replay/process_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ def controlsd_config_callback(params, cfg, lr):
controlsState = msg.controlsState
if initialized:
break
elif msg.which() == "carEvents":
initialized = car.CarEvent.EventName.controlsInitializing not in [e.name for e in msg.carEvents]
elif msg.which() == "onroadEvents":
initialized = car.CarEvent.EventName.controlsInitializing not in [e.name for e in msg.onroadEvents]

assert controlsState is not None and initialized, "controlsState never initialized"
params.put("ReplayControlsState", controlsState.as_builder().to_bytes())
Expand All @@ -465,7 +465,7 @@ def locationd_config_pubsub_callback(params, cfg, lr):
"modelV2", "driverCameraState", "roadCameraState", "wideRoadCameraState", "managerState",
"testJoystick", "liveTorqueParameters", "accelerometer", "gyroscope"
],
subs=["controlsState", "carState", "carControl", "sendcan", "carEvents", "carParams"],
subs=["controlsState", "carState", "carControl", "sendcan", "onroadEvents", "carParams"],
ignore=["logMonoTime", "valid", "controlsState.startMonoTime", "controlsState.cumLagMs"],
config_callback=controlsd_config_callback,
init_callback=controlsd_fingerprint_callback,
Expand Down
6 changes: 3 additions & 3 deletions selfdrive/test/test_onroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def test_timings(self):
def test_startup(self):
startup_alert = None
for msg in self.lrs[0]:
# can't use carEvents because the first msg can be dropped while loggerd is starting up
# can't use onroadEvents because the first msg can be dropped while loggerd is starting up
if msg.which() == "controlsState":
startup_alert = msg.controlsState.alertText1
break
Expand All @@ -417,8 +417,8 @@ def test_startup(self):

def test_engagable(self):
no_entries = Counter()
for m in self.service_msgs['carEvents']:
for evt in m.carEvents:
for m in self.service_msgs['onroadEvents']:
for evt in m.onroadEvents:
if evt.noEntry:
no_entries[evt.name] += 1

Expand Down
4 changes: 2 additions & 2 deletions selfdrive/test/test_time_to_onroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def test_time_to_onroad():
proc = subprocess.Popen(["python", manager_path])

start_time = time.monotonic()
sm = messaging.SubMaster(['controlsState', 'deviceState', 'carEvents'])
sm = messaging.SubMaster(['controlsState', 'deviceState', 'onroadEvents'])
try:
# wait for onroad
with Timeout(20, "timed out waiting to go onroad"):
Expand All @@ -40,7 +40,7 @@ def test_time_to_onroad():
# once we're enageable, must be for the next few seconds
for _ in range(500):
sm.update(100)
assert sm['controlsState'].engageable, f"events: {sm['carEvents']}"
assert sm['controlsState'].engageable, f"events: {sm['onroadEvents']}"
finally:
proc.terminate()
if proc.wait(60) is None:
Expand Down
4 changes: 2 additions & 2 deletions tools/sim/tests/test_sim_bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_engage(self):
p_manager = subprocess.Popen("./launch_openpilot.sh", cwd=SIM_DIR)
self.processes.append(p_manager)

sm = messaging.SubMaster(['controlsState', 'carEvents', 'managerState'])
sm = messaging.SubMaster(['controlsState', 'onroadEvents', 'managerState'])
q = Queue()
carla_bridge = self.create_bridge()
p_bridge = carla_bridge.run(q, retries=10)
Expand All @@ -46,7 +46,7 @@ def test_engage(self):
sm.update()

not_running = [p.name for p in sm['managerState'].processes if not p.running and p.shouldBeRunning]
car_event_issues = [event.name for event in sm['carEvents'] if any([event.noEntry, event.softDisable, event.immediateDisable])]
car_event_issues = [event.name for event in sm['onroadEvents'] if any([event.noEntry, event.softDisable, event.immediateDisable])]

if sm.all_alive() and len(car_event_issues) == 0 and len(not_running) == 0:
no_car_events_issues_once = True
Expand Down

0 comments on commit b97e5b0

Please sign in to comment.