mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-09-08 17:13:45 +08:00
PIKA
This commit is contained in:
@@ -245,6 +245,11 @@ class CarState(CarStateBase):
|
||||
|
||||
buttonEvents += create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise})
|
||||
|
||||
if self.CP.carFingerprint in LEGACY_PRIUS_CAR and not self.has_SDSU:
|
||||
prev_distance_button = self.distance_button
|
||||
self.distance_button = cp_acc.vl["ACC_CONTROL"]["DISTANCE"]
|
||||
buttonEvents += create_button_events(self.distance_button, prev_distance_button, {1: ButtonType.gapAdjustCruise})
|
||||
|
||||
if self.CP.carFingerprint in DISTANCE_BUTTON_CAR:
|
||||
prev_distance_button = self.distance_button
|
||||
self.distance_button = cp.vl["PCM_CRUISE_4"]["DISTANCE"]
|
||||
@@ -294,14 +299,20 @@ class CarState(CarStateBase):
|
||||
pt_messages = [
|
||||
("BLINKERS_STATE", float('nan')),
|
||||
]
|
||||
cam_messages = []
|
||||
|
||||
if CP.enableGasInterceptorDEPRECATED:
|
||||
pt_messages.append(("GAS_SENSOR", 50))
|
||||
|
||||
if CP.carFingerprint in LEGACY_PRIUS_CAR:
|
||||
pt_messages.append(("ACC_CONTROL", float('nan')))
|
||||
if CP.flags & ToyotaFlags.DSU_BYPASS.value:
|
||||
cam_messages.append(("ACC_CONTROL", float('nan')))
|
||||
|
||||
if CP.carFingerprint in DISTANCE_BUTTON_CAR:
|
||||
pt_messages.append(("PCM_CRUISE_4", 1))
|
||||
|
||||
return {
|
||||
Bus.pt: CANParser(DBC[CP.carFingerprint][Bus.pt], pt_messages, 0),
|
||||
Bus.cam: CANParser(DBC[CP.carFingerprint][Bus.pt], [], 2),
|
||||
Bus.cam: CANParser(DBC[CP.carFingerprint][Bus.pt], cam_messages, 2),
|
||||
}
|
||||
|
||||
@@ -1043,6 +1043,36 @@ class TestToyotaCarController:
|
||||
|
||||
|
||||
class TestToyotaCarState:
|
||||
@pytest.mark.parametrize("candidate", [CAR.TOYOTA_PRIUS, CAR.TOYOTA_PRIUS_RETROFIT])
|
||||
def test_legacy_prius_distance_button_generates_events(self, candidate):
|
||||
params = CarInterface.get_params(
|
||||
candidate,
|
||||
{bus: {} for bus in range(8)},
|
||||
[],
|
||||
alpha_long=False,
|
||||
is_release=False,
|
||||
docs=False,
|
||||
starpilot_toggles=SimpleNamespace(force_torque_controller=False, nnff=False, nnff_lite=False),
|
||||
)
|
||||
starpilot_params = CarInterface.get_starpilot_params(candidate, {bus: {} for bus in range(8)}, [], params, SimpleNamespace())
|
||||
car_state = CarState(params, starpilot_params)
|
||||
can_parsers = car_state.get_can_parsers(params)
|
||||
|
||||
assert "ACC_CONTROL" in can_parsers[Bus.pt].vl
|
||||
assert ("ACC_CONTROL" in can_parsers[Bus.cam].vl) == bool(params.flags & ToyotaFlags.DSU_BYPASS.value)
|
||||
|
||||
can_parsers[Bus.pt].vl["ACC_CONTROL"]["DISTANCE"] = 1
|
||||
ret, _ = car_state.update(can_parsers, SimpleNamespace(cluster_offset=1.0))
|
||||
assert [(event.type, event.pressed) for event in ret.buttonEvents] == [
|
||||
(structs.CarState.ButtonEvent.Type.gapAdjustCruise, True),
|
||||
]
|
||||
|
||||
can_parsers[Bus.pt].vl["ACC_CONTROL"]["DISTANCE"] = 0
|
||||
ret, _ = car_state.update(can_parsers, SimpleNamespace(cluster_offset=1.0))
|
||||
assert [(event.type, event.pressed) for event in ret.buttonEvents] == [
|
||||
(structs.CarState.ButtonEvent.Type.gapAdjustCruise, False),
|
||||
]
|
||||
|
||||
def test_lkas_button_platforms(self):
|
||||
assert CAR.TOYOTA_PRIUS in LKAS_BUTTON_CAR
|
||||
assert TSS2_CAR <= LKAS_BUTTON_CAR
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
// Keep the absolute envelope aligned with the software controller's 540 deg limit.
|
||||
#define VOLVO_ANGLE_DEG_TO_CAN 17.869907f
|
||||
#define VOLVO_MAX_ANGLE_CAN 9650
|
||||
#define VOLVO_RELAY_ANGLE_TOLERANCE 54 // approximately 3 degrees
|
||||
#define VOLVO_DRIVER_OVERRIDE 2
|
||||
|
||||
|
||||
@@ -186,8 +187,10 @@ static bool volvo_tx_hook(const CANPacket_t *msg) {
|
||||
// path. Do not allow that relay to invent a steering-angle measurement.
|
||||
if (msg->addr == VOLVO_PSCM) {
|
||||
const int relayed_angle = volvo_pscm_angle(msg);
|
||||
const int measured_max = SAFETY_CLAMP(angle_meas.max, -VOLVO_MAX_ANGLE_CAN, VOLVO_MAX_ANGLE_CAN) + 1;
|
||||
const int measured_min = SAFETY_CLAMP(angle_meas.min, -VOLVO_MAX_ANGLE_CAN, VOLVO_MAX_ANGLE_CAN) - 1;
|
||||
const int measured_max = SAFETY_CLAMP(angle_meas.max + VOLVO_RELAY_ANGLE_TOLERANCE,
|
||||
-VOLVO_MAX_ANGLE_CAN, VOLVO_MAX_ANGLE_CAN);
|
||||
const int measured_min = SAFETY_CLAMP(angle_meas.min - VOLVO_RELAY_ANGLE_TOLERANCE,
|
||||
-VOLVO_MAX_ANGLE_CAN, VOLVO_MAX_ANGLE_CAN);
|
||||
tx &= !safety_max_limit_check(relayed_angle, measured_max, measured_min);
|
||||
}
|
||||
|
||||
@@ -262,7 +265,8 @@ static safety_config volvo_init(uint16_t param) {
|
||||
volvo_ecm_1_addr = spa ? VOLVO_SPA_ECM_1 : VOLVO_CMA_ECM_1;
|
||||
volvo_bus1_cruise_control_addr = spa ? VOLVO_SPA_BUS1_CRUISE_CONTROL : VOLVO_CMA_BUS1_CRUISE_CONTROL;
|
||||
|
||||
// Define allowed TX messages - very permissive
|
||||
// Define the TX messages needed to replace the stock LCA path. Payload
|
||||
// limits for steering and the PSCM relay are enforced in volvo_tx_hook.
|
||||
static const CanMsg VOLVO_TX_MSGS[] = {
|
||||
{VOLVO_LCA_STEER, VOLVO_PARTY_BUS, 8, .check_relay = true}, // LCA steering command to party bus
|
||||
{VOLVO_PSCM, VOLVO_MAIN_BUS, 8, .check_relay = true}, // PSCM message sent to main bus (relay from party bus)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,2 +1,2 @@
|
||||
extern const uint8_t gitversion[19];
|
||||
const uint8_t gitversion[19] = "DEV-dc62d0e2-DEBUG";
|
||||
const uint8_t gitversion[19] = "DEV-289f5e9d-DEBUG";
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
DEV-dc62d0e2-DEBUG
|
||||
DEV-289f5e9d-DEBUG
|
||||
Reference in New Issue
Block a user