mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-12-02 04:53:40 +08:00
Separate HKG steering and qualified dashboard status contracts
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import pytest
|
||||
|
||||
from opendbc.can.parser import CANParser
|
||||
from opendbc.car import gen_empty_fingerprint, structs
|
||||
from opendbc.car.hyundai.canfd_stock_aol import qualified, qualified_long
|
||||
from opendbc.car.hyundai.carcontroller import CarController
|
||||
from opendbc.car.hyundai.carstate import CarState
|
||||
from opendbc.car.hyundai.interface import CarInterface
|
||||
@@ -44,13 +46,16 @@ def test_full_controller_steering_is_independent_of_longitudinal(car, topology,
|
||||
state.is_metric = True
|
||||
states.append(state)
|
||||
address = {'lfa': 0x12A, 'lkas': 0x50, 'lkas_alt': 0x110}[topology]
|
||||
message = {'lfa': 'LFA', 'lkas': 'LKAS', 'lkas_alt': 'LKAS_ALT'}[topology]
|
||||
decoders = [CANParser(DBC[car]['pt'], [(message, 0)], controller.CAN.ACAN if topology != 'lfa' else controller.CAN.ECAN)
|
||||
for controller in controllers]
|
||||
for frame in range(300):
|
||||
cc = structs.CarControl(enabled=not aol or frame < 150, latActive=True)
|
||||
cc.actuators.torque = (0.6 if frame % 80 < 40 else -0.6)
|
||||
cc.actuators.accel = -0.4 if frame % 50 < 25 else 0.5
|
||||
cc.hudControl.setSpeed = 20.0
|
||||
results = []
|
||||
for cp, controller, state in zip((stock, long), controllers, states, strict=True):
|
||||
for cp, controller, state, decoder in zip((stock, long), controllers, states, decoders, strict=True):
|
||||
state.out.vEgo = state.out.vEgoRaw = (2.0, 14.9, 15.0, 30.0)[frame // 75]
|
||||
state.out.steeringTorque = 0.0 if frame < 200 else 300.0
|
||||
state.out.steeringAngleDeg = 100.0 if frame < 120 else 0.0
|
||||
@@ -58,8 +63,22 @@ def test_full_controller_steering_is_independent_of_longitudinal(car, topology,
|
||||
output, packets = controller.update(cc.as_reader(), state, 1_000_000_000 + frame * 10_000_000)
|
||||
steering = [packet for packet in packets if packet[0] == address]
|
||||
assert len(steering) == 1
|
||||
results.append((output.torqueOutputCan, steering))
|
||||
assert results[0] == results[1], (car, topology, frame, results)
|
||||
decoder.update([1_000_000_000 + frame * 10_000_000, steering])
|
||||
assert decoder.can_valid
|
||||
values = dict(decoder.vl[message])
|
||||
indicator = values.pop('LKA_SysIndReq')
|
||||
values.pop('CHECKSUM')
|
||||
expected_active = cc.enabled or qualified(cp) or qualified_long(cp)
|
||||
assert indicator == (2 if expected_active else 1), (car, topology, frame, cp.openpilotLongitudinalControl)
|
||||
results.append((output.torqueOutputCan, values, steering))
|
||||
assert results[0][:2] == results[1][:2], (car, topology, frame, results)
|
||||
normalized = [bytearray(result[2][0][1]) for result in results]
|
||||
for data in normalized:
|
||||
data[:2] = b'\x00\x00'
|
||||
data[4] &= 0x3F
|
||||
assert normalized[0] == normalized[1], (car, topology, frame, results)
|
||||
if cc.enabled:
|
||||
assert results[0][2] == results[1][2], (car, topology, frame, results)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('car', (CAR.KIA_EV6, CAR.HYUNDAI_IONIQ_5, CAR.KIA_NIRO_EV_2ND_GEN))
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{"protected_inventory_sha256": "2a750beaa582adfd456f257132ec3200f21bef7baf40527187ce408203197948", "schema_version": 1}
|
||||
{"protected_inventory_sha256": "ee31ca3d9d375f32686251f70a77cca6b1b4e0845c6e3343beedecbbaa2085fa", "schema_version": 1}
|
||||
|
||||
Reference in New Issue
Block a user