mirror of
https://github.com/dragonpilot/dragonpilot.git
synced 2026-02-18 19:53:52 +08:00
Merge branch 'pre-vag' into pre
This commit is contained in:
@@ -143,4 +143,7 @@ inline static std::unordered_map<std::string, uint32_t> keys = {
|
||||
{"dp_toyota_door_auto_lock_unlock", PERSISTENT},
|
||||
{"dp_toyota_tss1_sng", PERSISTENT},
|
||||
{"dp_toyota_stock_lon", PERSISTENT},
|
||||
{"dp_vag_a0_sng", PERSISTENT},
|
||||
{"dp_vag_pq_steering_patch", PERSISTENT},
|
||||
{"dp_vag_avoid_eps_lockout", PERSISTENT},
|
||||
};
|
||||
|
||||
@@ -25,4 +25,7 @@ class DPFlags:
|
||||
ToyotaDoorAutoLockUnlock = 2 ** 2
|
||||
ToyotaTSS1SnG = 2 ** 3
|
||||
ToyotaStockLon = 2 ** 4
|
||||
VagA0SnG = 2 ** 5
|
||||
VAGPQSteeringPatch = 2 ** 6
|
||||
VagAvoidEPSLockout = 2 ** 7
|
||||
pass
|
||||
|
||||
@@ -13,7 +13,7 @@ LongCtrlState = structs.CarControl.Actuators.LongControlState
|
||||
class CarController(CarControllerBase):
|
||||
def __init__(self, dbc_names, CP):
|
||||
super().__init__(dbc_names, CP)
|
||||
self.CCP = CarControllerParams(CP)
|
||||
self.CCP = CarControllerParams(CP, CP.flags & VolkswagenFlags.AVOID_EPS_LOCKOUT)
|
||||
self.CCS = pqcan if CP.flags & VolkswagenFlags.PQ else mqbcan
|
||||
self.packer_pt = CANPacker(dbc_names[Bus.pt])
|
||||
self.ext_bus = CANBUS.pt if CP.networkLocation == structs.CarParams.NetworkLocation.fwdCamera else CANBUS.cam
|
||||
@@ -24,6 +24,7 @@ class CarController(CarControllerBase):
|
||||
self.eps_timer_soft_disable_alert = False
|
||||
self.hca_frame_timer_running = 0
|
||||
self.hca_frame_same_torque = 0
|
||||
self.dp_vag_pq_steering_patch = 7 if CP.flags & VolkswagenFlags.PQSteeringPatch else 5
|
||||
|
||||
def update(self, CC, CS, now_nanos):
|
||||
actuators = CC.actuators
|
||||
@@ -63,7 +64,7 @@ class CarController(CarControllerBase):
|
||||
|
||||
self.eps_timer_soft_disable_alert = self.hca_frame_timer_running > self.CCP.STEER_TIME_ALERT / DT_CTRL
|
||||
self.apply_torque_last = apply_torque
|
||||
can_sends.append(self.CCS.create_steering_control(self.packer_pt, CANBUS.pt, apply_torque, hca_enabled))
|
||||
can_sends.append(self.CCS.create_steering_control(self.packer_pt, CANBUS.pt, apply_torque, hca_enabled, self.dp_vag_pq_steering_patch))
|
||||
|
||||
if self.CP.flags & VolkswagenFlags.STOCK_HCA_PRESENT:
|
||||
# Pacify VW Emergency Assist driver inactivity detection by changing its view of driver steering input torque
|
||||
@@ -111,11 +112,22 @@ class CarController(CarControllerBase):
|
||||
lead_distance, hud_control.leadDistanceBars))
|
||||
|
||||
# **** Stock ACC Button Controls **************************************** #
|
||||
if self.CP.flags & VolkswagenFlags.A0SnG:
|
||||
if self.CP.pcmCruise and CS.gra_stock_values["COUNTER"] != self.gra_acc_counter_last:
|
||||
standing_resume_spam = CS.out.standstill
|
||||
spam_window = self.frame % 50 < 15
|
||||
|
||||
gra_send_ready = self.CP.pcmCruise and CS.gra_stock_values["COUNTER"] != self.gra_acc_counter_last
|
||||
if gra_send_ready and (CC.cruiseControl.cancel or CC.cruiseControl.resume):
|
||||
can_sends.append(self.CCS.create_acc_buttons_control(self.packer_pt, self.ext_bus, CS.gra_stock_values,
|
||||
cancel=CC.cruiseControl.cancel, resume=CC.cruiseControl.resume))
|
||||
send_cancel = CC.cruiseControl.cancel
|
||||
send_resume = CC.cruiseControl.resume or (standing_resume_spam and spam_window)
|
||||
|
||||
if send_cancel or send_resume:
|
||||
can_sends.append(self.CCS.create_acc_buttons_control(self.packer_pt, self.ext_bus, CS.gra_stock_values,
|
||||
cancel=send_cancel, resume=send_resume))
|
||||
else:
|
||||
gra_send_ready = self.CP.pcmCruise and CS.gra_stock_values["COUNTER"] != self.gra_acc_counter_last
|
||||
if gra_send_ready and (CC.cruiseControl.cancel or CC.cruiseControl.resume):
|
||||
can_sends.append(self.CCS.create_acc_buttons_control(self.packer_pt, self.ext_bus, CS.gra_stock_values,
|
||||
cancel=CC.cruiseControl.cancel, resume=CC.cruiseControl.resume))
|
||||
|
||||
new_actuators = actuators.as_builder()
|
||||
new_actuators.torque = self.apply_torque_last / self.CCP.STEER_MAX
|
||||
|
||||
@@ -35,7 +35,7 @@ class CarInterface(CarInterfaceBase):
|
||||
# It is documented in a four-part blog series:
|
||||
# https://blog.willemmelching.nl/carhacking/2022/01/02/vw-part1/
|
||||
# Panda ALLOW_DEBUG firmware required.
|
||||
ret.dashcamOnly = True
|
||||
# ret.dashcamOnly = True
|
||||
|
||||
else:
|
||||
# Set global MQB parameters
|
||||
@@ -87,4 +87,13 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.vEgoStopping = 0.5
|
||||
ret.autoResumeSng = ret.minEnableSpeed == -1
|
||||
|
||||
if dp_params & structs.DPFlags.VagA0SnG:
|
||||
ret.flags |= VolkswagenFlags.A0SnG.value
|
||||
|
||||
if ret.flags & VolkswagenFlags.PQ and dp_params & structs.DPFlags.VAGPQSteeringPatch:
|
||||
ret.flags |= VolkswagenFlags.PQSteeringPatch.value
|
||||
|
||||
if dp_params & structs.DPFlags.VagAvoidEPSLockout:
|
||||
ret.flags |= VolkswagenFlags.AVOID_EPS_LOCKOUT.value
|
||||
|
||||
return ret
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
def create_steering_control(packer, bus, apply_torque, lkas_enabled):
|
||||
def create_steering_control(packer, bus, apply_torque, lkas_enabled, dp_vag_pq_steering_patch):
|
||||
values = {
|
||||
"HCA_01_Status_HCA": 5 if lkas_enabled else 3,
|
||||
"HCA_01_LM_Offset": abs(apply_torque),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
def create_steering_control(packer, bus, apply_torque, lkas_enabled):
|
||||
def create_steering_control(packer, bus, apply_torque, lkas_enabled, dp_vag_pq_steering_patch = 5):
|
||||
values = {
|
||||
"LM_Offset": abs(apply_torque),
|
||||
"LM_OffSign": 1 if apply_torque < 0 else 0,
|
||||
"HCA_Status": 5 if (lkas_enabled and apply_torque != 0) else 3,
|
||||
"HCA_Status": dp_vag_pq_steering_patch if (lkas_enabled and apply_torque != 0) else 3,
|
||||
"Vib_Freq": 16,
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,8 @@ class CarControllerParams:
|
||||
# MQB vs PQ maximums are shared, but rate-of-change limited differently
|
||||
# based on safety requirements driven by lateral accel testing.
|
||||
|
||||
STEER_MAX = 300 # Max heading control assist torque 3.00 Nm
|
||||
# rick - move to init so we can overwrite it with avoid eps lockout
|
||||
# STEER_MAX = 300 # Max heading control assist torque 3.00 Nm
|
||||
STEER_DRIVER_MULTIPLIER = 3 # weight driver torque heavily
|
||||
STEER_DRIVER_FACTOR = 1 # from dbc
|
||||
|
||||
@@ -40,8 +41,9 @@ class CarControllerParams:
|
||||
ACCEL_MAX = 2.0 # 2.0 m/s max acceleration
|
||||
ACCEL_MIN = -3.5 # 3.5 m/s max deceleration
|
||||
|
||||
def __init__(self, CP):
|
||||
def __init__(self, CP, avoid_eps_lockout = False):
|
||||
can_define = CANDefine(DBC[CP.carFingerprint][Bus.pt])
|
||||
self.STEER_MAX = 300 if not avoid_eps_lockout else 288
|
||||
|
||||
if CP.flags & VolkswagenFlags.PQ:
|
||||
self.LDW_STEP = 5 # LDW_1 message frequency 20Hz
|
||||
@@ -144,6 +146,10 @@ class VolkswagenFlags(IntFlag):
|
||||
# Static flags
|
||||
PQ = 2
|
||||
|
||||
A0SnG = 2 ** 2
|
||||
PQSteeringPatch = 2 ** 3
|
||||
AVOID_EPS_LOCKOUT = 2 ** 4
|
||||
|
||||
|
||||
@dataclass
|
||||
class VolkswagenMQBPlatformConfig(PlatformConfig):
|
||||
|
||||
@@ -111,6 +111,15 @@ class Car:
|
||||
if self.params.get_bool("dp_toyota_stock_lon"):
|
||||
dp_params |= structs.DPFlags.ToyotaStockLon
|
||||
|
||||
if self.params.get_bool("dp_vag_a0_sng"):
|
||||
dp_params |= structs.DPFlags.VagA0SnG
|
||||
|
||||
if self.params.get_bool("dp_vag_pq_steering_patch"):
|
||||
dp_params |= structs.DPFlags.VAGPQSteeringPatch
|
||||
|
||||
if self.params.get_bool("dp_vag_avoid_eps_lockout"):
|
||||
dp_params |= structs.DPFlags.VagAvoidEPSLockout
|
||||
|
||||
self.CI = get_car(*self.can_callbacks, obd_callback(self.params), experimental_long_allowed, num_pandas, dp_params, cached_params)
|
||||
self.RI = interfaces[self.CI.CP.carFingerprint].RadarInterface(self.CI.CP)
|
||||
self.CP = self.CI.CP
|
||||
|
||||
@@ -2,8 +2,9 @@ import numpy as np
|
||||
from abc import abstractmethod, ABC
|
||||
|
||||
from openpilot.common.realtime import DT_CTRL
|
||||
from openpilot.common.params import Params
|
||||
|
||||
MIN_LATERAL_CONTROL_SPEED = 0.3 # m/s
|
||||
MIN_LATERAL_CONTROL_SPEED = 2.5 if Params().get_bool("dp_vag_avoid_eps_lockout") else 0.3 # m/s
|
||||
|
||||
|
||||
class LatControl(ABC):
|
||||
|
||||
@@ -55,6 +55,21 @@ void DPPanel::add_vag_toggles() {
|
||||
QString::fromUtf8("🐉 ") + tr("VW / Audi / Skoda"),
|
||||
"",
|
||||
},
|
||||
{
|
||||
"dp_vag_a0_sng",
|
||||
tr("Enable MQB A0 SnG Mod"),
|
||||
"",
|
||||
},
|
||||
{
|
||||
"dp_vag_pq_steering_patch",
|
||||
tr("PQ Steering Patch"),
|
||||
""
|
||||
},
|
||||
{
|
||||
"dp_vag_avoid_eps_lockout",
|
||||
tr("Avoid EPS Lockout"),
|
||||
"",
|
||||
},
|
||||
};
|
||||
|
||||
QWidget *label = nullptr;
|
||||
|
||||
@@ -65,6 +65,9 @@ def manager_init() -> None:
|
||||
("dp_toyota_door_auto_lock_unlock", "0"),
|
||||
("dp_toyota_tss1_sng", "0"),
|
||||
("dp_toyota_stock_lon", "0"),
|
||||
("dp_vag_a0_sng", "0"),
|
||||
("dp_vag_pq_steering_patch", "0"),
|
||||
("dp_vag_avoid_eps_lockout", "0"),
|
||||
]
|
||||
|
||||
if params.get_bool("RecordFrontLock"):
|
||||
|
||||
Reference in New Issue
Block a user