mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-28 01:52:06 +08:00
again
This commit is contained in:
@@ -149,6 +149,24 @@ def get_adas_keepalive_step(CP, is_kaofui_car):
|
||||
return None
|
||||
|
||||
|
||||
def should_send_adas_status(CP, is_kaofui_car):
|
||||
if CP.radarUnavailable:
|
||||
return False
|
||||
|
||||
if not is_kaofui_car:
|
||||
return True
|
||||
|
||||
# Volt ASCM/SASCM installs retain the stock radar-status source. Replacing it
|
||||
# faults cruise as soon as the accelerator changes the stock radar state.
|
||||
if CP.carFingerprint == CAR.CHEVROLET_VOLT_ASCM:
|
||||
return False
|
||||
|
||||
if CP.carFingerprint in ASCM_INT:
|
||||
return True
|
||||
|
||||
return CP.networkLocation != NetworkLocation.fwdCamera and CP.carFingerprint not in SDGM_CAR
|
||||
|
||||
|
||||
def get_testing_ground_1_brake_switch_bias(v_ego: float) -> int:
|
||||
return int(round(np.interp(v_ego, [0.0, 6.0, 15.0, 30.0], [40.0, 85.0, 130.0, 170.0])))
|
||||
|
||||
@@ -928,33 +946,27 @@ class CarController(CarControllerBase):
|
||||
|
||||
# Radar needs to know current speed and yaw rate (50hz),
|
||||
# and that ADAS is alive (10hz)
|
||||
if not self.CP.radarUnavailable:
|
||||
send_adas = True
|
||||
if should_send_adas_status(self.CP, self.CP.carFingerprint in kaofui_cars):
|
||||
tt = self.frame * DT_CTRL
|
||||
if self.CP.carFingerprint in kaofui_cars:
|
||||
if self.CP.carFingerprint not in ASCM_INT:
|
||||
send_adas = (self.CP.networkLocation != NetworkLocation.fwdCamera) and (self.CP.carFingerprint not in SDGM_CAR)
|
||||
|
||||
if send_adas:
|
||||
tt = self.frame * DT_CTRL
|
||||
if self.CP.carFingerprint in kaofui_cars:
|
||||
time_and_headlights_step = 10
|
||||
speed_and_accelerometer_step = 2
|
||||
if self.frame % time_and_headlights_step == 0:
|
||||
idx = (self.frame // time_and_headlights_step) % 4
|
||||
can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx))
|
||||
can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE))
|
||||
if self.frame % speed_and_accelerometer_step == 0:
|
||||
idx = (self.frame // speed_and_accelerometer_step) % 4
|
||||
can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx))
|
||||
can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx))
|
||||
else:
|
||||
time_and_headlights_step = 20
|
||||
if self.frame % time_and_headlights_step == 0:
|
||||
idx = (self.frame // time_and_headlights_step) % 4
|
||||
can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx))
|
||||
can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE))
|
||||
can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx))
|
||||
can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx))
|
||||
time_and_headlights_step = 10
|
||||
speed_and_accelerometer_step = 2
|
||||
if self.frame % time_and_headlights_step == 0:
|
||||
idx = (self.frame // time_and_headlights_step) % 4
|
||||
can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx))
|
||||
can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE))
|
||||
if self.frame % speed_and_accelerometer_step == 0:
|
||||
idx = (self.frame // speed_and_accelerometer_step) % 4
|
||||
can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx))
|
||||
can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx))
|
||||
else:
|
||||
time_and_headlights_step = 20
|
||||
if self.frame % time_and_headlights_step == 0:
|
||||
idx = (self.frame // time_and_headlights_step) % 4
|
||||
can_sends.append(gmcan.create_adas_time_status(CanBus.OBSTACLE, int((tt - self.start_time) * 60), idx))
|
||||
can_sends.append(gmcan.create_adas_headlights_status(self.packer_obj, CanBus.OBSTACLE))
|
||||
can_sends.append(gmcan.create_adas_steering_status(CanBus.OBSTACLE, idx))
|
||||
can_sends.append(gmcan.create_adas_accelerometer_speed_status(CanBus.OBSTACLE, CS.out.vEgo, idx))
|
||||
|
||||
keepalive_step = get_adas_keepalive_step(self.CP, self.CP.carFingerprint in kaofui_cars)
|
||||
if keepalive_step is not None and self.frame % keepalive_step == 0:
|
||||
|
||||
@@ -48,6 +48,7 @@ from opendbc.car.gm.carcontroller import (
|
||||
should_activate_volt_one_pedal,
|
||||
should_neutralize_volt_long_on_driver_override,
|
||||
should_send_stock_long_cancel,
|
||||
should_send_adas_status,
|
||||
should_suppress_volt_stock_cancel_in_park,
|
||||
should_suppress_volt_stock_long_pre_drive,
|
||||
should_spoof_dash_speed,
|
||||
@@ -155,6 +156,36 @@ def test_live_camera_path_does_not_send_pt_keepalive():
|
||||
assert get_adas_keepalive_step(cp, is_kaofui_car=True) is None
|
||||
|
||||
|
||||
def test_volt_ascm_does_not_replace_stock_radar_status():
|
||||
cp = SimpleNamespace(
|
||||
carFingerprint=CAR.CHEVROLET_VOLT_ASCM,
|
||||
networkLocation=CarParams.NetworkLocation.fwdCamera,
|
||||
radarUnavailable=False,
|
||||
)
|
||||
|
||||
assert not should_send_adas_status(cp, is_kaofui_car=True)
|
||||
|
||||
|
||||
def test_other_ascm_int_cars_send_radar_status():
|
||||
cp = SimpleNamespace(
|
||||
carFingerprint=CAR.BUICK_LACROSSE_ASCM,
|
||||
networkLocation=CarParams.NetworkLocation.fwdCamera,
|
||||
radarUnavailable=False,
|
||||
)
|
||||
|
||||
assert should_send_adas_status(cp, is_kaofui_car=True)
|
||||
|
||||
|
||||
def test_radar_status_is_suppressed_when_radar_is_unavailable():
|
||||
cp = SimpleNamespace(
|
||||
carFingerprint=CAR.BUICK_LACROSSE_ASCM,
|
||||
networkLocation=CarParams.NetworkLocation.fwdCamera,
|
||||
radarUnavailable=True,
|
||||
)
|
||||
|
||||
assert not should_send_adas_status(cp, is_kaofui_car=True)
|
||||
|
||||
|
||||
def test_volt_auto_hold_requires_toggle_supported_non_cc_only_volt_and_stock_safety():
|
||||
stock_safety = [SimpleNamespace(safetyParam=0x8000)]
|
||||
no_safety = [SimpleNamespace(safetyParam=0)]
|
||||
|
||||
Reference in New Issue
Block a user