mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-07-02 20:12:07 +08:00
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 c972956cb460eedaff3d0169a40673a6ea933385. * update ref old-commit-hash: 6c29a4c7fb83f9a4935d6003970b6b3442cccfd8
This commit is contained in:
@@ -107,7 +107,7 @@ class CarController():
|
||||
|
||||
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):
|
||||
|
||||
P = self.params
|
||||
@@ -165,9 +165,6 @@ class CarController():
|
||||
stopping = actuators.longControlState == LongCtrlState.stopping
|
||||
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 = 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
|
||||
@@ -214,12 +211,13 @@ class CarController():
|
||||
ts = frame * DT_CTRL
|
||||
|
||||
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)
|
||||
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:
|
||||
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)
|
||||
|
||||
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
|
||||
|
||||
# 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)
|
||||
|
||||
|
||||
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 = []
|
||||
bus = get_pt_bus(car_fingerprint)
|
||||
min_gas_accel = CarControllerParams.BOSCH_GAS_LOOKUP_BP[0]
|
||||
|
||||
control_on = 5 if enabled else 0
|
||||
# no gas = -30000
|
||||
gas_command = gas if enabled and gas > 0 else -30000
|
||||
accel_command = accel if enabled else 0
|
||||
braking = 1 if enabled and accel < 0 else 0
|
||||
standstill = 1 if enabled and stopping else 0
|
||||
standstill_release = 1 if enabled and starting else 0
|
||||
gas_command = gas if active and accel > min_gas_accel else -30000
|
||||
accel_command = accel if active else 0
|
||||
braking = 1 if active and accel < min_gas_accel else 0
|
||||
standstill = 1 if active and stopping else 0
|
||||
standstill_release = 1 if active and starting else 0
|
||||
|
||||
acc_control_values = {
|
||||
# setting CONTROL_ON causes car to set POWERTRAIN_DATA->ACC_STATUS = 1
|
||||
"CONTROL_ON": control_on,
|
||||
"GAS_COMMAND": gas_command, # used for gas
|
||||
"ACCEL_COMMAND": accel_command, # used for brakes
|
||||
"GAS_COMMAND": gas_command, # used for gas
|
||||
"ACCEL_COMMAND": accel_command, # used for brakes
|
||||
"BRAKE_LIGHTS": braking,
|
||||
"BRAKE_REQUEST": braking,
|
||||
"STANDSTILL": standstill,
|
||||
|
||||
@@ -39,7 +39,6 @@ class CarInterface(CarInterfaceBase):
|
||||
# Disable the radar and let openpilot control longitudinal
|
||||
# WARNING: THIS DISABLES AEB!
|
||||
ret.openpilotLongitudinalControl = Params().get_bool("DisableRadar")
|
||||
ret.longitudinalActuatorDelayUpperBound = 1.0 # s
|
||||
|
||||
ret.pcmCruise = not ret.openpilotLongitudinalControl
|
||||
else:
|
||||
@@ -65,11 +64,16 @@ class CarInterface(CarInterfaceBase):
|
||||
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
|
||||
ret.lateralTuning.pid.kf = 0.00006 # conservative feed-forward
|
||||
|
||||
# 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]
|
||||
if candidate in HONDA_BOSCH:
|
||||
ret.longitudinalTuning.kpV = [0.25]
|
||||
ret.longitudinalTuning.kiV = [0.05]
|
||||
ret.longitudinalActuatorDelayUpperBound = 0.5 # s
|
||||
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
|
||||
for fw in car_fw:
|
||||
@@ -414,7 +418,7 @@ class CarInterface(CarInterfaceBase):
|
||||
else:
|
||||
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.cruiseControl.cancel,
|
||||
hud_v_cruise,
|
||||
|
||||
@@ -4,20 +4,31 @@ from selfdrive.car import dbc_dict
|
||||
Ecu = car.CarParams.Ecu
|
||||
VisualAlert = car.CarControl.HUDControl.VisualAlert
|
||||
|
||||
|
||||
class CarControllerParams():
|
||||
# Allow small margin below -3.5 m/s^2 from ISO 15622:2018 since we
|
||||
# perform the closed loop control, and might need some
|
||||
# to apply some more braking if we're on a downhill slope.
|
||||
# Our controller should still keep the 2 second average above
|
||||
# -3.5 m/s^2 as per planner limits
|
||||
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_MIN = -4.0 # m/s^2
|
||||
NIDEC_ACCEL_MAX = 1.6 # m/s^2, lower than 2.0 m/s^2 for tuning reasons
|
||||
|
||||
BOSCH_ACCEL_MIN = -3.5 # m/s^2
|
||||
BOSCH_ACCEL_MAX = 2.0 # m/s^2
|
||||
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_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):
|
||||
self.BRAKE_MAX = 1024//4
|
||||
self.STEER_MAX = CP.lateralParams.torqueBP[-1]
|
||||
# mirror of list (assuming first item is zero) for interp of signed request values
|
||||
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_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
|
||||
class CruiseButtons:
|
||||
|
||||
@@ -1 +1 @@
|
||||
641884dca2102fe74e3164f8ce001cf3294b3255
|
||||
dc264ed5d283bbfe4dd44c5f65db3eb5cef210eb
|
||||
Reference in New Issue
Block a user