Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tuning for corolla, add alert when user disengages long control #477

Merged
merged 1 commit into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cereal/car.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ struct CarEvent @0x9b1657f34caf3ad3 {
laneChange @59;
invalidGiraffeToyota @60;
internetConnectivityNeeded @61;
longControlDisabled @62;
}
}

Expand Down
2 changes: 1 addition & 1 deletion common/op_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self):
self.read_timeout = 1.0 # max frequency to read with self.get(...) (sec)
self.default_params = {'camera_offset': 0.06, 'awareness_factor': 2.0, 'lane_hug_direction': None,
'lane_hug_mod': 1.2, 'lane_hug_angle': 10, 'use_car_caching': True, 'osm': True,
'speed_offset': 0, 'keep_openpilot_engaged': True}
'speed_offset': 0, 'keep_openpilot_engaged': True, 'force_pedal': False}
self.force_update = False # replaces values with default params if True, not just add add missing key/value pairs
self.run_init() # restores, reads, and updates params

Expand Down
39 changes: 21 additions & 18 deletions selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay

ret.steerActuatorDelay = 0.12 # Default delay, Prius has larger delay

if ret.enableGasInterceptor:
ret.gasMaxBP = [0., 9., 55]
ret.gasMaxV = [0.2, 0.5, 0.7]
ret.longitudinalTuning.kpV = [0.50, 0.4, 0.3] # braking tune
ret.longitudinalTuning.kiV = [0.0135, 0.01]
else:
ret.gasMaxBP = [0., 9., 55]
ret.gasMaxV = [0.2, 0.5, 0.7]
ret.longitudinalTuning.kpV = [0.325, 0.325, 0.325] # braking tune from rav4h
ret.longitudinalTuning.kiV = [0.001, 0.0010]

if candidate not in [CAR.PRIUS, CAR.RAV4, CAR.RAV4H]: # These cars use LQR/INDI
ret.lateralTuning.init('pid')
ret.lateralTuning.pid.kiBP, ret.lateralTuning.pid.kpBP = [[0.], [0.]]
Expand Down Expand Up @@ -111,11 +122,14 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay
stop_and_go = False
ret.safetyParam = 100
ret.wheelbase = 2.70
ret.steerRatio = 18.27
ret.steerRatio = 17.8
tire_stiffness_factor = 0.444 # not optimized yet
ret.mass = 2860. * CV.LB_TO_KG + STD_CARGO_KG # mean between normal and hybrid
ret.lateralTuning.pid.kpV, ret.lateralTuning.pid.kiV = [[0.2], [0.05]]
ret.lateralTuning.pid.kf = 0.00003 # full torque for 20 deg at 80mph means 0.00007818594
ret.lateralTuning.pid.kf = 0.0000275 # full torque for 20 deg at 80mph means 0.00007818594
if ret.enableGasInterceptor:
ret.longitudinalTuning.kpV = [1.0, 0.66, 0.42]
ret.longitudinalTuning.kiV = [0.135, 0.09]

elif candidate == CAR.LEXUS_RXH:
stop_and_go = True
Expand Down Expand Up @@ -252,7 +266,7 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay
ret.enableCamera = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, ECU.CAM) or has_relay
ret.enableDsu = is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, ECU.DSU) or (has_relay and candidate in TSS2_CAR)
ret.enableApgs = False # is_ecu_disconnected(fingerprint[0], FINGERPRINTS, ECU_FINGERPRINT, candidate, ECU.APGS)
ret.enableGasInterceptor = 0x201 in fingerprint[0]
ret.enableGasInterceptor = 0x201 in fingerprint[0] or opParams().get('force_pedal', False)
ret.openpilotLongitudinalControl = ret.enableCamera and ret.enableDsu
cloudlog.warning("ECU Camera Simulated: %r", ret.enableCamera)
cloudlog.warning("ECU DSU Simulated: %r", ret.enableDsu)
Expand All @@ -272,17 +286,6 @@ def get_params(candidate, fingerprint=gen_empty_fingerprint(), vin="", has_relay
ret.stoppingControl = False
ret.startAccel = 0.0

if ret.enableGasInterceptor:
ret.gasMaxBP = [0., 9., 55]
ret.gasMaxV = [0.2, 0.5, 0.7]
ret.longitudinalTuning.kpV = [0.50, 0.4, 0.3] # braking tune
ret.longitudinalTuning.kiV = [0.0135, 0.01]
else:
ret.gasMaxBP = [0., 9., 55]
ret.gasMaxV = [0.2, 0.5, 0.7]
ret.longitudinalTuning.kpV = [0.325, 0.325, 0.325] # braking tune from rav4h
ret.longitudinalTuning.kiV = [0.001, 0.0010]

return ret

# returns a car.CarState
Expand Down Expand Up @@ -333,12 +336,16 @@ def update(self, c, can_strings):
ret.steeringTorqueEps = self.CS.steer_torque_motor
ret.steeringPressed = self.CS.steer_override

# events
events = []

# cruise state
if not self.cruise_enabled_prev:
ret.cruiseState.enabled = self.CS.pcm_acc_active
else:
ret.cruiseState.enabled = bool(self.CS.main_on)
if not self.CS.pcm_acc_active:
events.append(create_event('longControlDisabled', [ET.WARNING]))
ret.brakePressed = True
if self.CS.v_ego < 1 or not self.keep_openpilot_engaged:
ret.cruiseState.enabled = self.CS.pcm_acc_active
Expand Down Expand Up @@ -375,10 +382,6 @@ def update(self, c, can_strings):
ret.seatbeltUnlatched = not self.CS.seatbelt

ret.genericToggle = self.CS.generic_toggle

# events
events = []
# todo: arne, do we need this section below? it's not present in 066

if ret.cruiseState.enabled and not self.cruise_enabled_prev: # this lets us modularize which checks we want to turn off op if cc was engaged previoiusly or not
disengage_event = True
Expand Down
7 changes: 7 additions & 0 deletions selfdrive/controls/lib/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def __gt__(self, alert2):
AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimePrompt, 1., 2., 3.),

Alert(
"longControlDisabled",
"BRAKE PRESSED",
"Longitudinal Control Disabled",
AlertStatus.userPrompt, AlertSize.mid,
Priority.LOW, VisualAlert.steerRequired, AudibleAlert.chimeWarning1, .4, 2., 3.),

Alert(
"steerTempUnavailable",
"TAKE CONTROL",
Expand Down