mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 02:53:41 +08:00
Toyota radar-ACC cars: stockFcw from the ARS510's PCS alarm
As in commaai/opendbc#3860. The radar also reports its PCS alarm on its own bus (PCS_STATE, 0x100), which keeps running when alpha long disables the radar's car-bus output (and with it 0x411). The parser does not require the message, so a quiet radar bus cannot make CAN invalid or time out; the power-up frame (all bits set) is ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -212,6 +212,11 @@ class CarState(CarStateBase):
|
||||
self.acc_type = cp_acc.vl["ACC_CONTROL"]["ACC_TYPE"]
|
||||
ret.stockFcw = bool(cp_acc.vl["PCS_HUD"]["FCW"])
|
||||
|
||||
# ARS510 radar-ACC cars: the radar also reports its PCS alarm on its own bus, which keeps running when openpilot disables the radar
|
||||
if Bus.radar in can_parsers and self.CP.flags & ToyotaFlags.ARS510_RADAR:
|
||||
pcs = can_parsers[Bus.radar].vl["PCS_STATE"]
|
||||
ret.stockFcw = ret.stockFcw or bool(pcs["PCS_ALARM"] and pcs["POWER_UP"] == 0)
|
||||
|
||||
# some TSS2 cars have low speed lockout permanently set, so ignore on those cars
|
||||
# these cars are identified by an ACC_TYPE value of 2.
|
||||
# TODO: it is possible to avoid the lockout and gain stop and go if you
|
||||
@@ -413,8 +418,12 @@ class CarState(CarStateBase):
|
||||
if enhanced_bsm.configured(CP):
|
||||
pt_parser = enhanced_bsm.BsmCANParser
|
||||
pt_messages.append(("BSM", math.nan))
|
||||
return {
|
||||
parsers = {
|
||||
Bus.pt: pt_parser(DBC[CP.carFingerprint][Bus.pt], pt_messages, 0, **({"stock_word": CP.safetyConfigs[0].safetyParam} if stock else
|
||||
{"alternate_main": alternate_sdsu_main} if legacy_advert else {})),
|
||||
Bus.cam: CANParser(dbc_name, cam_messages, 2),
|
||||
}
|
||||
if CP.flags & ToyotaFlags.ARS510_RADAR:
|
||||
# not required (nan), so a quiet radar bus never makes CAN invalid
|
||||
parsers[Bus.radar] = CANParser("toyota_tss2_ars510", [("PCS_STATE", math.nan)], 1)
|
||||
return parsers
|
||||
|
||||
@@ -97,3 +97,20 @@ def test_rav4_startup_wait_does_not_stall_live_tracks():
|
||||
outputs = [radar.update([(1_000_000_000 + i * 10_000_000, [])]) for i in range(700)]
|
||||
assert sum(r is not None for r in outputs) == 140
|
||||
assert all(not r.points and not r.errors.radarUnavailableTemporary for r in outputs if r is not None)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('candidate', sorted(ARS510_RADAR_CAR))
|
||||
def test_pcs_alarm_sets_stock_fcw_on_ars510_cars(candidate):
|
||||
from opendbc.can import CANParser
|
||||
from opendbc.car import Bus
|
||||
from opendbc.car.toyota.carstate import CarState
|
||||
cp = CarInterface.get_params(candidate, gen_empty_fingerprint(), [], True, False, False)
|
||||
radar = CarState.get_can_parsers(cp)[Bus.radar]
|
||||
assert isinstance(radar, CANParser) and radar.bus == 1
|
||||
packer = CANPacker(RADAR_DBC)
|
||||
seen = []
|
||||
for i, values in enumerate(({"PCS_ALARM": 1, "POWER_UP": 255}, {"PCS_ALARM": 0}, {"PCS_ALARM": 1})):
|
||||
radar.update([(1_000_000_000 + i * 100_000_000, [packer.make_can_msg("PCS_STATE", 1, values)])])
|
||||
pcs = radar.vl["PCS_STATE"]
|
||||
seen.append(bool(pcs["PCS_ALARM"] and pcs["POWER_UP"] == 0))
|
||||
assert seen == [False, False, True] and radar.can_valid and not radar.bus_timeout
|
||||
|
||||
Reference in New Issue
Block a user