the code is darkest before the refactor

pull/23257/head
Jason Young 4 years ago
parent 34b52f5481
commit c0792fe57a
  1. 39
      selfdrive/car/volkswagen/carcontroller.py
  2. 10
      selfdrive/car/volkswagen/interface.py
  3. 22
      selfdrive/car/volkswagen/volkswagencan.py

@ -41,41 +41,44 @@ class CarController():
else: else:
acc_status = CS.tsk_status acc_status = CS.tsk_status
accel = actuators.accel if enabled else 0 accel = clip(actuators.accel, P.ACCEL_MIN, P.ACCEL_MAX) if enabled else 0
accel = clip(accel, P.ACCEL_MIN, P.ACCEL_MAX) if enabled else 0
# FIXME: this needs to become a proper state machine # FIXME: this needs to become a proper state machine
acc_hold_request, acc_hold_release = False, False acc_hold_request, acc_hold_release, acc_hold_type, stopping_distance = False, False, 0, 0
if actuators.longControlState == LongCtrlState.stopping: if actuators.longControlState == LongCtrlState.stopping and CS.out.vEgo < 0.2:
self.acc_stopping = True self.acc_stopping = True
acc_hold_request = not CS.esp_hold_confirmation # Send hold request for ABS/ESP brake-hold until acked if CS.esp_hold_confirmation:
acc_hold_type = 1 # hold
stopping_distance = 3.5
else:
acc_hold_type = 3 # hold_standby
stopping_distance = 0.5
elif enabled: elif enabled:
if self.acc_stopping: if self.acc_stopping:
self.acc_starting = True self.acc_starting = True
self.acc_stopping = False self.acc_stopping = False
self.acc_starting &= CS.out.vEgo < CS.CP.vEgoStarting self.acc_starting &= CS.out.vEgo < 1.5
acc_hold_release = CS.esp_hold_confirmation # Send release request for ABS/ESP brake-hold until acked acc_hold_release = self.acc_starting
stopping_distance = 20.46
if CS.esp_hold_confirmation:
acc_hold_type = 4 # startup
else:
acc_hold_type = 0 # no_request
else: else:
self.acc_stopping, self.acc_starting = False, False self.acc_stopping, self.acc_starting = False, False
# Hopefully, have PI yank the lag out and let the drivetrain coordinator make it smooth again acc_hold_request = self.acc_stopping or (self.acc_starting and CS.esp_hold_confirmation)
cb_pos = 0.0 if lead_visible or CS.out.vEgo < 2.0 else 0.2 # react faster to lead cars, also don't get hung up at DSG clutch release/kiss points when creeping to stop
cb_neg = 0.0 if accel < 0 else 0.2 # IDK why, but stock likes to zero this out when accel is negative
if acc_hold_request: cb_pos = 0.0 if lead_visible or CS.out.vEgo < 2.0 else 0.1 # react faster to lead cars, also don't get hung up at DSG clutch release/kiss points when creeping to stop
weird_value = 0x88 cb_neg = 0.0 if accel < 0 else 0.2 # IDK why, but stock likes to zero this out when accel is negative
elif self.acc_stopping:
weird_value = 0x95
else:
weird_value = 0x7F
idx = (frame / P.ACC_CONTROL_STEP) % 16 idx = (frame / P.ACC_CONTROL_STEP) % 16
can_sends.append(volkswagencan.create_mqb_acc_06_control(self.packer_pt, CANBUS.pt, enabled, acc_status, can_sends.append(volkswagencan.create_mqb_acc_06_control(self.packer_pt, CANBUS.pt, enabled, acc_status,
accel, self.acc_stopping, self.acc_starting, accel, self.acc_stopping, self.acc_starting,
cb_pos, cb_neg, idx)) cb_pos, cb_neg, idx))
can_sends.append(volkswagencan.create_mqb_acc_07_control(self.packer_pt, CANBUS.pt, enabled, can_sends.append(volkswagencan.create_mqb_acc_07_control(self.packer_pt, CANBUS.pt, enabled,
accel, self.acc_stopping, self.acc_starting, accel, acc_hold_request, acc_hold_release,
acc_hold_request, acc_hold_release, weird_value, idx)) acc_hold_type, stopping_distance, idx))
if frame % P.ACC_HUD_STEP == 0: if frame % P.ACC_HUD_STEP == 0:
idx = (frame / P.ACC_HUD_STEP) % 16 idx = (frame / P.ACC_HUD_STEP) % 16

@ -66,15 +66,13 @@ class CarInterface(CarInterfaceBase):
# Global longitudinal tuning defaults, can be overridden per-vehicle # Global longitudinal tuning defaults, can be overridden per-vehicle
ret.pcmCruise = not ret.openpilotLongitudinalControl ret.pcmCruise = not ret.openpilotLongitudinalControl
ret.longitudinalActuatorDelayLowerBound = 0.5 # s
ret.longitudinalActuatorDelayUpperBound = 1.0 # s ret.longitudinalActuatorDelayUpperBound = 1.0 # s
ret.stoppingControl = True ret.stoppingControl = True
ret.vEgoStopping = 0.2 ret.vEgoStopping = 0.4
ret.vEgoStarting = 0.2 ret.vEgoStarting = 0.5
ret.stopAccel = 0.0
ret.startAccel = 0.0 ret.startAccel = 0.0
ret.startingAccelRate = 6.0 ret.stopAccel = -1.0
ret.longitudinalTuning.kpV = [0.1] ret.longitudinalTuning.kpV = [0.0]
ret.longitudinalTuning.kiV = [0.0] ret.longitudinalTuning.kiV = [0.0]
# Per-chassis tuning values, override tuning defaults here if desired # Per-chassis tuning values, override tuning defaults here if desired

@ -65,20 +65,16 @@ def create_mqb_acc_06_control(packer, bus, enabled, acc_status, accel, acc_stopp
return packer.make_can_msg("ACC_06", bus, values, idx) return packer.make_can_msg("ACC_06", bus, values, idx)
def create_mqb_acc_07_control(packer, bus, enabled, accel, acc_stopping, acc_starting, acc_hold_request, def create_mqb_acc_07_control(packer, bus, enabled, accel, acc_hold_request, acc_hold_release,
acc_hold_release, weird_value, idx): acc_hold_type, stopping_distance, idx):
values = { values = {
"XXX_Maybe_Engine_Start_Request": 2, # TODO "ACC_Distance_to_Stop": stopping_distance,
"XXX_Always_1": 1, "ACC_Hold_Request": acc_hold_request,
"XXX_Maybe_Engine_Stop_Release": not acc_hold_request, # TODO this isn't S/S, AHR but also slight delay past AHR "ACC_Freewheel_Type": 2,
"XXX_Unknown": weird_value, # FIXME: Should try to figure out what's really going on here "ACC_Hold_Type": acc_hold_type,
"ACC_Engaged": enabled, "ACC_Hold_Release": acc_hold_release,
"ACC_Anhalten": acc_stopping, "ACC_Accel_Secondary": accel if enabled else 0,
"ACC_Anhaltevorgang": acc_hold_request, "ACC_Accel_Primary": accel if enabled else 3.01,
"ACC_Anfahrvorgang": acc_hold_release,
"ACC_Anfahren": acc_starting,
"ACC_Sollbeschleunigung_01": accel if enabled else 3.01,
"ACC_Sollbeschleunigung_03": accel if enabled else 0,
} }
return packer.make_can_msg("ACC_07", bus, values, idx) return packer.make_can_msg("ACC_07", bus, values, idx)

Loading…
Cancel
Save