Skip to content

Commit

Permalink
carEvent -> onroadEvent (commaai#33432)
Browse files Browse the repository at this point in the history
  • Loading branch information
adeebshihadeh committed Sep 1, 2024
1 parent fefb033 commit c481f11
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 21 deletions.
8 changes: 5 additions & 3 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ $Cxx.namespace("cereal");

# ******* events causing controls state machine transition *******

struct CarEvent @0x9b1657f34caf3ad3 {
# FIXME: OnroadEvent shouldn't be in car.capnp, but can't immediately
# move due to being referenced by structs in this file
struct OnroadEvent @0x9b1657f34caf3ad3 {
name @0 :EventName;

# event types
Expand Down Expand Up @@ -152,7 +154,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
# all speeds in m/s

struct CarState {
events @13 :List(CarEvent);
events @13 :List(OnroadEvent);

# CAN health
canValid @26 :Bool; # invalid counter/checksums
Expand Down Expand Up @@ -281,7 +283,7 @@ struct CarState {
}

# deprecated
errorsDEPRECATED @0 :List(CarEvent.EventName);
errorsDEPRECATED @0 :List(OnroadEvent.EventName);
brakeLightsDEPRECATED @19 :Bool;
steeringRateLimitedDEPRECATED @29 :Bool;
canMonoTimesDEPRECATED @12: List(UInt64);
Expand Down
6 changes: 3 additions & 3 deletions cereal/log.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -1149,7 +1149,7 @@ struct LongitudinalPlan @0xe00b5b3eba12876c {
radarValidDEPRECATED @28 :Bool;
radarCanErrorDEPRECATED @30 :Bool;
commIssueDEPRECATED @31 :Bool;
eventsDEPRECATED @13 :List(Car.CarEvent);
eventsDEPRECATED @13 :List(Car.OnroadEvent);
gpsTrajectoryDEPRECATED @12 :GpsTrajectory;
gpsPlannerActiveDEPRECATED @19 :Bool;
personalityDEPRECATED @36 :LongitudinalPersonality;
Expand Down Expand Up @@ -2055,7 +2055,7 @@ struct DriverStateDEPRECATED @0xb83c6cc593ed0a00 {
}

struct DriverMonitoringState @0xb83cda094a1da284 {
events @0 :List(Car.CarEvent);
events @0 :List(Car.OnroadEvent);
faceDetected @1 :Bool;
isDistracted @2 :Bool;
distractedType @17 :UInt32;
Expand Down Expand Up @@ -2346,7 +2346,7 @@ struct Event {
liveTorqueParameters @94 :LiveTorqueParametersData;
cameraOdometry @63 :CameraOdometry;
thumbnail @66: Thumbnail;
onroadEvents @68: List(Car.CarEvent);
onroadEvents @68: List(Car.OnroadEvent);
carParams @69: Car.CarParams;
driverMonitoringState @71: DriverMonitoringState;
livePose @129 :LivePose;
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/car_specific.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

ButtonType = structs.CarState.ButtonEvent.Type
GearShifter = structs.CarState.GearShifter
EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName
NetworkLocation = structs.CarParams.NetworkLocation


Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

REPLAY = "REPLAY" in os.environ

EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName

# forward
carlog.addHandler(ForwardingHandler(cloudlog))
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

from panda.tests.libpanda import libpanda_py

EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName
PandaType = log.PandaState.PandaType
SafetyModel = car.CarParams.SafetyModel

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
Desire = log.Desire
LaneChangeState = log.LaneChangeState
LaneChangeDirection = log.LaneChangeDirection
EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName
ButtonType = car.CarState.ButtonEvent.Type
SafetyModel = car.CarParams.SafetyModel

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/lib/drive_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from openpilot.common.realtime import DT_CTRL
from openpilot.system.version import get_build_metadata

EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName

# WARNING: this value was determined based on the model's training distribution,
# model predictions above this speed can be unpredictable
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/controls/lib/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
AlertStatus = log.SelfdriveState.AlertStatus
VisualAlert = car.CarControl.HUDControl.VisualAlert
AudibleAlert = car.CarControl.HUDControl.AudibleAlert
EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName


# Alert priorities
Expand Down Expand Up @@ -98,7 +98,7 @@ def add_from_msg(self, events):
def to_msg(self):
ret = []
for event_name in self.events:
event = car.CarEvent.new_message()
event = car.OnroadEvent.new_message()
event.name = event_name
for event_type in EVENTS.get(event_name, {}):
setattr(event, event_type, True)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/tests/test_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def setup_class(cls):

def test_events_defined(self):
# Ensure all events in capnp schema are defined in events.py
events = car.CarEvent.EventName.schema.enumerants
events = car.OnroadEvent.EventName.schema.enumerants

for name, e in events.items():
if not name.endswith("DEPRECATED"):
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/controls/tests/test_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from openpilot.selfdrive.controls.lib.events import EVENT_NAME
from openpilot.system.manager.process_config import managed_processes

EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName
Ecu = car.CarParams.Ecu

COROLLA_FW_VERSIONS = [
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/debug/cycle_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from openpilot.selfdrive.controls.lib.alertmanager import AlertManager
from openpilot.system.manager.process_config import managed_processes

EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName

def randperc() -> float:
return 100. * random.random()
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/monitoring/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from openpilot.common.stat_live import RunningStatFilter
from openpilot.common.transformations.camera import DEVICE_CAMERAS

EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName

# ******************************************************************************************
# NOTE: To fork maintainers.
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/monitoring/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from openpilot.common.realtime import DT_DMON
from openpilot.selfdrive.monitoring.helpers import DriverMonitoring, DRIVER_MONITOR_SETTINGS

EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName
dm_settings = DRIVER_MONITOR_SETTINGS()

TEST_TIMESPAN = 120 # seconds
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/test/process_replay/process_replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ def controlsd_config_callback(params, cfg, lr):
if initialized:
break
elif msg.which() == "onroadEvents":
initialized = car.CarEvent.EventName.controlsInitializing not in [e.name for e in msg.onroadEvents]
initialized = car.OnroadEvent.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 Down
2 changes: 1 addition & 1 deletion selfdrive/test/test_onroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def test_startup(self):
if msg.which() == "selfdriveState":
startup_alert = msg.selfdriveState.alertText1
break
expected = EVENTS[car.CarEvent.EventName.startup][ET.PERMANENT].alert_text_1
expected = EVENTS[car.OnroadEvent.EventName.startup][ET.PERMANENT].alert_text_1
assert startup_alert == expected, "wrong startup alert"

def test_engagable(self):
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/test/test_time_to_onroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from openpilot.common.timeout import Timeout
from openpilot.selfdrive.test.helpers import set_params_enabled

EventName = car.CarEvent.EventName
EventName = car.OnroadEvent.EventName


@pytest.mark.tici
Expand Down

0 comments on commit c481f11

Please sign in to comment.