RAV4 radar: keep the ACC target receiver under alpha long's radar disable

This commit is contained in:
ds-sebastian
2026-11-25 22:09:06 -06:00
committed by firestar5683
15 changed files with 149 additions and 421 deletions
+1 -1
View File
@@ -24,7 +24,7 @@ The radar interface preserves that attribution while adapting to the current int
## RAV4 Continental ARS510 receiver
The optional ACC-target and fused-track receivers and DBC preserve firestar5683's Dom integration from `b220a37f4bd119e402225a7aa16a7cd84878d0af` (Sea Turtles, 2026-10-13) and its ARS510 source attribution to ds-sebastian/ars510-radar `fb5b29c2b5999f34afeb6f7ac494a73949d66c67`, copyright 2026 ARS510 radar contributors. The complete MIT permission and warranty notice is retained in THIRD_PARTY_NOTICES.md. Startup/settings ownership is adapted to the current StarPilot architecture; no original firmware binaries or safety permissions are copied.
The ACC-target receiver and DBC preserve firestar5683's Dom integration from `b220a37f4bd119e402225a7aa16a7cd84878d0af` (Sea Turtles, 2026-10-13) and its ARS510 source attribution to ds-sebastian/ars510-radar `fb5b29c2b5999f34afeb6f7ac494a73949d66c67`, copyright 2026 ARS510 radar contributors. The DBC is the one in commaai/opendbc#3860 (ds-sebastian/opendbc `ddcc0b07d1759c96a1d208ae1db13ad91ce23435`). The complete MIT permission and warranty notice is retained in THIRD_PARTY_NOTICES.md. Startup/settings ownership is adapted to the current StarPilot architecture; no original firmware binaries or safety permissions are copied.
## Spotify Bluetooth output
+3 -2
View File
@@ -92,9 +92,10 @@ The Ford CAN FD camera-radar filtering includes work adapted from BluePilot's `b
## Continental ARS510 radar
The optional RAV4 radar decoders and `toyota_tss2_ars510.dbc` are adapted from
The RAV4 ACC-target radar receiver is adapted from
<https://github.com/ds-sebastian/ars510-radar> at
`fb5b29c2b5999f34afeb6f7ac494a73949d66c67`.
`fb5b29c2b5999f34afeb6f7ac494a73949d66c67`. `toyota_tss2_ars510.dbc` is the DBC
of commaai/opendbc#3860 (ds-sebastian/opendbc `ddcc0b07d1759c96a1d208ae1db13ad91ce23435`).
MIT License
@@ -14,11 +14,10 @@ def configured(cp):
required |= ToyotaFlags.RADAR_CAN_FILTER
elif cp.openpilotLongitudinalControl:
required |= ToyotaFlags.DISABLE_RADAR
allowed = required | ToyotaFlags.HYBRID | ToyotaFlags.HAS_BSM | ToyotaFlags.ARS510_RADAR | ToyotaFlags.ARS510_FUSED
allowed = required | ToyotaFlags.HYBRID | ToyotaFlags.HAS_BSM | ToyotaFlags.ARS510_RADAR
expected = 0x449 | (0x1000 if filtered else 0) | (0 if cp.openpilotLongitudinalControl else 0x200)
config = cp.safetyConfigs[0]
return bool(cp.flags & required == required and not int(cp.flags) & ~int(allowed) and
(not cp.flags & ToyotaFlags.ARS510_FUSED or cp.flags & ToyotaFlags.ARS510_RADAR) and
config.safetyModel == structs.CarParams.SafetyModel.toyota and config.safetyParam == expected)
@@ -19,10 +19,9 @@ def supported(cp):
def configure_radar(cp):
if not supported(cp):
return False
cp.flags &= ~int(ToyotaFlags.ARS510_RADAR | ToyotaFlags.ARS510_FUSED)
if cp.flags & ToyotaFlags.DISABLE_RADAR:
cp.radarUnavailable = True
return False
cp.flags &= ~int(ToyotaFlags.ARS510_RADAR)
# Alpha long's UDS disable (DISABLE_RADAR) only stops the radar's car-bus (bus 0) output;
# the ACC target on the radar bus (bus 1) keeps running at full rate, so it stays the lead source.
cp.flags |= int(ToyotaFlags.ARS510_RADAR)
cp.radarUnavailable = False
return True
@@ -1,246 +0,0 @@
"""Toyota / Continental ARS510 front radar (RAV4 2022+, fwdRadar 8821F0R03100): object list to RadarData.
The radar sends its object list on bus 1 as one 742-byte record split over 106 frames on 0x80 (consecutive-frame
numbers wrap every 16 frames, so it is reassembled here instead of read through a DBC). Each of its 20 slots holds one
object; the radar keeps an object in its slot while the slot's age counts up, which gives the track IDs.
The slot speed has slow, correlated errors at range (false closings of 1-10 s beyond ~40 m). Their size follows the
radar's 240|7 code. One Kalman filter per track fuses the slot speed, weighted by that code, with the radar's own ACC target
(0x235 / 0x237) for the track it describes. radard then filters as for any radar. radard's lead match weights
lateral position only through the camera's uncertainty, so beyond 15 m a track a lane away from the yaw-predicted path
is withheld.
Adapted from ds-sebastian/ars510-radar at fb5b29c2b5999f34afeb6f7ac494a73949d66c67.
Copyright (c) 2026 ARS510 radar contributors. MIT license; see THIRD_PARTY_NOTICES.md.
"""
import zlib
from math import isfinite, nan, pi
from opendbc.car import structs
from opendbc.car.interfaces import RadarInterfaceBase
RADAR_BUS, CAR_BUS = 1, 0
SPEED_ADDR, YAW_ADDR, OBJECTS_ADDR, ACC_SPEED_ADDR, ACC_POS_ADDR = 0xB4, 0x24, 0x80, 0x235, 0x237
RECORD_FRAMES, RECORD_LEN, SLOT_START, SLOT_LEN, SLOTS = 106, 742, 17, 36, 20
IDLE_SLOT = bytes.fromhex("FCE00000A0F07F00FFFDF71FFFA100F807000F0008000000000000000000000000000000")
EGO_MAX_AGE_S = 0.5
PUBLISH_AGE = 60 # ~3.6 s: young tracks have unconverged range and speed
RANGE_GAIN = 0.1 # velocity-aided range: cuts 1.5 s range walks by about a third
# Kalman speed filter (one state: the lead's over-ground speed)
SIGMA_PER_CODE = 0.045 # m/s per 240|7 count, against the radar's ACC target
YOUNG_SCALE, YOUNG_AGE = 1.8, 100 # young tracks err more than 240|7 says
ACC_SIGMA = 0.13 # m/s, the radar's ACC target speed (its measured noise; blended with the object list, which damps the ACC target's rare slides)
LEAD_ACCEL = 1.5 # m/s^2, process noise
GATE_SIGMA = 3.0 # innovations beyond 3 sigma count as 3 sigma
PUBLISH_STD = 0.75 # m/s: a new track is published once its speed is this certain
PATH_GATE, PATH_GATE_MIN_RANGE = 2.5, 15.0 # m: off the yaw-predicted path by more than this = another lane; closer in, cut-ins stay
FAR_ACC_ONLY = 60.0 # m: beyond this only the car the radar's ACC follows is published, as Toyota's own ACC uses it
STILL, STILL_GATE = 0.5, 1.5 # m/s, m: a stationary track (parked car, roadside object) is path-gated at every range, so it stays out of the lane
def bits(b: bytes, start: int, length: int) -> int:
return (int.from_bytes(b, "little") >> start) & ((1 << length) - 1)
def be_bits(b: bytes, start: int, length: int) -> int:
return (int.from_bytes(b, "big") >> start) & ((1 << length) - 1)
class Ars510Radar:
"""Raw CAN frames in, points (trackId, dRel, yRel, vRel) out once per 0x80 record."""
def __init__(self):
self.chunks, self.record_t, self.last_frame_t = [], 0.0, None
self.v_ego = self.yaw = None # (time, m/s), (time, rad/s left positive)
self.slots = {} # slot -> (radar track id, age, time)
self.next_tid = 1
self.acc_speed = self.acc_pos = self.acc_assoc = None
self.kf = {} # tid -> (time, speed, variance)
self.rng = {} # tid -> (time, dRel, vRel)
self.published = set()
def update(self, t: float, bus: int, addr: int, dat: bytes):
if bus == CAR_BUS and addr == SPEED_ADDR and len(dat) >= 7:
self.v_ego = (t, int.from_bytes(dat[5:7], "big") * 0.01 / 3.6)
elif bus == CAR_BUS and addr == YAW_ADDR and len(dat) >= 2:
self.yaw = (t, (((dat[0] & 0x03) << 8 | dat[1]) * 0.244 - 125.0) * pi / 180.0)
elif bus == RADAR_BUS and addr in (ACC_SPEED_ADDR, ACC_POS_ADDR):
if len(dat) != 8 or (not dat[1] & 4 if addr == ACC_SPEED_ADDR else dat[2:] == bytes.fromhex("003E80000000")):
self.acc_speed = self.acc_pos = None # idle
elif addr == ACC_SPEED_ADDR:
self.acc_speed = (t, (be_bits(dat, 29, 11) - 1024) * 0.125)
else:
self.acc_pos = (t, be_bits(dat, 39, 13) * 0.025, (be_bits(dat, 27, 12) - 2000) * 0.01)
elif bus == RADAR_BUS and addr == OBJECTS_ADDR:
record = self.reassemble(t, dat)
if record is not None and int.from_bytes(record[737:741], "little") == zlib.crc32(record[1:737]):
return self.points(self.record_t, record)
return None
def reassemble(self, t, dat):
"""The 106 frames of one record joined (bytes 1-7 of each); restarts on a first frame (0x12 0xE4)."""
if len(dat) != 8 or (self.chunks and t < self.last_frame_t):
self.chunks = []
if len(dat) != 8:
return None
if dat[0] == 0x12 and dat[1] == 0xE4:
self.chunks, self.record_t = [bytes(dat[1:8])], t
elif self.chunks:
self.chunks.append(bytes(dat[1:8]))
else:
return None
self.last_frame_t = t
if len(self.chunks) != RECORD_FRAMES:
return None
record, self.chunks = b"".join(self.chunks), []
return record if len(record) == RECORD_LEN else None
def track_id(self, t, slot, age):
prev = self.slots.get(slot)
if prev is not None and t == prev[2]:
return prev[0]
if prev is None or t - prev[2] > 0.3 or not (age > prev[1] or age == prev[1] == 126):
prev = (self.next_tid, age, t)
self.next_tid += 1
self.slots[slot] = (prev[0], age, t)
return prev[0]
def points(self, t, record):
v_ego = self.v_ego[1] if self.v_ego is not None and abs(t - self.v_ego[0]) <= EGO_MAX_AGE_S else None
objs = []
for slot in range(SLOTS):
s = record[SLOT_START + SLOT_LEN * slot : SLOT_START + SLOT_LEN * (slot + 1)]
if s == IDLE_SLOT:
continue
age, lat = bits(s, 24, 7), bits(s, 44, 12) - 2048
init_template = age == 1 and bits(s, 56, 7) == 0 and bits(s, 216, 6) == 0
# over-ground speed: 0.149 m/s per code against 0xB4 ego speed (DBC factor 0.15)
objs.append(
dict(
tid=self.track_id(t, slot, age),
age=age,
d=(bits(s, 32, 12) - 160) / 16,
y=lat * 0.015,
vg=(bits(s, 64, 10) - 510.5) * 0.149,
unc=bits(s, 240, 7),
valid=age >= 1 and not init_template and abs(lat) < 2000,
)
)
tracks = {o["tid"]: o for o in objs if o["valid"]}
acc_tid = self.acc_match(t, tracks)
yaw = self.yaw[1] if self.yaw is not None and abs(t - self.yaw[0]) <= EGO_MAX_AGE_S else None
out = []
for o in objs:
if not o["valid"]:
continue
tid, vrel, std = o["tid"], nan, 0.0
if v_ego is not None:
readings = [(self.acc_speed[1] + v_ego, ACC_SIGMA)] if tid == acc_tid else []
speed, std = self.speed_filter(tid, t, o, readings)
vrel = speed - v_ego
d_rel = self.fused_range(tid, t, self.acc_pos[1] if tid == acc_tid else o["d"], vrel) # ACC distance for its track
if o["age"] < PUBLISH_AGE or (tid not in self.published and std > PUBLISH_STD) or not isfinite(vrel):
continue # a point needs a fresh ego speed: one NaN would poison radard's filter
still = abs(speed) < STILL and d_rel <= PATH_GATE_MIN_RANGE
if tid != acc_tid and (
d_rel > FAR_ACC_ONLY
or (
yaw is not None
and (d_rel > PATH_GATE_MIN_RANGE or still)
and abs(o["y"] - yaw / max(v_ego, 2.0 if still else 5.0) * d_rel * d_rel / 2) > (STILL_GATE if still else PATH_GATE)
)
):
continue # far: only the car the radar's ACC follows is published (the camera covers the rest); closer in: an object off the path is another lane's
self.published.add(tid)
out.append((tid, d_rel, o["y"], vrel))
self.prune(t)
return out
def speed_filter(self, tid, t, o, readings):
"""One-state Kalman filter on the over-ground speed; every reading weighted by its own sigma."""
sig = SIGMA_PER_CODE * max(o["unc"], 1)
if o["age"] < YOUNG_AGE:
sig *= 1.0 + (YOUNG_SCALE - 1.0) * min(max((YOUNG_AGE - o["age"]) / (YOUNG_AGE - PUBLISH_AGE), 0.0), 1.0)
prev = self.kf.get(tid)
if prev is None or not 0.0 < t - prev[0] <= 0.5:
self.kf[tid] = (t, o["vg"], sig * sig)
return o["vg"], sig
_, v, p = prev
p += (LEAD_ACCEL * (t - prev[0])) ** 2
for z, r in [(o["vg"], sig)] + readings:
s = p + r * r
innov = max(min(z - v, GATE_SIGMA * s**0.5), -GATE_SIGMA * s**0.5)
v, p = v + p / s * innov, p * (1.0 - p / s)
self.kf[tid] = (t, v, p)
return v, p**0.5
def fused_range(self, tid, t, d, vrel):
prev = self.rng.get(tid)
if prev is not None and isfinite(vrel) and isfinite(prev[2]) and 0.0 < t - prev[0] <= 0.5:
pred = prev[1] + 0.5 * (prev[2] + vrel) * (t - prev[0])
d = pred + RANGE_GAIN * (d - pred)
self.rng[tid] = (t, d, vrel)
return d
def acc_match(self, t, tracks):
"""The track the radar's ACC target describes: matched by position, kept while both persist."""
if self.acc_speed is None or self.acc_pos is None or max(abs(t - self.acc_speed[0]), abs(t - self.acc_pos[0])) > 0.1:
self.acc_assoc = None
return None
_, ax, ay = self.acc_pos
rs = max(12.0, 0.4 * ax) # the object list reads far cars short of the ACC distance; 10-20 % of new tracks by more than 10 m
costs = sorted((abs(o["d"] - ax) / rs + abs(o["y"] - ay) / 0.5, tid, o["age"]) for tid, o in tracks.items())
if self.acc_assoc is not None:
tid0, ax0, ay0 = self.acc_assoc
own = next((c for c, tid, _ in costs if tid == tid0), None)
if own is not None and own < 4.0 and abs(ax - ax0) <= 8.0 and abs(ay - ay0) <= 1.0:
self.acc_assoc = (tid0, ax, ay)
return tid0
self.acc_assoc = None
if not costs or costs[0][0] >= 1.0 or costs[0][2] < 20 or (len(costs) > 1 and costs[1][0] - costs[0][0] <= 1.0):
return None
self.acc_assoc = (costs[0][1], ax, ay)
return costs[0][1]
def prune(self, t):
for store in (self.kf, self.rng):
if len(store) > 400:
for k in [k for k, v in store.items() if v[0] < t - 5.0]:
store.pop(k)
if len(self.published) > 400:
# A live allocation can outlast its recent speed-filter entry after invalid geometry.
self.published &= set(self.kf) | {state[0] for state in self.slots.values()}
class RadarInterface(RadarInterfaceBase):
def __init__(self, CP):
super().__init__(CP)
self.radar = Ars510Radar()
self.last_record_t = None
def update(self, can_packets):
self.frame += 1
points, t = None, None
for nanos, frames in can_packets:
t = nanos * 1e-9
for address, dat, src in frames:
out = self.radar.update(t, src, address, dat)
if out is not None:
points, self.last_record_t = out, t
if points is None: # between scans: report only at 20 Hz, and only before the first scan or once the radar is stale
if t is None or self.frame % 5 != 0 or (self.last_record_t is not None and t - self.last_record_t <= 0.5):
return None
ret = structs.RadarData()
ret.errors.radarUnavailableTemporary = self.last_record_t is not None
return ret
ret = structs.RadarData()
pts = []
for track_id, d_rel, y_rel, v_rel in points:
pt = structs.RadarData.RadarPoint()
pt.trackId, pt.dRel, pt.yRel, pt.vRel = track_id, d_rel, y_rel, v_rel
pt.deprecated.aRel = pt.deprecated.yvRel = nan
pt.deprecated.measured = True
pts.append(pt)
ret.points = pts
return ret
+1 -2
View File
@@ -90,12 +90,11 @@ def configured(cp):
required |= int(ToyotaFlags.RAISED_ACCEL_LIMIT)
allowed = required | int(ToyotaFlags.HYBRID | ToyotaFlags.HAS_BSM)
if cp.carFingerprint in (CAR.TOYOTA_RAV4_TSS2_2022, CAR.TOYOTA_RAV4_TSS2_2023):
allowed |= int(ToyotaFlags.ARS510_RADAR | ToyotaFlags.ARS510_FUSED)
allowed |= int(ToyotaFlags.ARS510_RADAR)
expected_type = structs.CarParams.SteerControlType.angle if cp.carFingerprint == CAR.TOYOTA_RAV4_TSS2_2023 else structs.CarParams.SteerControlType.torque
return bool(
cp.flags & required == required
and not int(cp.flags) & ~allowed
and (not cp.flags & ToyotaFlags.ARS510_FUSED or cp.flags & ToyotaFlags.ARS510_RADAR)
and cp.steerControlType == expected_type
and cp.safetyConfigs[0].safetyModel == structs.CarParams.SafetyModel.toyota
and cp.safetyConfigs[0].safetyParam == words(cp.carFingerprint)[not cp.openpilotLongitudinalControl]
+1 -3
View File
@@ -85,9 +85,7 @@ def configured(cp):
required |= ToyotaFlags.ANGLE_CONTROL
allowed |= ToyotaFlags.ANGLE_CONTROL
if cp.carFingerprint in (CAR.TOYOTA_RAV4_TSS2_2022, CAR.TOYOTA_RAV4_TSS2_2023):
allowed |= ToyotaFlags.ARS510_RADAR | ToyotaFlags.ARS510_FUSED
if cp.flags & ToyotaFlags.ARS510_FUSED and not cp.flags & ToyotaFlags.ARS510_RADAR:
return False
allowed |= ToyotaFlags.ARS510_RADAR
expected_steer = structs.CarParams.SteerControlType.angle if angle else structs.CarParams.SteerControlType.torque
if cp.steerControlType != expected_steer:
return False
@@ -4,7 +4,6 @@ from opendbc.car import Bus
from opendbc.car.structs import RadarData
from opendbc.car.toyota.values import CAR, DBC, ToyotaFlags, ARS510_RADAR_CAR
from opendbc.car.toyota.ars510_acc_target import RadarInterface as Ars510AccRadarInterface
from opendbc.car.toyota.ars510_radar import RadarInterface as Ars510FusedRadarInterface
from opendbc.car.interfaces import RadarInterfaceBase
@@ -36,8 +35,7 @@ class RadarInterface(RadarInterfaceBase):
return
self.ars510 = None
if CP.carFingerprint in ARS510_RADAR_CAR and CP.flags & ToyotaFlags.ARS510_RADAR and not CP.radarUnavailable:
parser = Ars510FusedRadarInterface if CP.flags & ToyotaFlags.ARS510_FUSED else Ars510AccRadarInterface
self.ars510 = parser(CP)
self.ars510 = Ars510AccRadarInterface(CP)
self.rcp = None
return
if CP.flags & ToyotaFlags.TSS2:
@@ -1,12 +1,10 @@
from math import isfinite, isnan
import zlib
import pytest
from opendbc.can import CANPacker
from opendbc.car import gen_empty_fingerprint, structs
from opendbc.car.toyota.ars510_acc_target import RadarInterface as AccRadarInterface, RADAR_DBC
from opendbc.car.toyota.ars510_radar import Ars510Radar, IDLE_SLOT, RadarInterface as FusedRadarInterface
from opendbc.car.toyota.interface import CarInterface
from opendbc.car.toyota.radar_interface import RadarInterface
from opendbc.car.toyota.values import ARS510_RADAR_CAR, CAR, ToyotaFlags
@@ -19,137 +17,13 @@ def test_factory_selects_only_live_supported_continental_radar(candidate, alpha_
if can_filter:
fingerprint[0][0x2AA] = 8
cp = CarInterface.get_params(candidate, fingerprint, [], alpha_long, False, False)
if candidate in ARS510_RADAR_CAR and not cp.flags & ToyotaFlags.DISABLE_RADAR:
if candidate in ARS510_RADAR_CAR:
# with or without alpha long's radar disable: the disable leaves the radar bus running
assert cp.flags & ToyotaFlags.ARS510_RADAR, 'AUTOMATIC_CONTINENTAL_RADAR'
assert not cp.flags & ToyotaFlags.ARS510_FUSED and not cp.radarUnavailable
assert not cp.radarUnavailable
assert isinstance(RadarInterface(cp).ars510, AccRadarInterface)
else:
assert not cp.flags & (ToyotaFlags.ARS510_RADAR | ToyotaFlags.ARS510_FUSED)
if candidate in ARS510_RADAR_CAR:
assert cp.radarUnavailable and RadarInterface(cp).ars510 is None
def set_bits(data, start, length, value):
raw = int.from_bytes(data, "little")
mask = ((1 << length) - 1) << start
data[:] = ((raw & ~mask) | (value << start)).to_bytes(len(data), "little")
def object_record(age=60, distance=30, lateral=0, speed_code=645, uncertainty=1, count=1):
record = bytearray(742)
record[0] = 0xE4
for slot in range(20):
data = bytearray(IDLE_SLOT)
if slot < count:
set_bits(data, 24, 7, age)
set_bits(data, 32, 12, round(160 + 16 * distance))
set_bits(data, 44, 12, round(2048 + lateral / 0.015))
set_bits(data, 64, 10, speed_code)
set_bits(data, 240, 7, uncertainty)
record[17 + slot * 36 : 17 + (slot + 1) * 36] = data
record[737:741] = zlib.crc32(record[1:737]).to_bytes(4, "little")
return bytes(record)
def record_frames(record, bus=1):
return [(0x80, bytes([0x12 if i == 0 else 0x20 | i % 16]) + record[i * 7 : (i + 1) * 7], bus) for i in range(106)]
def ego_frames(speed=20, yaw_code=512):
speed_data = bytearray(8)
speed_data[5:7] = round(speed * 3.6 * 100).to_bytes(2, "big")
yaw_data = bytes([yaw_code >> 8, yaw_code & 0xFF]) + bytes(6)
return [(0xB4, bytes(speed_data), 0), (0x24, yaw_data, 0)]
def fused_radar():
return FusedRadarInterface(structs.CarParams(carFingerprint=CAR.TOYOTA_RAV4_TSS2_2023))
def test_fused_decodes_20_slots_and_preserves_left_positive_geometry():
radar = fused_radar()
ret = radar.update([(1_000_000_000, ego_frames() + record_frames(object_record(count=20, lateral=0.3)))])
assert len(ret.points) == 20
assert len({pt.trackId for pt in ret.points}) == 20
for pt in ret.points:
assert (pt.dRel, pt.yRel, pt.vRel) == pytest.approx((30, 0.3, (645 - 510.5) * 0.149 - 20))
assert pt.deprecated.measured
assert isnan(pt.deprecated.aRel) and isnan(pt.deprecated.yvRel)
assert not ret.errors.canError
@pytest.mark.parametrize("bad_input", ["crc", "short", "truncated", "reordered", "wrong_bus"])
def test_fused_rejects_incomplete_corrupt_or_non_native_records(bad_input):
radar = fused_radar()
record = bytearray(object_record())
if bad_input == "crc":
record[25] ^= 1
frames = record_frames(record, bus=2 if bad_input == "wrong_bus" else 1)
if bad_input == "short":
frames[50] = (0x80, frames[50][1][:-1], 1)
elif bad_input == "truncated":
frames.pop(50)
elif bad_input == "reordered":
frames[30], frames[31] = frames[31], frames[30]
assert radar.update([(1_000_000_000, ego_frames() + frames)]) is None
assert radar.last_record_t is None
def test_fused_requires_fresh_ego_speed_and_converged_tracks():
radar = Ars510Radar()
assert radar.points(1.0, object_record()) == []
radar.v_ego = (1.0, 20)
assert radar.points(1.0, object_record(age=59)) == []
assert radar.points(1.1, object_record(age=60))
assert radar.points(1.6, object_record(age=61)) == []
def test_fused_lifecycle_age_reset_allocates_a_new_track():
radar = Ars510Radar()
radar.v_ego = (1.0, 20)
first = radar.points(1.0, object_record(age=60))[0][0]
assert radar.points(1.06, object_record(age=61))[0][0] == first
radar.points(1.12, object_record(age=1))
radar.v_ego = (1.18, 20)
assert radar.points(1.18, object_record(age=60))[0][0] != first
saturated = radar.track_id(2.0, 0, 126)
assert radar.track_id(2.06, 0, 126) == saturated
@pytest.mark.parametrize("kwargs", [{"uncertainty": 127}, {"distance": 61}, {"lateral": 3}])
def test_fused_gates_uncertain_far_and_out_of_path_objects(kwargs):
radar = Ars510Radar()
radar.v_ego = (1.0, 20)
radar.yaw = (1.0, 0)
assert radar.points(1.0, object_record(**kwargs)) == []
def test_fused_damps_a_high_uncertainty_speed_excursion():
radar = Ars510Radar()
radar.v_ego = (1.0, 20)
first = radar.points(1.0, object_record(age=126))[0]
raw_closing = (600 - 510.5) * 0.149 - 20
second = radar.points(1.06, object_record(age=126, speed_code=600, uncertainty=127))[0]
assert raw_closing < -6
assert second[0] == first[0]
assert abs(second[3] - first[3]) < 0.2
def test_fused_keeps_healthy_tracks_between_scans_then_reports_actual_silence(monkeypatch):
radar = fused_radar()
monkeypatch.setattr(radar.radar, "update", lambda t, *_: [(1, 30, 0, -1)] if round(t * 100) % 6 == 0 else None)
for i in range(1, 101):
ret = radar.update([(i * 10_000_000, [(0x80, bytes(8), 1)])])
if i % 6 == 0:
assert len(ret.points) == 1
elif i > 6:
assert ret is None
monkeypatch.setattr(radar.radar, "update", lambda *_: None)
outputs = [radar.update([(2_000_000_000 + i * 10_000_000, [])]) for i in range(10)]
assert any(r is not None and r.errors.radarUnavailableTemporary and not r.points for r in outputs)
monkeypatch.setattr(radar.radar, "update", lambda *_: [])
ret = radar.update([(2_200_000_000, [(0x80, bytes(8), 1)])])
assert not ret.points and not ret.errors.radarUnavailableTemporary
assert not cp.flags & ToyotaFlags.ARS510_RADAR
def acc_frames(packer, counter, cycle, present=True, distance=35, relative_speed=-2, target_id=3):
@@ -69,7 +69,6 @@ class ToyotaFlags(IntFlag):
HAS_BSM = 2 # blind spot monitoring
LONG_FILTER = 8192
ARS510_RADAR = 16384
ARS510_FUSED = 32768
DISABLE_RADAR = 4
# Static flags
+117 -11
View File
@@ -34,6 +34,56 @@ NS_ :
BS_:
BU_: XXX
BO_ 256 PCS_STATE: 7 XXX
SG_ PCS_ALARM : 1|1@0+ (1,0) [0|1] "" XXX
SG_ POWER_UP : 15|8@0+ (1,0) [0|255] "" XXX
BO_ 400 RADAR_CYCLE: 7 XXX
SG_ SUMMARY_COUNT : 3|2@0+ (1,0) [0|3] "" XXX
SG_ TIMESTAMP : 23|32@0+ (1,0) [0|4294967295] "us" XXX
SG_ CYCLE_COUNTER : 52|4@1+ (1,0) [0|15] "" XXX
BO_ 401 TARGET_SUMMARY_A_INFO: 8 XXX
SG_ SCORE : 1|7@1+ (1,0) [0|127] "" XXX
SG_ AGE : 9|7@1+ (1,0) [0|127] "" XXX
SG_ TRACK_CODE : 26|6@1+ (1,0) [0|63] "" XXX
SG_ WIDTH : 34|6@1+ (0.1,0) [0|6.3] "m" XXX
SG_ AGE_COUNTER : 43|5@1+ (1,0) [0|31] "" XXX
SG_ HEIGHT : 49|7@1+ (0.1,0) [0|12.7] "m" XXX
SG_ LENGTH : 56|8@1+ (0.1,0) [0|25.5] "m" XXX
BO_ 402 TARGET_SUMMARY_A_POS: 4 XXX
SG_ LONG_DIST : 4|13@0+ (0.0625,-10) [-10|501.9375] "m" XXX
SG_ LAT_DIST : 20|13@0+ (0.015,-30.72) [-30.72|92.145] "m" XXX
BO_ 403 TARGET_SUMMARY_B_INFO: 8 XXX
SG_ SCORE : 1|7@1+ (1,0) [0|127] "" XXX
SG_ AGE : 9|7@1+ (1,0) [0|127] "" XXX
SG_ TRACK_CODE : 26|6@1+ (1,0) [0|63] "" XXX
SG_ WIDTH : 34|6@1+ (0.1,0) [0|6.3] "m" XXX
SG_ AGE_COUNTER : 43|5@1+ (1,0) [0|31] "" XXX
SG_ HEIGHT : 49|7@1+ (0.1,0) [0|12.7] "m" XXX
SG_ LENGTH : 56|8@1+ (0.1,0) [0|25.5] "m" XXX
BO_ 404 TARGET_SUMMARY_B_POS: 4 XXX
SG_ LONG_DIST : 4|13@0+ (0.0625,-10) [-10|501.9375] "m" XXX
SG_ LAT_DIST : 20|13@0+ (0.015,-30.72) [-30.72|92.145] "m" XXX
BO_ 405 EVENT_OBJECT: 8 XXX
SG_ PATH_CURVATURE : 7|16@0+ (7.5e-06,-0.24576) [-0.24576|0.2457525] "1/m" XXX
SG_ OBJECT_ACCEL : 23|12@0+ (0.03125,-16) [-16|111.96875] "m/s^2" XXX
SG_ OBJECT_SPEED : 27|12@0+ (0.0625,0) [0|255.9375] "m/s" XXX
SG_ EGO_TRAVEL_TO_TTC : 46|11@0+ (0.05,0) [0|102.35] "m" XXX
SG_ OBJECT_DIST : 50|11@0+ (0.05,0) [0|102.35] "m" XXX
BO_ 406 EVENT_STATE: 8 XXX
SG_ REQUIRED_DECEL : 7|8@0- (0.095,0) [-12.16|12.065] "m/s^2" XXX
SG_ RADAR_FAULT : 8|1@0+ (1,0) [0|1] "" XXX
BO_ 514 RADAR_ALIVE: 5 XXX
SG_ CHECK_BYTE : 7|8@0+ (1,0) [0|255] "" XXX
SG_ COUNTER : 15|4@0+ (1,0) [0|15] "" XXX
BO_ 565 ACC_TARGET_1: 8 XXX
SG_ CHECK_BYTE : 7|8@0+ (1,0) [0|255] "" XXX
SG_ COUNTER : 15|4@0+ (1,0) [0|15] "" XXX
@@ -42,7 +92,7 @@ BO_ 565 ACC_TARGET_1: 8 XXX
SG_ REL_SPEED : 31|11@0+ (0.125,-128) [-128|127.875] "m/s" XXX
SG_ LAT_ACCEL : 34|8@0+ (0.125,-12.5) [-12.5|19.375] "m/s^2" XXX
SG_ LAT_SPEED : 42|11@0+ (0.0125,-12.8) [-12.8|12.7875] "m/s" XXX
SG_ TARGET_ID : 60|5@0+ (1,0) [0|31] "" XXX
SG_ TARGET_ID : 61|6@0+ (1,0) [0|63] "" XXX
BO_ 567 ACC_TARGET_2: 8 XXX
SG_ CHECK_BYTE : 7|8@0+ (1,0) [0|255] "" XXX
@@ -70,19 +120,66 @@ BO_ 571 ACC_TARGET_4: 3 XXX
SG_ COUNTER : 15|4@0+ (1,0) [0|15] "" XXX
SG_ WIDTH : 11|12@0+ (1,0) [0|4095] "cm" XXX
CM_ "Continental ARS510 front radar, radar bus: the target the radar's own ACC follows. Used on the radar-ACC platforms: RAV4 2022-25 (fwdRadar 8821F0R01100, 8821F0R03100), C-HR 2021-22 (8821FF4102xx-0500) and Yaris (8821F0D0xxxx). The 0x80 object list and 0x85 metadata record span many frames and are decoded by ars510-radar (ars510/). The radar interface uses STATE, REL_SPEED, TARGET_ID, LONG_DIST, LAT_DIST, PRESENT and TIMESTAMP; the other signals are documented for completeness.";
BO_ 591 RADAR_BOOT: 1 XXX
SG_ RADAR_RUNNING : 6|1@0+ (1,0) [0|1] "" XXX
BO_ 1664 OBJECT_STREAM: 8 XXX
SG_ SELECTOR : 7|8@0+ (1,0) [0|255] "" XXX
SG_ LONG_DIST : 15|13@0+ (0.03125,0) [0|255.96875] "m" XXX
SG_ LAT_DIST : 18|11@0- (0.015,0) [-15.36|15.345] "m" XXX
SG_ SPEED : 39|10@0+ (0.15,-76.8) [-76.8|76.65] "m/s" XXX
SG_ STATIONARY : 40|1@0+ (1,0) [0|1] "" XXX
SG_ ONCOMING : 41|1@0+ (1,0) [0|1] "" XXX
SG_ SEEN_MOVING : 43|1@0+ (1,0) [0|1] "" XXX
SG_ LAT_SPEED : 55|8@0+ (0.15,-19.2) [-19.2|19.05] "m/s" XXX
CM_ "Continental ARS510 front radar, radar bus. Used on the radar-ACC platforms: RAV4 2022-25 (fwdRadar 8821F0R01100, 8821F0R03100), C-HR 2021-22 (8821FF4102xx-0500) and Yaris (8821F0D0xxxx). The 0x80 object list and 0x85 metadata record are ISO-TP transfers (740 and 144 bytes, CRC32-protected; flow control on 0x81 / 0x86) and are not described here; neither are values that need a computation across frames or signals (a summary's speed from its range slope, LAT_DIST's hidden 13th bit), which the comments explain instead. The radar interface reads ACC_TARGET_1-3 (STATE, REL_SPEED, TARGET_ID, LONG_DIST, LAT_DIST, PRESENT, TIMESTAMP); the other messages and signals are documented for completeness, decoded from recorded drives on two RAV4s and checked on the C-HR and Yaris test routes. Comments say where a unit or meaning is approximate. Camera-sent frames on this bus (0x101, 0x102, 0x180, 0x197, 0x210, 0x240-0x248, 0x24D, 0x500, 0x501) and the constant 0x103 and 0x23D (all zero) and 0x198 (0x10; 0x90 while RADAR_FAULT is set) are left out.";
CM_ BO_ 256 "Radar PCS state, 10 Hz. The first frame after power-up is FF FF (POWER_UP = 255; ignore it); zero otherwise, except PCS_ALARM.";
CM_ SG_ 256 PCS_ALARM "Pre-collision alarm: 1 from the same CAN frame as the car-bus PCS alarm (0x283 PCSNOCHG, 0x411 FCW) until it ends; seen in 8 stock alarms on 7 cars, never otherwise.";
CM_ SG_ 256 POWER_UP "255 on the first frame after power-up, when every bit is set; 0 otherwise.";
CM_ BO_ 514 "Radar alive frame, 16.7 Hz. Bytes 2-4 are constant (03 6D 80) on every recorded car; the first frame after power-up differs.";
CM_ SG_ 514 CHECK_BYTE "Depends only on COUNTER.";
CM_ SG_ 514 COUNTER "+1 per frame, mod 16.";
CM_ BO_ 591 "Radar start-up frame, 33 Hz.";
CM_ SG_ 591 RADAR_RUNNING "0 while the radar boots, 1 once running; stays 1 (booted, not healthy). RADAR_FAULT in EVENT_STATE reports object-list loss.";
CM_ BO_ 400 "Radar cycle header, once per 60 ms radar cycle, before the target summaries.";
CM_ SG_ 400 SUMMARY_COUNT "Number of target summaries this cycle (0-2); TARGET_SUMMARY_A fills first.";
CM_ SG_ 400 TIMESTAMP "Radar cycle clock.";
CM_ SG_ 400 CYCLE_COUNTER "Cycle counter mod 16, +3 per radar cycle; a different step means a dropped cycle.";
CM_ BO_ 401 "Target summary A: one target of the radar's internal tracker (the tracker behind the ACC target): the ACC car or one of the two nearest other moving vehicles. Sentinel FE FE FE FC FC FF FE FF = no target.";
CM_ SG_ 401 SCORE "91-100 while a target is present, 127 in the sentinel. Rises with the target's own over-ground speed (95 at 1-5 m/s, 99 at 10-15, 100 above about 15 m/s) and slightly with track age: a moving-vehicle confidence, too coarse for a speed.";
CM_ SG_ 401 AGE "Target age in radar cycles, saturates at 126.";
CM_ SG_ 401 TRACK_CODE "Track code; stays with a track and can move between summaries A and B.";
CM_ SG_ 401 WIDTH "Class template width: 1.8 car, 2.2 truck.";
CM_ SG_ 401 AGE_COUNTER "Grows with target age, saturates at 30.";
CM_ SG_ 401 HEIGHT "Class template height-like size: 1.5 car, 2.3 truck.";
CM_ SG_ 401 LENGTH "Class template length: 4.5 car, 12.0 truck.";
CM_ BO_ 402 "Target summary A position. Sentinel 00 FF 00 FF = no target. On the ACC car the distance is the ACC distance rounded down to 1/16 m. No speed is sent; the slope of LONG_DIST per track gives one.";
CM_ SG_ 402 LONG_DIST "Distance from the radar.";
CM_ SG_ 402 LAT_DIST "Lateral position, left positive.";
CM_ BO_ 403 "Target summary B: same layout as TARGET_SUMMARY_A_INFO.";
CM_ BO_ 404 "Target summary B position: same layout as TARGET_SUMMARY_A_POS.";
CM_ BO_ 405 "Event object: idle (exact payload) except in short time-to-collision states (0.5 % of moving cycles); then one object of the radar's tracker, usually the ACC car.";
CM_ SG_ 405 PATH_CURVATURE "Ego path curvature, left positive (about 1/133,000 per m per code).";
CM_ SG_ 405 OBJECT_ACCEL "Object over-ground acceleration (about 1/32 m/s^2 per code, approximate).";
CM_ SG_ 405 OBJECT_SPEED "Object longitudinal over-ground speed.";
CM_ SG_ 405 EGO_TRAVEL_TO_TTC "Ego's predicted travel until the time to collision (v T + a T^2 / 2, T = distance / closing speed), clamped at 0.";
CM_ SG_ 405 OBJECT_DIST "Object distance; on the ACC car the ACC distance rounded down to 0.05 m. 0 when idle.";
CM_ BO_ 406 "Event state, paired with EVENT_OBJECT.";
CM_ SG_ 406 REQUIRED_DECEL "Required deceleration for the event object while active: floor(a_req / 0.095) of a lead-moving / lead-stops formula with a 1.75 m margin.";
CM_ SG_ 406 RADAR_FAULT "Radar fault: held while the radar declares itself blocked (car-bus 0x411 dust state; the object list keeps running) and after some object-list outages; also set for the single first cycle after power-up, so require two or more consecutive cycles.";
CM_ BO_ 565 "ACC target, part 1: 50 Hz, content updated once per 60 ms radar cycle.";
CM_ SG_ 565 CHECK_BYTE "Check byte over the rest of the frame (algorithm unknown).";
CM_ SG_ 565 CHECK_BYTE "CRC-8 (polynomial 0x1D, MSB first) over the frame's signals serialized as zero-padded 8, 16 or 32-bit integers, not over the raw bytes; linear, so a 56-column table over payload bits plus a constant computes it.";
CM_ SG_ 565 STATE "5 = target present, 1 = idle (bytes 2-7 64 80 0B 24 00 FF), 15 = start-up.";
CM_ SG_ 565 REL_ACCEL "Target acceleration relative to ego, positive = opening.";
CM_ SG_ 565 REL_SPEED "Closing speed relative to ego, negative = closing.";
CM_ SG_ 565 LAT_ACCEL "Relative lateral acceleration, left positive (nominal unit). Mostly minus ego's own lateral acceleration.";
CM_ SG_ 565 LAT_SPEED "Lateral speed of the target relative to ego, left positive (about 0.0125 m/s per code).";
CM_ SG_ 565 TARGET_ID "Changes when the radar switches to a different target; 31 while idle.";
CM_ SG_ 565 LAT_SPEED "Lateral speed of the target relative to ego in the rotating ego frame, left positive (about 0.0125 m/s per code). Wraps above the top code (crossing traffic); the check byte then differs by 0x9C.";
CM_ SG_ 565 TARGET_ID "The radar tracker's track number: changes when the radar switches to a different target, kept when it re-acquires the same one. 32-63 occur on a C-HR radar (8821FF410300); the RAV4 radars sent 0-31 in every recorded drive. 63 in the idle payload.";
CM_ BO_ 567 "ACC target, part 2: 50 Hz.";
CM_ SG_ 567 CHECK_BYTE "Check byte: an affine parity function of bytes 1-7.";
CM_ SG_ 567 CHECK_BYTE "CRC-8 like ACC_TARGET_1's, over this frame's signals.";
CM_ SG_ 567 LONG_DIST "Distance from the radar.";
CM_ SG_ 567 LAT_DIST "Lateral position, left positive.";
CM_ SG_ 567 LAT_DIST "Lateral position, left positive. Holds the low 12 bits of a 13-bit value: beyond +20.95 m (targets 21-53 m to the left in turns and at junctions) it wraps by 40.96 m, and the check byte then differs from the CRC of the visible bits by 0x14. Stops at -20.00 m on the right.";
CM_ SG_ 567 TRACKER_A "Raw tracker byte: about 35 on a steady target, higher while it accelerates or brakes.";
CM_ SG_ 567 TRACKER_B "Raw tracker byte: about 86 for a stopped target, 128-135 for a steady mover, rises (and wraps) while it accelerates or brakes.";
CM_ SG_ 567 IN_PATH "1 while the target is confirmed in the path (level 5).";
@@ -90,15 +187,24 @@ CM_ SG_ 567 PRESENT "1 = target present.";
CM_ SG_ 567 IN_PATH_LEVEL "In-path level 5, 4, 3, 2; steps to the neighboring level only; lower levels sit farther from the path.";
CM_ SG_ 567 IN_PATH_CANDIDATE "1 while the target is a candidate (levels 4-2).";
CM_ BO_ 569 "ACC target, part 3: 50 Hz.";
CM_ SG_ 569 CHECK_BYTE "Check byte: an affine parity function of bytes 1-7.";
CM_ SG_ 569 CLASS "Target class: 1 car, 2 truck, 0 / 4 / 5 / 6 other, 7 idle, 15 start-up.";
CM_ SG_ 569 CHECK_BYTE "CRC-8 like ACC_TARGET_1's, over this frame's signals.";
CM_ SG_ 569 CLASS "Target class: 1 car, 2 truck; likely 0 narrow and 6 wide stationary object, 4 unclassified object, 5 crossing object; 7 idle, 15 start-up; 3 never seen.";
CM_ SG_ 569 STATE "1 with an ACC target, 2 idle.";
CM_ SG_ 569 IN_OBJECT_LIST "1 while the target also has an object in the 0x80 object list.";
CM_ SG_ 569 PRESENT "1 = target present.";
CM_ SG_ 569 TIMESTAMP "Radar cycle clock: changes once per 60 ms radar cycle, when the ACC target is recomputed.";
CM_ BO_ 571 "ACC target, part 4: 50 Hz, 3 bytes.";
CM_ SG_ 571 CHECK_BYTE "CRC-8 (polynomial 0x1D, init 0, xor 0x59) over the counter and width bits.";
CM_ SG_ 571 CHECK_BYTE "CRC-8 SAE J1850 (polynomial 0x1D, init 0xFF, final xor 0xFF) over the bytes 0x00, COUNTER, WIDTH as 16 bits.";
CM_ SG_ 571 WIDTH "Target width: 0 while idle, 140-220 cm for the car class, 200-280 cm for the truck class.";
CM_ BO_ 1664 "One object from the radar's tracker every 0.5 s: its track number 0, which is the ACC target whenever TARGET_ID is 0 and otherwise mostly a stationary roadside object.";
CM_ SG_ 1664 SELECTOR "0 / 1 mostly stationary objects, 3 mostly same-direction vehicles.";
CM_ SG_ 1664 LONG_DIST "Longitudinal distance.";
CM_ SG_ 1664 LAT_DIST "Lateral position, left positive; covers +-15.36 m.";
CM_ SG_ 1664 SPEED "Speed over ground; 0 for stationary objects.";
CM_ SG_ 1664 STATIONARY "1 for a stationary object.";
CM_ SG_ 1664 ONCOMING "1 for an oncoming object.";
CM_ SG_ 1664 SEEN_MOVING "1 once the object has been seen moving (with STATIONARY: a stopped vehicle).";
CM_ SG_ 1664 LAT_SPEED "Lateral speed over ground, left positive (about 0.13-0.18 m/s per code, nominal 0.15).";
VAL_ 565 STATE 15 "STARTUP" 5 "TARGET" 1 "NO_TARGET" ;
VAL_ 569 CLASS 0 "OTHER_0" 1 "CAR" 2 "TRUCK" 4 "OTHER_4" 5 "OTHER_5" 6 "OTHER_6" 7 "NO_TARGET" 15 "STARTUP" ;
VAL_ 569 CLASS 0 "STATIONARY_NARROW" 1 "CAR" 2 "TRUCK" 4 "UNCLASSIFIED" 5 "CROSSING" 6 "STATIONARY_WIDE" 7 "NO_TARGET" 15 "STARTUP" ;
VAL_ 569 STATE 1 "TARGET" 2 "NO_TARGET" ;
+1 -3
View File
@@ -140,12 +140,10 @@ class TestHighlanderAol(unittest.TestCase):
with self.subTest(car=car, alpha=alpha):
cp = CarInterface.get_params(car, gen_empty_fingerprint(), [], alpha, False, False)
cp.flags |= int(ToyotaFlags.ARS510_RADAR)
expected = car == CAR.TOYOTA_RAV4_TSS2_2022 and not alpha
expected = car == CAR.TOYOTA_RAV4_TSS2_2022 # the ACC target receiver also runs under the radar disable
self.assertEqual(qualified(cp), expected)
cp.alternativeExperience = 32
self.assertEqual(qualified(cp, marked_only=True), expected)
cp.flags |= int(ToyotaFlags.ARS510_FUSED)
self.assertFalse(qualified(cp))
def test_radar_torque_factory_stock_and_alpha_transport(self):
from opendbc.car.toyota.carcontroller import CarController
+4 -4
View File
@@ -75,9 +75,8 @@ def radar_filter_qualified(cp, *, marked_only=False):
required |= ToyotaFlags.TSS2 | ToyotaFlags.RADAR_ACC | ToyotaFlags.RAISED_ACCEL_LIMIT
allowed = required | ToyotaFlags.HYBRID | ToyotaFlags.HAS_BSM | ToyotaFlags.FILTER_BUTTONS
if cp.carFingerprint == CAR.TOYOTA_RAV4_TSS2_2022:
allowed |= ToyotaFlags.ARS510_RADAR | ToyotaFlags.ARS510_FUSED
return bool(cp.flags & required == required and not int(cp.flags) & ~int(allowed) and
(not cp.flags & ToyotaFlags.ARS510_FUSED or cp.flags & ToyotaFlags.ARS510_RADAR))
allowed |= ToyotaFlags.ARS510_RADAR
return bool(cp.flags & required == required and not int(cp.flags) & ~int(allowed))
def angle_qualified(cp, *, marked_only=False):
@@ -177,7 +176,8 @@ def qualified(cp, *, marked_only=False):
if hold:
return False
allowed_flags = required_flags | ToyotaFlags.HYBRID | ToyotaFlags.HAS_BSM
if cp.carFingerprint == CAR.TOYOTA_RAV4_TSS2_2022 and not cp.openpilotLongitudinalControl:
if cp.carFingerprint == CAR.TOYOTA_RAV4_TSS2_2022:
# the ACC target receiver also runs under alpha long's radar disable (DISABLE_RADAR)
allowed_flags |= ToyotaFlags.ARS510_RADAR
if cp.flags & required_flags != required_flags or int(cp.flags) & ~int(allowed_flags | ToyotaFlags.AUTO_BRAKE_HOLD):
return False
@@ -39,7 +39,6 @@ def test_retired_choice_cannot_disable_or_change_automatic_receiver(tmp_path, ca
owner.prepare(cp)
owner.finalize(cp)
assert cp.flags & ToyotaFlags.ARS510_RADAR, 'AUTOMATIC_CONTINENTAL_RADAR'
assert not cp.flags & ToyotaFlags.ARS510_FUSED
assert not cp.radarUnavailable and RadarInterface(cp).ars510 is not None
assert cp.safetyConfigs[0].to_dict() == baseline['safetyConfigs'][0]
assert cp.lateralTuning.to_dict() == baseline['lateralTuning']
@@ -93,14 +92,18 @@ def test_automatic_factory_card_and_radard_parse_live_target(candidate):
@pytest.mark.parametrize('candidate', [CAR.TOYOTA_RAV4_TSS2_2022, CAR.TOYOTA_RAV4_TSS2_2023])
def test_disabled_radar_withdraws_a_previous_receiver_without_changing_authority(candidate):
def test_disabled_radar_keeps_acc_target_receiver_without_changing_authority(candidate):
# alpha long's UDS disable stops the radar's car-bus output only; the radar bus keeps sending the ACC target
from opendbc.car.toyota.ars510_preferences import configure_radar
cp = CarInterface.get_params(candidate, gen_empty_fingerprint(), [], False, False, False)
cp.flags |= int(ToyotaFlags.DISABLE_RADAR | ToyotaFlags.ARS510_FUSED)
cp = CarInterface.get_params(candidate, gen_empty_fingerprint(), [], True, False, False)
assert cp.flags & ToyotaFlags.DISABLE_RADAR
cp.flags &= ~int(ToyotaFlags.ARS510_RADAR)
cp.radarUnavailable = True
before = cp.to_dict()
assert not configure_radar(cp)
assert configure_radar(cp)
expected = before.copy()
expected['flags'] &= ~int(ToyotaFlags.ARS510_RADAR | ToyotaFlags.ARS510_FUSED)
expected['radarUnavailable'] = True
expected['flags'] |= int(ToyotaFlags.ARS510_RADAR)
expected['radarUnavailable'] = False
assert cp.to_dict() == expected
assert RadarInterface(cp).ars510 is None
assert cp.flags & ToyotaFlags.DISABLE_RADAR and cp.openpilotLongitudinalControl
assert RadarInterface(cp).ars510 is not None
+1 -1
View File
@@ -1 +1 @@
{"protected_inventory_sha256": "678b5dbf02949a821c6c8eb486de53efd4a1552d48fb4222e136f9bde60483a6", "schema_version": 1}
{"protected_inventory_sha256": "ce33871fe77809fd591d89ad2379046ddc912680ef6cc242e9f7997ac539ead3", "schema_version": 1}