mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-31 21:23:49 +08:00
End The Suffering
This commit is contained in:
@@ -926,7 +926,7 @@ class SelfdriveD:
|
||||
fpss.alertSize = self.starpilot_AM.current_alert.alert_size
|
||||
fpss.alertStatus = self.starpilot_AM.current_alert.alert_status
|
||||
fpss.alertType = self.starpilot_AM.current_alert.alert_type
|
||||
fpss.vEgo = self.sm["carState"].vEgo
|
||||
fpss.vEgo = CS.vEgo
|
||||
fpss.alertSound, self.forcing_stop_chime_played = filter_forcing_stop_alert_sound(
|
||||
fpss.alertType,
|
||||
self.starpilot_AM.current_alert.audible_alert,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
import cereal.messaging as messaging
|
||||
|
||||
from cereal import car, custom, log
|
||||
@@ -40,6 +42,64 @@ def test_dead_or_slow_comm_issue_is_immediate():
|
||||
assert evaluate_comm_issue(False, True, False, 0) == (True, 0)
|
||||
|
||||
|
||||
def test_starpilot_selfdrive_state_uses_sampled_car_state_speed():
|
||||
class FakeEvents:
|
||||
names = []
|
||||
|
||||
@staticmethod
|
||||
def contains(_event_type):
|
||||
return False
|
||||
|
||||
class FakeSubMaster:
|
||||
frame = 1
|
||||
|
||||
@staticmethod
|
||||
def __getitem__(service):
|
||||
if service == "starpilotPlan":
|
||||
return SimpleNamespace(forcingStop=False)
|
||||
raise KeyError(service)
|
||||
|
||||
class FakePubMaster:
|
||||
def __init__(self):
|
||||
self.messages = {}
|
||||
|
||||
def send(self, service, message):
|
||||
self.messages[service] = message
|
||||
|
||||
stock_alert = SimpleNamespace(
|
||||
alert_text_1="", alert_text_2="", alert_size=log.SelfdriveState.AlertSize.none,
|
||||
alert_status=log.SelfdriveState.AlertStatus.normal, alert_type="",
|
||||
audible_alert=log.SelfdriveState.AudibleAlert.none,
|
||||
visual_alert=car.CarControl.HUDControl.VisualAlert.none,
|
||||
)
|
||||
starpilot_alert = SimpleNamespace(
|
||||
alert_text_1="", alert_text_2="", alert_size=custom.StarPilotSelfdriveState.AlertSize.none,
|
||||
alert_status=custom.StarPilotSelfdriveState.AlertStatus.normal, alert_type="",
|
||||
audible_alert=log.SelfdriveState.AudibleAlert.none,
|
||||
)
|
||||
|
||||
selfdrived = SelfdriveD.__new__(SelfdriveD)
|
||||
selfdrived.enabled = False
|
||||
selfdrived.active = False
|
||||
selfdrived.state_machine = SimpleNamespace(state=log.SelfdriveState.OpenpilotState.disabled)
|
||||
selfdrived.events = FakeEvents()
|
||||
selfdrived.starpilot_events = FakeEvents()
|
||||
selfdrived.events_prev = []
|
||||
selfdrived.starpilot_events_prev = []
|
||||
selfdrived.experimental_mode = False
|
||||
selfdrived.personality = log.LongitudinalPersonality.standard
|
||||
selfdrived.AM = SimpleNamespace(current_alert=stock_alert)
|
||||
selfdrived.starpilot_AM = SimpleNamespace(current_alert=starpilot_alert)
|
||||
selfdrived.forcing_stop_chime_played = False
|
||||
selfdrived.sm = FakeSubMaster()
|
||||
selfdrived.pm = FakePubMaster()
|
||||
|
||||
selfdrived.publish_selfdriveState(car.CarState.new_message(vEgo=12.5))
|
||||
|
||||
msg = selfdrived.pm.messages["starpilotSelfdriveState"]
|
||||
assert msg.starpilotSelfdriveState.vEgo == 12.5
|
||||
|
||||
|
||||
class FakeFallbackParams:
|
||||
def __init__(self, controls_ready, ecu_disable_failed, fallback_cp, fallback_fpcp):
|
||||
self.controls_ready = controls_ready
|
||||
|
||||
Reference in New Issue
Block a user