Honda Bosch longitudinal tuning (#22407)

* revert changes to standstill logic

* start with mostly open loop

* Revert "revert changes to standstill logic"

This reverts commit d737d858e7708aedaf09cfc068b85398161e9bbe.

* proper clipping

* less lag

* less gas command

* start gas from -0.2

* controls should take care of that

* use CarControllerParams

* switch to braking sooner

* Revert "switch to braking sooner"

This reverts commit cf11dae334ccb369f625d4b13b7cd4176156a446.

* 2.5x more P

* use active

* engage on rising edge

* Revert "engage on rising edge"

This reverts commit c972956cb4.

* update ref
pull/22475/head
Willem Melching 4 years ago committed by GitHub
parent 43d9478740
commit 6c29a4c7fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      selfdrive/car/honda/carcontroller.py
  2. 20
      selfdrive/car/honda/hondacan.py
  3. 18
      selfdrive/car/honda/interface.py
  4. 30
      selfdrive/car/honda/values.py
  5. 2
      selfdrive/test/process_replay/ref_commit

@ -107,7 +107,7 @@ class CarController():
self.params = CarControllerParams(CP) self.params = CarControllerParams(CP)
def update(self, enabled, CS, frame, actuators, pcm_cancel_cmd, def update(self, enabled, active, CS, frame, actuators, pcm_cancel_cmd,
hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert): hud_v_cruise, hud_show_lanes, hud_show_car, hud_alert):
P = self.params P = self.params
@ -165,9 +165,6 @@ class CarController():
stopping = actuators.longControlState == LongCtrlState.stopping stopping = actuators.longControlState == LongCtrlState.stopping
starting = actuators.longControlState == LongCtrlState.starting starting = actuators.longControlState == LongCtrlState.starting
# Prevent rolling backwards
accel = -4.0 if stopping else accel
# wind brake from air resistance decel at high speed # wind brake from air resistance decel at high speed
wind_brake = interp(CS.out.vEgo, [0.0, 2.3, 35.0], [0.001, 0.002, 0.15]) wind_brake = interp(CS.out.vEgo, [0.0, 2.3, 35.0], [0.001, 0.002, 0.15])
# all of this is only relevant for HONDA NIDEC # all of this is only relevant for HONDA NIDEC
@ -214,12 +211,13 @@ class CarController():
ts = frame * DT_CTRL ts = frame * DT_CTRL
if CS.CP.carFingerprint in HONDA_BOSCH: if CS.CP.carFingerprint in HONDA_BOSCH:
accel = clip(accel, P.BOSCH_ACCEL_MIN, P.BOSCH_ACCEL_MAX)
bosch_gas = interp(accel, P.BOSCH_GAS_LOOKUP_BP, P.BOSCH_GAS_LOOKUP_V) bosch_gas = interp(accel, P.BOSCH_GAS_LOOKUP_BP, P.BOSCH_GAS_LOOKUP_V)
can_sends.extend(hondacan.create_acc_commands(self.packer, enabled, accel, bosch_gas, idx, stopping, starting, CS.CP.carFingerprint)) can_sends.extend(hondacan.create_acc_commands(self.packer, enabled, active, accel, bosch_gas, idx, stopping, starting, CS.CP.carFingerprint))
else: else:
apply_brake = clip(self.brake_last - wind_brake, 0.0, 1.0) apply_brake = clip(self.brake_last - wind_brake, 0.0, 1.0)
apply_brake = int(clip(apply_brake * P.BRAKE_MAX, 0, P.BRAKE_MAX - 1)) apply_brake = int(clip(apply_brake * P.NIDEC_BRAKE_MAX, 0, P.NIDEC_BRAKE_MAX - 1))
pump_on, self.last_pump_ts = brake_pump_hysteresis(apply_brake, self.apply_brake_last, self.last_pump_ts, ts) pump_on, self.last_pump_ts = brake_pump_hysteresis(apply_brake, self.apply_brake_last, self.last_pump_ts, ts)
pcm_override = True pcm_override = True

@ -1,4 +1,4 @@
from selfdrive.car.honda.values import HONDA_BOSCH, CAR from selfdrive.car.honda.values import HONDA_BOSCH, CAR, CarControllerParams
from selfdrive.config import Conversions as CV from selfdrive.config import Conversions as CV
# CAN bus layout with relay # CAN bus layout with relay
@ -43,23 +43,23 @@ def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_
return packer.make_can_msg("BRAKE_COMMAND", bus, values, idx) return packer.make_can_msg("BRAKE_COMMAND", bus, values, idx)
def create_acc_commands(packer, enabled, accel, gas, idx, stopping, starting, car_fingerprint): def create_acc_commands(packer, enabled, active, accel, gas, idx, stopping, starting, car_fingerprint):
commands = [] commands = []
bus = get_pt_bus(car_fingerprint) bus = get_pt_bus(car_fingerprint)
min_gas_accel = CarControllerParams.BOSCH_GAS_LOOKUP_BP[0]
control_on = 5 if enabled else 0 control_on = 5 if enabled else 0
# no gas = -30000 gas_command = gas if active and accel > min_gas_accel else -30000
gas_command = gas if enabled and gas > 0 else -30000 accel_command = accel if active else 0
accel_command = accel if enabled else 0 braking = 1 if active and accel < min_gas_accel else 0
braking = 1 if enabled and accel < 0 else 0 standstill = 1 if active and stopping else 0
standstill = 1 if enabled and stopping else 0 standstill_release = 1 if active and starting else 0
standstill_release = 1 if enabled and starting else 0
acc_control_values = { acc_control_values = {
# setting CONTROL_ON causes car to set POWERTRAIN_DATA->ACC_STATUS = 1 # setting CONTROL_ON causes car to set POWERTRAIN_DATA->ACC_STATUS = 1
"CONTROL_ON": control_on, "CONTROL_ON": control_on,
"GAS_COMMAND": gas_command, # used for gas "GAS_COMMAND": gas_command, # used for gas
"ACCEL_COMMAND": accel_command, # used for brakes "ACCEL_COMMAND": accel_command, # used for brakes
"BRAKE_LIGHTS": braking, "BRAKE_LIGHTS": braking,
"BRAKE_REQUEST": braking, "BRAKE_REQUEST": braking,
"STANDSTILL": standstill, "STANDSTILL": standstill,

@ -39,7 +39,6 @@ class CarInterface(CarInterfaceBase):
# Disable the radar and let openpilot control longitudinal # Disable the radar and let openpilot control longitudinal
# WARNING: THIS DISABLES AEB! # WARNING: THIS DISABLES AEB!
ret.openpilotLongitudinalControl = Params().get_bool("DisableRadar") ret.openpilotLongitudinalControl = Params().get_bool("DisableRadar")
ret.longitudinalActuatorDelayUpperBound = 1.0 # s
ret.pcmCruise = not ret.openpilotLongitudinalControl ret.pcmCruise = not ret.openpilotLongitudinalControl
else: else:
@ -65,11 +64,16 @@ class CarInterface(CarInterfaceBase):
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]] ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
ret.lateralTuning.pid.kf = 0.00006 # conservative feed-forward ret.lateralTuning.pid.kf = 0.00006 # conservative feed-forward
# default longitudinal tuning for all hondas if candidate in HONDA_BOSCH:
ret.longitudinalTuning.kpBP = [0., 5., 35.] ret.longitudinalTuning.kpV = [0.25]
ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5] ret.longitudinalTuning.kiV = [0.05]
ret.longitudinalTuning.kiBP = [0., 35.] ret.longitudinalActuatorDelayUpperBound = 0.5 # s
ret.longitudinalTuning.kiV = [0.18, 0.12] else:
# default longitudinal tuning for all hondas
ret.longitudinalTuning.kpBP = [0., 5., 35.]
ret.longitudinalTuning.kpV = [1.2, 0.8, 0.5]
ret.longitudinalTuning.kiBP = [0., 35.]
ret.longitudinalTuning.kiV = [0.18, 0.12]
eps_modified = False eps_modified = False
for fw in car_fw: for fw in car_fw:
@ -414,7 +418,7 @@ class CarInterface(CarInterfaceBase):
else: else:
hud_v_cruise = 255 hud_v_cruise = 255
can_sends = self.CC.update(c.enabled, self.CS, self.frame, can_sends = self.CC.update(c.enabled, c.active, self.CS, self.frame,
c.actuators, c.actuators,
c.cruiseControl.cancel, c.cruiseControl.cancel,
hud_v_cruise, hud_v_cruise,

@ -4,20 +4,31 @@ from selfdrive.car import dbc_dict
Ecu = car.CarParams.Ecu Ecu = car.CarParams.Ecu
VisualAlert = car.CarControl.HUDControl.VisualAlert VisualAlert = car.CarControl.HUDControl.VisualAlert
class CarControllerParams(): class CarControllerParams():
# Allow small margin below -3.5 m/s^2 from ISO 15622:2018 since we # Allow small margin below -3.5 m/s^2 from ISO 15622:2018 since we
# perform the closed loop control, and might need some # perform the closed loop control, and might need some
# to apply some more braking if we're on a downhill slope. # to apply some more braking if we're on a downhill slope.
# Our controller should still keep the 2 second average above # Our controller should still keep the 2 second average above
# -3.5 m/s^2 as per planner limits # -3.5 m/s^2 as per planner limits
NIDEC_ACCEL_MIN = -4.0 # m/s^2 NIDEC_ACCEL_MIN = -4.0 # m/s^2
NIDEC_ACCEL_MAX = 1.6 # m/s^2, lower than 2.0 m/s^2 for tuning reasons NIDEC_ACCEL_MAX = 1.6 # m/s^2, lower than 2.0 m/s^2 for tuning reasons
NIDEC_ACCEL_LOOKUP_BP = [-1., 0., .6]
NIDEC_ACCEL_LOOKUP_V = [-4.8, 0., 2.0]
NIDEC_MAX_ACCEL_V = [0.5, 2.4, 1.4, 0.6]
NIDEC_MAX_ACCEL_BP = [0.0, 4.0, 10., 20.]
NIDEC_BRAKE_MAX = 1024 // 4
BOSCH_ACCEL_MIN = -3.5 # m/s^2 BOSCH_ACCEL_MIN = -3.5 # m/s^2
BOSCH_ACCEL_MAX = 2.0 # m/s^2 BOSCH_ACCEL_MAX = 2.0 # m/s^2
BOSCH_GAS_LOOKUP_BP = [-0.2, 2.0] # 2m/s^2
BOSCH_GAS_LOOKUP_V = [0, 1600]
def __init__(self, CP): def __init__(self, CP):
self.BRAKE_MAX = 1024//4
self.STEER_MAX = CP.lateralParams.torqueBP[-1] self.STEER_MAX = CP.lateralParams.torqueBP[-1]
# mirror of list (assuming first item is zero) for interp of signed request values # mirror of list (assuming first item is zero) for interp of signed request values
assert(CP.lateralParams.torqueBP[0] == 0) assert(CP.lateralParams.torqueBP[0] == 0)
@ -25,15 +36,6 @@ class CarControllerParams():
self.STEER_LOOKUP_BP = [v * -1 for v in CP.lateralParams.torqueBP][1:][::-1] + list(CP.lateralParams.torqueBP) self.STEER_LOOKUP_BP = [v * -1 for v in CP.lateralParams.torqueBP][1:][::-1] + list(CP.lateralParams.torqueBP)
self.STEER_LOOKUP_V = [v * -1 for v in CP.lateralParams.torqueV][1:][::-1] + list(CP.lateralParams.torqueV) self.STEER_LOOKUP_V = [v * -1 for v in CP.lateralParams.torqueV][1:][::-1] + list(CP.lateralParams.torqueV)
self.NIDEC_ACCEL_LOOKUP_BP = [-1., 0., .6]
self.NIDEC_ACCEL_LOOKUP_V = [-4.8, 0., 2.0]
self.NIDEC_MAX_ACCEL_V = [0.5, 2.4, 1.4, 0.6]
self.NIDEC_MAX_ACCEL_BP = [0.0, 4.0, 10., 20.]
self.BOSCH_GAS_LOOKUP_BP = [0., 2.0] # 2m/s^2
self.BOSCH_GAS_LOOKUP_V = [0, 2000]
# Car button codes # Car button codes
class CruiseButtons: class CruiseButtons:

@ -1 +1 @@
641884dca2102fe74e3164f8ce001cf3294b3255 dc264ed5d283bbfe4dd44c5f65db3eb5cef210eb
Loading…
Cancel
Save