use CarControllerParams

pull/22407/head
Willem Melching 4 years ago
parent a99f9e7570
commit ffc66240f4
  1. 2
      selfdrive/car/honda/carcontroller.py
  2. 8
      selfdrive/car/honda/hondacan.py
  3. 22
      selfdrive/car/honda/values.py

@ -217,7 +217,7 @@ class CarController():
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
@ -46,12 +46,12 @@ def create_brake_command(packer, apply_brake, pump_on, pcm_override, pcm_cancel_
def create_acc_commands(packer, enabled, accel, gas, idx, stopping, starting, car_fingerprint): def create_acc_commands(packer, enabled, 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 enabled and accel > min_gas_accel else -30000
gas_command = gas if enabled and gas > -0.2 else -30000
accel_command = accel if enabled else 0 accel_command = accel if enabled else 0
braking = 1 if enabled and accel < -0.2 else 0 braking = 1 if enabled and accel < min_gas_accel else 0
standstill = 1 if enabled and stopping else 0 standstill = 1 if enabled and stopping else 0
standstill_release = 1 if enabled and starting else 0 standstill_release = 1 if enabled and starting else 0

@ -4,6 +4,7 @@ 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
@ -13,11 +14,21 @@ class CarControllerParams():
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, 2.0] # 2m/s^2
self.BOSCH_GAS_LOOKUP_V = [0, 1600]
# Car button codes # Car button codes
class CruiseButtons: class CruiseButtons:

Loading…
Cancel
Save