Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VW PQ: HCA mode switching #55

Merged
merged 29 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c06728c
initial hca_mode flipping commit
dkiiv May 3, 2024
cddc76c
hot fix**ing**
dkiiv May 3, 2024
a39dbe5
bump hysteresis to 5 deg
dkiiv May 5, 2024
fdaa285
increase hysteresis to 13 degree's
dkiiv May 6, 2024
3bb2738
change HCA flipping logic.
dkiiv May 6, 2024
7a81719
logic change worked, dropping hysteresis limits to test
dkiiv May 6, 2024
78175ea
switch to NM torque blending
dkiiv May 6, 2024
70245b7
temporarily bump panda maxsteer to 400
dkiiv May 6, 2024
6efc34f
revert panda edit, refactor torque blend
dkiiv May 6, 2024
69aecfd
refactor, again!
dkiiv May 6, 2024
e73931c
try ramping the 1NM drop
dkiiv May 6, 2024
e1d96f4
bugfix for pseudo STEER_MAX?
dkiiv May 6, 2024
0d7faa8
another hotfix
dkiiv May 6, 2024
ce6311d
change rate limit in interpolation, removed apply_driver_steer_torque…
dkiiv May 6, 2024
9ca1d9a
throw out >3nm. switch to HCA7 when requested torque >2nm
dkiiv May 6, 2024
e79a362
make HCA7 switching a wider band, and add some torque interpolation
dkiiv May 7, 2024
d6fa3b9
change flipping logic
dkiiv May 7, 2024
b1925ae
fix typo
dkiiv May 7, 2024
f1f7a8a
bugfix: negative steering angle
dkiiv May 7, 2024
2ae4488
switch to hca7 based on NM rate too
dkiiv May 7, 2024
bc9dece
change from NM rate to steeringRate
dkiiv May 7, 2024
6dbdb31
revert back to no rate based hca7 switch
dkiiv May 7, 2024
0e7a07a
up deadzone to 13
dkiiv May 7, 2024
21a753e
13 up for HCA7 worked, dropping HCA5 down to 8
dkiiv May 7, 2024
dc9b580
fix bug, > not < !
dkiiv May 8, 2024
6aaf33c
bugfix: hca7 lock and unlock logic. fixed for reals now!
dkiiv May 8, 2024
ec6c8ae
change delta up ramp rate when HCA7. refactor HCA switch logic a bit
dkiiv May 9, 2024
3a51a8a
added dynamic HCA7 lock behavior, based on NM and angle
dkiiv May 9, 2024
cfd6137
tweak values for HCA mode switching
dkiiv May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion selfdrive/car/volkswagen/carcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ def __init__(self, dbc_name, CP, VM):
self.gra_acc_counter_last = None
self.frame = 0
self.eps_timer_soft_disable_alert = False
self.hca_mode = 5 # init in (active)status 5
self.hca_centerDeadbandHigh = 13 # init center dead band high
self.hca_centerDeadbandLow = 4 # init center dead band low
self.hca_deadbandNM_switch = 150 # init dead band NM switch
self.steeringAngle = 0 # init our own steeringAngle
self.steerDeltaUpHCA5 = self.CCP.STEER_DELTA_UP # init HCA 5 delta up ramp rate
self.steerDeltaUpHCA7 = self.CCP.STEER_DELTA_UP / 2 # init HCA 7 delta up ramp rate, adjust "/" value to change ramp rate difference
self.hca_frame_timer_running = 0
self.hca_frame_same_torque = 0

Expand Down Expand Up @@ -53,6 +60,19 @@ def update(self, CC, CS, ext_bus, now_nanos, frogpilot_variables):
self.hca_frame_same_torque = 0
else:
self.hca_frame_same_torque = 0

if self.CCS == pqcan: # Custom HCA mode switching (PQ only)
self.steeringAngle = CS.out.steeringAngleDeg if CS.out.steeringAngleDeg >= 0 else CS.out.steeringAngleDeg * -1
if (((self.steeringAngle >= self.hca_centerDeadbandHigh and abs(apply_steer) <= self.hca_deadbandNM_switch) or \
(self.steeringAngle >= self.hca_centerDeadbandLow and abs(apply_steer) >= self.hca_deadbandNM_switch)) or \
(self.hca_mode == 7 and ((abs(apply_steer) >= 25 and self.steeringAngle <= self.hca_centerDeadbandLow) or \
self.steeringAngle >= self.hca_centerDeadbandLow))):
self.hca_mode = 7
self.CCP.STEER_DELTA_UP = self.steerDeltaUpHCA7
else:
self.hca_mode = 5
self.CCP.STEER_DELTA_UP = self.steerDeltaUpHCA5

hca_enabled = abs(apply_steer) > 0
else:
hca_enabled = False
Expand All @@ -63,7 +83,7 @@ def update(self, CC, CS, ext_bus, now_nanos, frogpilot_variables):

self.eps_timer_soft_disable_alert = self.hca_frame_timer_running > self.CCP.STEER_TIME_ALERT / DT_CTRL
self.apply_steer_last = apply_steer
can_sends.append(self.CCS.create_steering_control(self.packer_pt, CANBUS.pt, apply_steer, hca_enabled))
can_sends.append(self.CCS.create_steering_control(self.packer_pt, CANBUS.pt, apply_steer, hca_enabled, self.hca_mode))

if self.CP.flags & VolkswagenFlags.STOCK_HCA_PRESENT:
# Pacify VW Emergency Assist driver inactivity detection by changing its view of driver steering input torque
Expand Down
5 changes: 3 additions & 2 deletions selfdrive/car/volkswagen/pqcan.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
def create_steering_control(packer, bus, apply_steer, lkas_enabled):
def create_steering_control(packer, bus, apply_steer, lkas_enabled, hca_mode):

values = {
"LM_Offset": abs(apply_steer),
"LM_OffSign": 1 if apply_steer < 0 else 0,
"HCA_Status": 7 if (lkas_enabled and apply_steer != 0) else 3,
"HCA_Status": hca_mode if (lkas_enabled and apply_steer != 0) else 3,
"Vib_Freq": 16,
}

Expand Down
Loading