use CarControllerParams

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

@ -217,7 +217,7 @@ class CarController():
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
@ -46,20 +46,20 @@ 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):
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.2 else -30000
gas_command = gas if enabled and accel > min_gas_accel else -30000
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_release = 1 if enabled 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,

@ -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
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_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, 2.0] # 2m/s^2
self.BOSCH_GAS_LOOKUP_V = [0, 1600]
# Car button codes
class CruiseButtons:

Loading…
Cancel
Save